From b11c264df3ac6c7a83d22c81158ee774ac286cb1 Mon Sep 17 00:00:00 2001 From: Sven Grossmann Date: Fri, 2 Jun 2023 12:35:11 +0200 Subject: [PATCH] Loki: Fix e2e flakiness (#69441) fix loki e2e test flakiness by waiting for requests to finish --- e2e/various-suite/loki-query-builder.spec.ts | 29 ++++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/e2e/various-suite/loki-query-builder.spec.ts b/e2e/various-suite/loki-query-builder.spec.ts index c2f6a98675e..cadbf4b64f2 100644 --- a/e2e/various-suite/loki-query-builder.spec.ts +++ b/e2e/various-suite/loki-query-builder.spec.ts @@ -31,14 +31,22 @@ describe('Loki query builder', () => { }); it('should be able to use all modes', () => { - e2e().intercept(/labels?/, (req) => { - req.reply({ status: 'success', data: ['instance', 'job', 'source'] }); - }); + e2e() + .intercept(/labels\?/, (req) => { + req.reply({ status: 'success', data: ['instance', 'job', 'source'] }); + }) + .as('labelsRequest'); e2e().intercept(/series?/, (req) => { req.reply({ status: 'success', data: [{ instance: 'instance1' }] }); }); + e2e() + .intercept(/values/, (req) => { + req.reply({ status: 'success', data: ['instance1', 'instance2'] }); + }) + .as('valuesRequest'); + // Go to Explore and choose Loki data source e2e.pages.Explore.visit(); e2e.components.DataSourcePicker.container().should('be.visible').click(); @@ -62,13 +70,16 @@ describe('Loki query builder', () => { e2e().contains(MISSING_LABEL_FILTER_ERROR_MESSAGE).should('be.visible'); // Add labels to remove error - e2e.components.QueryBuilder.labelSelect().should('be.visible').click().type('instance{enter}'); + e2e.components.QueryBuilder.labelSelect().should('be.visible').click(); + // wait until labels are loaded and set on the component before starting to type + e2e().wait('@labelsRequest'); + e2e().wait(100); + e2e.components.QueryBuilder.labelSelect().type('instance{enter}'); e2e.components.QueryBuilder.matchOperatorSelect().should('be.visible').click().type('=~{enter}'); - e2e.components.QueryBuilder.valueSelect() - .should('be.visible') - .click() - .type('instance1{enter}') - .type('instance2{enter}'); + e2e.components.QueryBuilder.valueSelect().should('be.visible').click(); + e2e().wait('@valuesRequest'); + e2e().wait(100); + e2e.components.QueryBuilder.valueSelect().type('instance1{enter}').type('instance2{enter}'); e2e().contains(MISSING_LABEL_FILTER_ERROR_MESSAGE).should('not.exist'); e2e().contains(finalQuery).should('be.visible');