diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 07c855e952..677f8b9b57 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -37,6 +37,8 @@ jobs: export API_KEY=`sudo maas apikey --username=admin` maas login admin http://localhost:5240/MAAS $API_KEY maas admin users create username=user password=test email=fake-user@example.org is_superuser=0 + - name: Wait for MAAS boot resources + run: while [ $(maas admin boot-resources is-importing | cat) == "true" ]; do sleep 10; done; echo "syncing finished" - name: Run Cypress tests with a user uses: cypress-io/github-action@v4 with: diff --git a/cypress/e2e/with-users/base/footer.spec.ts b/cypress/e2e/with-users/base/footer.spec.ts index eb9105bdd3..88cd4bf157 100644 --- a/cypress/e2e/with-users/base/footer.spec.ts +++ b/cypress/e2e/with-users/base/footer.spec.ts @@ -14,17 +14,22 @@ context("Footer", () => { }); it("navigates to the local documentation", () => { - cy.get(".p-footer__link:contains(Local documentation)").click(); - cy.location("pathname").should("eq", "/MAAS/docs/"); + cy.findByRole("link", { name: /local documentation/i }) + .should("have.attr", "href") + .and("include", "/MAAS/docs/"); }); it("has a link to legal", () => { - cy.get(".p-footer__link:contains(Legal information)") + cy.findByRole("link", { + name: /legal information/i, + }) .should("have.attr", "href") .and("include", "https://www.ubuntu.com/legal"); }); it("displays the feedback link", () => { - cy.get(".p-footer__nav button:contains(Give feedback)").should("exist"); + cy.findByRole("button", { + name: /give feedback/i, + }).should("exist"); }); }); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 8a891205ed..042f84e6fa 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -44,7 +44,7 @@ Cypress.Commands.add("addMachine", (hostname = generateName()) => { cy.get("input[name='hostname']").type(hostname); cy.get("input[name='pxe_mac']").type(generateMac()); cy.get("select[name='power_type']").select("manual").blur(); - cy.get("button[type='submit']").click(); + cy.findByRole("button", { name: /save machine/i }).click(); cy.get(`[data-testid='message']:contains(${hostname} added successfully.)`, { timeout: LONG_TIMEOUT, });