e2e: refactors the most flaky tests (#33727)

This commit is contained in:
Hugo Häggmark 2021-05-05 09:09:57 +02:00 committed by GitHub
parent 79772bcd2a
commit 86f2ed8ef2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 35 deletions

View File

@ -2,6 +2,7 @@ import { e2e } from '@grafana/e2e';
import { expect } from '../../../public/test/lib/common';
const PANEL_UNDER_TEST = 'Random walk series';
const flakyTimeout = 10000;
e2e.scenario({
describeName: 'Panel edit tests - queries',
@ -25,31 +26,17 @@ e2e.scenario({
expect(rows.length).equals(1);
});
e2e().server();
e2e()
.route({
method: 'POST',
url: '/api/ds/query',
})
.as('apiPostQuery');
// Add query button should be visible and clicking on it should create a new row
e2e.components.QueryTab.addQuery().scrollIntoView().should('be.visible').click();
// We expect row with refId A and B to exist and be visible
e2e.components.QueryEditorRows.rows().within((rows) => {
expect(rows.length).equals(2);
});
e2e.components.QueryEditorRows.rows({ timeout: flakyTimeout }).should('have.length', 2);
// Remove refId A
e2e.components.QueryEditorRow.actionButton('Remove query').eq(0).should('be.visible').click();
e2e().wait('@apiPostQuery');
// We expect row with refId B to exist and be visible
e2e.components.QueryEditorRows.rows().within((rows) => {
expect(rows.length).equals(1);
});
e2e.components.QueryEditorRows.rows({ timeout: flakyTimeout }).should('have.length', 1);
// Duplicate refId B
e2e.components.QueryEditorRow.actionButton('Duplicate query').eq(0).should('be.visible').click();
@ -68,8 +55,6 @@ e2e.scenario({
cy.contains('CSV Metric Values').scrollIntoView().should('be.visible').eq(0).click();
});
e2e().wait('@apiPostQuery');
// Disable / enable row
expectInspectorResultAndClose((keys) => {
const length = keys.length;
@ -85,8 +70,6 @@ e2e.scenario({
// Disable row with refId A
e2e.components.QueryEditorRow.actionButton('Disable/enable query').eq(1).should('be.visible').click();
e2e().wait('@apiPostQuery');
expectInspectorResultAndClose((keys) => {
const length = keys.length;
expect(keys[length - 1].innerText).equals('B:');
@ -95,8 +78,6 @@ e2e.scenario({
// Enable row with refId B
e2e.components.QueryEditorRow.actionButton('Disable/enable query').eq(1).should('be.visible').click();
e2e().wait('@apiPostQuery');
expectInspectorResultAndClose((keys) => {
const length = keys.length;
const resultIds = new Set<string>([
@ -115,9 +96,7 @@ const expectInspectorResultAndClose = (expectCallBack: (keys: any[]) => void) =>
e2e.components.PanelInspector.Query.refreshButton().should('be.visible').click();
e2e().wait('@apiPostQuery');
e2e.components.PanelInspector.Query.jsonObjectKeys()
e2e.components.PanelInspector.Query.jsonObjectKeys({ timeout: flakyTimeout })
.should('be.visible')
.within((keys: any) => expectCallBack(keys));

View File

@ -1,14 +1,12 @@
import { e2e } from '@grafana/e2e';
const PAGE_UNDER_TEST = '-Y-tnEDWk/templating-nested-template-variables';
const flakyTimeout = 5000;
describe('Variables - Set options from ui', () => {
it('clicking a value that is not part of dependents options should change these to All', () => {
e2e.flows.login('admin', 'admin');
e2e.flows.openDashboard({ uid: `${PAGE_UNDER_TEST}?orgId=1&var-datacenter=A&var-server=AA&var-pod=AAA` });
e2e().intercept('/api/ds/query').as('query');
e2e().wait('@query');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('A').should('be.visible').click();
@ -16,11 +14,9 @@ describe('Variables - Set options from ui', () => {
e2e.components.PageToolbar.container().click();
e2e().wait('@query');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('B').scrollIntoView().should('be.visible');
e2e.components.LoadingIndicator.icon().should('have.length', 0);
e2e().wait(flakyTimeout);
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All')
.should('have.length', 2)
@ -28,8 +24,6 @@ describe('Variables - Set options from ui', () => {
.should('be.visible')
.click();
e2e().wait(2000);
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
@ -41,9 +35,9 @@ describe('Variables - Set options from ui', () => {
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('BB').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('BC').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All').should('be.visible').click();
e2e().wait(flakyTimeout);
e2e().wait(2000);
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')