From 86f2ed8ef2a7d8a6f1caa0d3a2fb6cb8dd7bbc15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=A4ggmark?= Date: Wed, 5 May 2021 09:09:57 +0200 Subject: [PATCH] e2e: refactors the most flaky tests (#33727) --- e2e/suite1/specs/panelEdit_queries.spec.ts | 29 +++---------------- .../specs/variables/set-options-from-ui.ts | 14 +++------ 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/e2e/suite1/specs/panelEdit_queries.spec.ts b/e2e/suite1/specs/panelEdit_queries.spec.ts index f18ab566f8d..db20e9eb485 100644 --- a/e2e/suite1/specs/panelEdit_queries.spec.ts +++ b/e2e/suite1/specs/panelEdit_queries.spec.ts @@ -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([ @@ -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)); diff --git a/e2e/suite1/specs/variables/set-options-from-ui.ts b/e2e/suite1/specs/variables/set-options-from-ui.ts index 87949ff4b16..9449ce8fb7d 100644 --- a/e2e/suite1/specs/variables/set-options-from-ui.ts +++ b/e2e/suite1/specs/variables/set-options-from-ui.ts @@ -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')