From 8cceda66eefca5af3f12d0346023b75c4985a969 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Fri, 17 Jun 2022 11:08:17 +0200 Subject: [PATCH] Make cypress tests for spotlight less flaky (#8856) --- .../12-spotlight/spotlight.spec.ts | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/cypress/integration/12-spotlight/spotlight.spec.ts b/cypress/integration/12-spotlight/spotlight.spec.ts index df5cc134c40..3862dc638fd 100644 --- a/cypress/integration/12-spotlight/spotlight.spec.ts +++ b/cypress/integration/12-spotlight/spotlight.spec.ts @@ -282,21 +282,41 @@ describe("Spotlight", () => { cy.openSpotlightDialog().within(() => { cy.spotlightFilter(Filter.People); cy.spotlightSearch().clear().type("b"); - cy.spotlightResults().should("have.length", 2); - cy.spotlightResults().eq(0).should("have.attr", "aria-selected", "true"); - cy.spotlightResults().eq(1).should("have.attr", "aria-selected", "false"); - cy.spotlightSearch().type("{downArrow}"); - cy.spotlightResults().eq(0).should("have.attr", "aria-selected", "false"); - cy.spotlightResults().eq(1).should("have.attr", "aria-selected", "true"); - cy.spotlightSearch().type("{downArrow}"); - cy.spotlightResults().eq(0).should("have.attr", "aria-selected", "false"); - cy.spotlightResults().eq(1).should("have.attr", "aria-selected", "false"); - cy.spotlightSearch().type("{upArrow}"); - cy.spotlightResults().eq(0).should("have.attr", "aria-selected", "false"); - cy.spotlightResults().eq(1).should("have.attr", "aria-selected", "true"); - cy.spotlightSearch().type("{upArrow}"); - cy.spotlightResults().eq(0).should("have.attr", "aria-selected", "true"); - cy.spotlightResults().eq(1).should("have.attr", "aria-selected", "false"); + // our debouncing logic only starts the search after a short timeout, + // so we wait a few milliseconds. + cy.wait(300); + cy.get(".mx_Spinner").should("not.exist").then(() => { + cy.spotlightResults().should("have.length", 2).then(() => { + cy.spotlightResults().eq(0) + .should("have.attr", "aria-selected", "true"); + cy.spotlightResults().eq(1) + .should("have.attr", "aria-selected", "false"); + }); + cy.spotlightSearch().type("{downArrow}").then(() => { + cy.spotlightResults().eq(0) + .should("have.attr", "aria-selected", "false"); + cy.spotlightResults().eq(1) + .should("have.attr", "aria-selected", "true"); + }); + cy.spotlightSearch().type("{downArrow}").then(() => { + cy.spotlightResults().eq(0) + .should("have.attr", "aria-selected", "false"); + cy.spotlightResults().eq(1) + .should("have.attr", "aria-selected", "false"); + }); + cy.spotlightSearch().type("{upArrow}").then(() => { + cy.spotlightResults().eq(0) + .should("have.attr", "aria-selected", "false"); + cy.spotlightResults().eq(1) + .should("have.attr", "aria-selected", "true"); + }); + cy.spotlightSearch().type("{upArrow}").then(() => { + cy.spotlightResults().eq(0) + .should("have.attr", "aria-selected", "true"); + cy.spotlightResults().eq(1) + .should("have.attr", "aria-selected", "false"); + }); + }); }); }); });