Skip to content

Commit

Permalink
test: update cypres test selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
petermakowski committed Dec 12, 2023
1 parent e53d51d commit d4be3f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 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
9 changes: 6 additions & 3 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 @@ -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", () => {

Check failure on line 42 in cypress/e2e/with-users/subnets/subnets.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

it.only not permitted
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 d4be3f2

Please sign in to comment.