From 0aa904dde96335a6abac64150a53a5e8bbc0ef39 Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Tue, 17 Oct 2023 12:37:28 +0100 Subject: [PATCH 01/12] add timeout and check if button is emabled --- cypress/support/commands.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 8a891205ed..fecc88285d 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -44,7 +44,9 @@ 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.get("button[type='submit']", { timeout: LONG_TIMEOUT }) + .should("be.enabled") + .click(); cy.get(`[data-testid='message']:contains(${hostname} added successfully.)`, { timeout: LONG_TIMEOUT, }); From ed50207b2f258901a8ce6401c19d76657e254bff Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Tue, 17 Oct 2023 12:46:58 +0100 Subject: [PATCH 02/12] TEMPORARY: get cypress tests running --- .github/workflows/cypress.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 07c855e952..2611061ee0 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -2,8 +2,7 @@ name: Cypress on: push: branches: - - main - - "3.*" + - "*" jobs: cypress: name: Cypress From 2f70fa16d58dbabb6a49497283ea9a924d396f2f Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Tue, 24 Oct 2023 09:37:26 +0100 Subject: [PATCH 03/12] undo button enable check --- cypress/support/commands.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index fecc88285d..2f8a8d3095 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -44,9 +44,6 @@ 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']", { timeout: LONG_TIMEOUT }) - .should("be.enabled") - .click(); cy.get(`[data-testid='message']:contains(${hostname} added successfully.)`, { timeout: LONG_TIMEOUT, }); From 9f9321503e7ddbe2b2c9acc9545ae6024374f6d3 Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Tue, 24 Oct 2023 09:37:51 +0100 Subject: [PATCH 04/12] add check to make sure image is synced fully --- .github/workflows/cypress.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 2611061ee0..6f591ade5b 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -30,7 +30,10 @@ jobs: spec: "cypress/e2e/no-users/**/*.spec.ts" wait-on: "${{env.MAAS_URL}}/MAAS/r/machines" - name: Create MAAS admin - run: sudo maas createadmin --username=admin --password=test --email=fake@example.org + run: | + sudo maas createadmin --username=admin --password=test --email=fake@example.org + maas login admin http://127.0.0.1:5240/MAAS/api/2.0/ < $(maas apikey --username=admin) + while [ $(maas image boot-resources is-importing | cat) == "true" ]; do sleep 10; done; echo "syncing finished" - name: Create MAAS non-admin user run: | export API_KEY=`sudo maas apikey --username=admin` From b5cfe334d6ab9e14554568ca9b16096a00bc9170 Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Tue, 24 Oct 2023 09:54:58 +0100 Subject: [PATCH 05/12] remove duplicate commands --- .github/workflows/cypress.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 6f591ade5b..390e726087 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -30,14 +30,12 @@ jobs: spec: "cypress/e2e/no-users/**/*.spec.ts" wait-on: "${{env.MAAS_URL}}/MAAS/r/machines" - name: Create MAAS admin - run: | - sudo maas createadmin --username=admin --password=test --email=fake@example.org - maas login admin http://127.0.0.1:5240/MAAS/api/2.0/ < $(maas apikey --username=admin) - while [ $(maas image boot-resources is-importing | cat) == "true" ]; do sleep 10; done; echo "syncing finished" + run: sudo maas createadmin --username=admin --password=test --email=fake@example.org - name: Create MAAS non-admin user run: | export API_KEY=`sudo maas apikey --username=admin` maas login admin http://localhost:5240/MAAS $API_KEY + while [ $(maas admin boot-resources is-importing | cat) == "true" ]; do sleep 10; done; echo "syncing finished" maas admin users create username=user password=test email=fake-user@example.org is_superuser=0 - name: Run Cypress tests with a user uses: cypress-io/github-action@v4 From 9f2ae19ca5655a648d0ee2b45ae6632b7b265a69 Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Tue, 24 Oct 2023 12:56:50 +0100 Subject: [PATCH 06/12] update footer tests --- cypress/e2e/with-users/base/footer.spec.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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"); }); }); From 907a1c4d7d1c11d77d7ae05a8c14bff60e200d01 Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Tue, 24 Oct 2023 15:02:34 +0100 Subject: [PATCH 07/12] add submit button click --- cypress/support/commands.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 2f8a8d3095..042f84e6fa 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -44,6 +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.findByRole("button", { name: /save machine/i }).click(); cy.get(`[data-testid='message']:contains(${hostname} added successfully.)`, { timeout: LONG_TIMEOUT, }); From dd33e8d5ab16dc1e4d2c41f8eab327c7ac3b85a7 Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Tue, 24 Oct 2023 15:37:08 +0100 Subject: [PATCH 08/12] run cypress tests on main and 3.x --- .github/workflows/cypress.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 390e726087..11f0873b90 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -2,7 +2,8 @@ name: Cypress on: push: branches: - - "*" + - main + - "3.*" jobs: cypress: name: Cypress From 83992b901f6718a8df65998a4248cd7343144334 Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Wed, 25 Oct 2023 11:16:30 +0100 Subject: [PATCH 09/12] separate image syncing script --- .github/workflows/cypress.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 11f0873b90..83caa27be5 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -36,8 +36,9 @@ jobs: run: | export API_KEY=`sudo maas apikey --username=admin` maas login admin http://localhost:5240/MAAS $API_KEY - while [ $(maas admin boot-resources is-importing | cat) == "true" ]; do sleep 10; done; echo "syncing finished" maas admin users create username=user password=test email=fake-user@example.org is_superuser=0 + - name: Ensure that images have successfully synced + 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: From ddebb85b832ff3582bc913c7374360de502180b1 Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Wed, 25 Oct 2023 11:17:03 +0100 Subject: [PATCH 10/12] testrun cypress on push --- .github/workflows/cypress.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 83caa27be5..437bc25107 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -2,8 +2,7 @@ name: Cypress on: push: branches: - - main - - "3.*" + - "*" jobs: cypress: name: Cypress From 7bd2accaa6b416e4efdd6f9fd39233875ae611aa Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Wed, 25 Oct 2023 11:33:03 +0100 Subject: [PATCH 11/12] run cypress on push to main --- .github/workflows/cypress.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 437bc25107..83caa27be5 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -2,7 +2,8 @@ name: Cypress on: push: branches: - - "*" + - main + - "3.*" jobs: cypress: name: Cypress From 51f19fd3e2274df50e1692893437b914ee89c432 Mon Sep 17 00:00:00 2001 From: Jones Ogolo Date: Wed, 25 Oct 2023 11:34:05 +0100 Subject: [PATCH 12/12] rename process --- .github/workflows/cypress.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 83caa27be5..677f8b9b57 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -37,7 +37,7 @@ 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: Ensure that images have successfully synced + - 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