Skip to content

Commit

Permalink
test: fix cypress #5137
Browse files Browse the repository at this point in the history
- update navigation selector
  • Loading branch information
petermakowski committed Dec 4, 2023
1 parent 102e49d commit b3cd2ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
28 changes: 9 additions & 19 deletions cypress/e2e/with-users/base/navigation.spec.ts
Original file line number Diff line number Diff line change
@@ -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")
);
};
Expand Down Expand Up @@ -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");
});
});

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/with-users/machines/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const MACHINE_ACTIONS_GROUPS = [
],
},
{
label: "Power cycle",
label: "Power",
actions: ["Power on", "Power off", "Soft power off"],
},
{
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down

0 comments on commit b3cd2ca

Please sign in to comment.