From b3cd2cac614b92ca300437bb6b8fe312ae9547e6 Mon Sep 17 00:00:00 2001 From: Peter Makowski Date: Mon, 4 Dec 2023 15:50:51 +0100 Subject: [PATCH] test: fix cypress #5137 - update navigation selector --- .../e2e/with-users/base/navigation.spec.ts | 28 ++++++------------- .../e2e/with-users/machines/actions.spec.ts | 2 +- cypress/support/commands.ts | 2 +- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/cypress/e2e/with-users/base/navigation.spec.ts b/cypress/e2e/with-users/base/navigation.spec.ts index 2624966cf8..e774397ca3 100644 --- a/cypress/e2e/with-users/base/navigation.spec.ts +++ b/cypress/e2e/with-users/base/navigation.spec.ts @@ -1,18 +1,14 @@ import { generateMAASURL } from "../../utils"; const expectCollapsedNavigation = () => { - cy.findByRole("navigation", { name: /main navigation/i }) - .invoke("width") - .should("equal", 64); - cy.findByRole("navigation", { name: /main navigation/i }).within(() => + cy.getMainNavigation().invoke("width").should("equal", 64); + cy.getMainNavigation().within(() => cy.findByRole("link", { name: /machines/i }).should("not.exist") ); }; const expectExpandedNavigation = () => { - cy.findByRole("navigation", { name: /main navigation/i }) - .invoke("width") - .should("equal", 240); - cy.findByRole("navigation", { name: /main navigation/i }).within(() => + cy.getMainNavigation().invoke("width").should("equal", 240); + cy.getMainNavigation().within(() => cy.findByRole("link", { name: /machines/i }).should("exist") ); }; @@ -72,20 +68,14 @@ context("Navigation - admin - collapse", () => { it("opens and closes the menu on mobile", () => { cy.viewport("iphone-8"); - const getMainNavigation = () => - cy.findByRole("navigation", { - name: /main navigation/i, - }); - getMainNavigation().should("not.be.visible"); - cy.findByRole("banner", { name: /navigation/i }).within(() => + cy.getMainNavigation().should("not.be.visible"); + cy.findByRole("banner", { name: "navigation" }).within(() => cy.findByRole("button", { name: "Menu" }).click() ); - getMainNavigation() + cy.getMainNavigation() .should("be.visible") - .within(() => - cy.findByRole("button", { name: /collapse main navigation/ }).click() - ); - getMainNavigation().should("not.be.visible"); + .within(() => cy.findByRole("button", { name: /close menu/i }).click()); + cy.getMainNavigation().should("not.be.visible"); }); }); diff --git a/cypress/e2e/with-users/machines/actions.spec.ts b/cypress/e2e/with-users/machines/actions.spec.ts index 24faa980ae..be36b456f3 100644 --- a/cypress/e2e/with-users/machines/actions.spec.ts +++ b/cypress/e2e/with-users/machines/actions.spec.ts @@ -13,7 +13,7 @@ const MACHINE_ACTIONS_GROUPS = [ ], }, { - label: "Power cycle", + label: "Power", actions: ["Power on", "Power off", "Soft power off"], }, { diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 042f84e6fa..f67a102502 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -155,7 +155,7 @@ Cypress.Commands.add("waitForTableToLoad", ({ name } = { name: undefined }) => { }); Cypress.Commands.add("getMainNavigation", () => { - return cy.findByRole("navigation", { name: /main navigation/i }); + return cy.findByRole("banner", { name: /main navigation/i }); }); Cypress.Commands.add("expandMainNavigation", () => {