From 29598d83ce14a6babac301b942fdcaa59fe178e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=A4ggmark?= Date: Fri, 5 Jun 2020 06:53:47 +0200 Subject: [PATCH] e2e: waits for requests to minimize flakiness (#25368) --- e2e/suite1/specs/panelEdit_queries.spec.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/e2e/suite1/specs/panelEdit_queries.spec.ts b/e2e/suite1/specs/panelEdit_queries.spec.ts index 96f34c0bce0..68d7f844a42 100644 --- a/e2e/suite1/specs/panelEdit_queries.spec.ts +++ b/e2e/suite1/specs/panelEdit_queries.spec.ts @@ -25,6 +25,14 @@ e2e.scenario({ expect(rows.length).equals(1); }); + e2e().server(); + e2e() + .route({ + method: 'POST', + url: '/api/tsdb/query', + }) + .as('apiPostQuery'); + // Add query button should be visible and clicking on it should create a new row e2e.components.QueryTab.addQuery() .scrollIntoView() @@ -42,6 +50,8 @@ e2e.scenario({ .should('be.visible') .click(); + cy.wait('@apiPostQuery'); + // We expect row with refId B to exist and be visible e2e.components.QueryEditorRows.rows().within(rows => { expect(rows.length).equals(1); @@ -63,6 +73,8 @@ e2e.scenario({ .eq(1) .select('CSV Metric Values'); + cy.wait('@apiPostQuery'); + // Change order or query rows // Check the order of the rows before e2e.components.QueryEditorRows.rows() @@ -82,6 +94,8 @@ e2e.scenario({ .eq(1) .click(); + cy.wait('@apiPostQuery'); + // Check the order of the rows after change e2e.components.QueryEditorRows.rows() .eq(0) @@ -108,6 +122,8 @@ e2e.scenario({ .should('be.visible') .click(); + cy.wait('@apiPostQuery'); + expectInspectorResultAndClose(keys => { const length = keys.length; expect(keys[length - 1].innerText).equals('A:'); @@ -119,6 +135,8 @@ e2e.scenario({ .should('be.visible') .click(); + cy.wait('@apiPostQuery'); + expectInspectorResultAndClose(keys => { const length = keys.length; expect(keys[length - 2].innerText).equals('A:'); @@ -136,6 +154,8 @@ const expectInspectorResultAndClose = (expectCallBack: (keys: any[]) => void) => .should('be.visible') .click(); + cy.wait('@apiPostQuery'); + e2e.components.PanelInspector.Query.jsonObjectKeys() .should('be.visible') .within((keys: any) => expectCallBack(keys));