Skip to content

Commit

Permalink
test: update cypres test selectors (#5241)
Browse files Browse the repository at this point in the history
  • Loading branch information
petermakowski authored Dec 13, 2023
1 parent 8757243 commit 4f58969
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 7 additions & 3 deletions cypress/e2e/with-users/machines/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}...`),
Expand All @@ -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",
Expand Down Expand Up @@ -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");
Expand Down
7 changes: 5 additions & 2 deletions cypress/e2e/with-users/subnets/subnets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ context("Subnets", () => {
beforeEach(() => {
cy.login();
cy.visit(generateMAASURL("/networks?by=fabric"));
cy.waitForPageToLoad();
cy.viewport("macbook-11");
});

Expand Down Expand Up @@ -40,7 +41,7 @@ context("Subnets", () => {

it("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(
Expand All @@ -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"));
Expand Down

0 comments on commit 4f58969

Please sign in to comment.