From d4be3f254b81d1f6f0ed71cc03a76d75553930b7 Mon Sep 17 00:00:00 2001 From: Peter Makowski Date: Tue, 12 Dec 2023 16:28:00 +0100 Subject: [PATCH] test: update cypres test selectors --- cypress/e2e/with-users/machines/actions.spec.ts | 10 +++++++--- cypress/e2e/with-users/subnets/subnets.spec.ts | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/with-users/machines/actions.spec.ts b/cypress/e2e/with-users/machines/actions.spec.ts index be36b456f39..f9a9af78b0d 100644 --- a/cypress/e2e/with-users/machines/actions.spec.ts +++ b/cypress/e2e/with-users/machines/actions.spec.ts @@ -44,8 +44,12 @@ const selectFirstMachine = () => .within(() => cy.findByRole("checkbox").click({ force: true })); }); +const openMachineActionDropdown = (groupLabel: string) => { + cy.findAllByRole("button", { name: groupLabel }).first().click(); +}; + const openMachineActionForm = (groupLabel: string, action: string) => { - cy.findByRole("button", { name: groupLabel }).click(); + openMachineActionDropdown(groupLabel); cy.findByLabelText("submenu").within(() => { cy.findAllByRole("button", { name: new RegExp(`${action}...`), @@ -70,7 +74,7 @@ context("Machine listing - actions", () => { it("displays the correct actions in the action menu", () => { selectFirstMachine(); MACHINE_ACTIONS_GROUPS.forEach((actionGroup) => { - cy.findByRole("button", { name: actionGroup.label }).click(); + openMachineActionDropdown(actionGroup.label); cy.findByLabelText("submenu").within(() => { cy.findAllByRole("button").should( "have.length", @@ -166,7 +170,7 @@ context("Machine listing - actions", () => { it("can open a soft power off form", () => { selectFirstMachine(); - cy.findByRole("button", { name: /power cycle/i }).click(); + cy.findAllByRole("button", { name: "Power" }).first().click(); cy.findByRole("button", { name: /soft power off\.\.\./i }).click(); cy.findByRole("complementary", { name: /soft power off/i }).should("exist"); cy.findByRole("heading", { name: /soft power off/i }).should("exist"); diff --git a/cypress/e2e/with-users/subnets/subnets.spec.ts b/cypress/e2e/with-users/subnets/subnets.spec.ts index da5963d670b..833472dd07b 100644 --- a/cypress/e2e/with-users/subnets/subnets.spec.ts +++ b/cypress/e2e/with-users/subnets/subnets.spec.ts @@ -4,6 +4,7 @@ context("Subnets", () => { beforeEach(() => { cy.login(); cy.visit(generateMAASURL("/networks?by=fabric")); + cy.waitForPageToLoad(); cy.viewport("macbook-11"); }); @@ -38,9 +39,9 @@ context("Subnets", () => { cy.url().should("include", generateMAASURL("/networks?by=fabric")); }); - it("allows grouping by fabric and space", () => { + it.only("allows grouping by fabric and space", () => { cy.findByRole("grid", { name: "Subnets by Fabric" }).within(() => { - cy.findAllByRole("columnheader").first().should("have.text", "VLAN"); + cy.get("tbody tr").first().should("include.text", "fabric"); }); cy.findByRole("combobox", { name: /group by/i }).should( @@ -55,8 +56,10 @@ context("Subnets", () => { cy.findByRole("combobox", { name: /group by/i }).select("space"); + cy.waitForPageToLoad(); + cy.findByRole("grid", { name: "Subnets by Space" }).within(() => { - cy.findAllByRole("columnheader").first().should("have.text", "VLAN"); + cy.get("tbody tr").first().should("include.text", "space"); }); cy.url().should("include", generateMAASURL("/networks?by=space"));