From 9d632109ee5023cf30b9bd67822f9ad71a4a87f2 Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Tue, 26 Sep 2023 10:24:29 +0100 Subject: [PATCH 1/3] add more time to enable table load properly --- cypress/support/commands.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 882bc15997..18fcf856ab 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -54,7 +54,9 @@ Cypress.Commands.add("deleteMachine", (hostname: string) => { cy.visit(generateMAASURL("/machines")); cy.findByRole("combobox", { name: "Group by" }).select("No grouping"); cy.findByRole("searchbox").type(hostname); - cy.findByText(/Showing 1 out of 1 machines/).should("exist"); + cy.findByText(/Showing 1 out of 1 machines/, { timeout: 15000 }).should( + "exist" + ); cy.findByRole("grid", { name: /Machines/ }).within(() => cy .findByRole("checkbox", { name: new RegExp(hostname) }) @@ -146,7 +148,9 @@ Cypress.Commands.add("waitForPageToLoad", () => { Cypress.Commands.add("waitForTableToLoad", ({ name } = { name: undefined }) => { cy.findByRole("grid", { name: /Loading/i }).should("exist"); - cy.findByRole("grid", { name: /Loading/i }).should("not.exist"); + cy.findByRole("grid", { name: /Loading/i, timeout: 15000 }).should( + "not.exist" + ); return cy.findByRole("grid", { name }).should("exist"); }); From 3c3ccb0efec829c82f151cc89466a4f35520314c Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Tue, 26 Sep 2023 10:25:30 +0100 Subject: [PATCH 2/3] add wait for table loading --- cypress/e2e/with-users/machines/actions.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/with-users/machines/actions.spec.ts b/cypress/e2e/with-users/machines/actions.spec.ts index 3742f20200..24faa980ae 100644 --- a/cypress/e2e/with-users/machines/actions.spec.ts +++ b/cypress/e2e/with-users/machines/actions.spec.ts @@ -117,7 +117,10 @@ context("Machine listing - actions", () => { const machineName = generateName("machine"); cy.addMachine(machineName); cy.findByRole("searchbox", { name: "Search" }).type(machineName); - cy.findByRole("checkbox", { name: `${machineName}.maas` }).click({ + cy.waitForTableToLoad({ name: /Machines/i }); + cy.findByRole("checkbox", { + name: `${machineName}.maas`, + }).click({ force: true, }); openMachineActionForm("Categorise", "Set pool"); From b99d4573df115d58f3f5129d6172f338f2e81b30 Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Tue, 26 Sep 2023 11:20:24 +0100 Subject: [PATCH 3/3] use timeout constant --- cypress/support/commands.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 18fcf856ab..8a891205ed 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -54,9 +54,9 @@ Cypress.Commands.add("deleteMachine", (hostname: string) => { cy.visit(generateMAASURL("/machines")); cy.findByRole("combobox", { name: "Group by" }).select("No grouping"); cy.findByRole("searchbox").type(hostname); - cy.findByText(/Showing 1 out of 1 machines/, { timeout: 15000 }).should( - "exist" - ); + cy.findByText(/Showing 1 out of 1 machines/, { + timeout: LONG_TIMEOUT, + }).should("exist"); cy.findByRole("grid", { name: /Machines/ }).within(() => cy .findByRole("checkbox", { name: new RegExp(hostname) }) @@ -148,7 +148,7 @@ Cypress.Commands.add("waitForPageToLoad", () => { Cypress.Commands.add("waitForTableToLoad", ({ name } = { name: undefined }) => { cy.findByRole("grid", { name: /Loading/i }).should("exist"); - cy.findByRole("grid", { name: /Loading/i, timeout: 15000 }).should( + cy.findByRole("grid", { name: /Loading/i, timeout: LONG_TIMEOUT }).should( "not.exist" ); return cy.findByRole("grid", { name }).should("exist");