From e5331a96ffebee7653844a0841ece325ed10fade Mon Sep 17 00:00:00 2001 From: aldbr Date: Thu, 11 Apr 2024 08:54:01 +0200 Subject: [PATCH] fix: adapt CI to diracx-charts changes --- .github/workflows/integration-test.yml | 6 +++--- README.md | 3 +-- test/e2e/login_out.cy.ts | 15 +++++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 55418ea3..3d13c02d 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -45,11 +45,11 @@ jobs: exit 1 fi - - name: Set BASE_URL - run: echo "BASE_URL=$(hostname)" >> $GITHUB_ENV + - name: Set DIRACX_URL + run: echo "DIRACX_URL=https://$(ifconfig | grep 'inet ' | awk '{ print $2 }' | grep -v '^127' | head -n 1 | cut -d '/' -f 1).nip.io:8000" >> $GITHUB_ENV - name: Start Cypress uses: cypress-io/github-action@v6 with: browser: chrome - env: BASE_URL=${{ env.BASE_URL }} + config: baseUrl=${{ env.DIRACX_URL }} diff --git a/README.md b/README.md index 7b08ad9d..e414c4e7 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,7 @@ npm test End-to-end tests are launched through `cypress` such as: ``` -export CYPRESS_BASE_URL= -npx cypress open +npx cypress open --config baseUrl=$DIRACX_URL ``` ## Learn More diff --git a/test/e2e/login_out.cy.ts b/test/e2e/login_out.cy.ts index 4f10799d..cab4a07b 100644 --- a/test/e2e/login_out.cy.ts +++ b/test/e2e/login_out.cy.ts @@ -2,14 +2,12 @@ // Make sure the user can login and logout describe("Login and Logout", () => { - const baseUrl = Cypress.env("BASE_URL"); - beforeEach(() => { // Cypress starts out with a blank slate for each test // so we must tell it to visit our website with the `cy.visit()` command. // Since we want to visit the same URL at the start of all our tests, // we include it in our beforeEach function so that it runs before each test - cy.visit(`https://${baseUrl}:8000`); + cy.visit("/"); }); it("login", () => { @@ -20,10 +18,15 @@ describe("Login and Logout", () => { // Continue with the default parameters cy.contains("Login through your Identity Provider").click(); - cy.url().should("include", `http://${baseUrl}:32002`); + // Extract name from baseUrl (remove http:// and port number) + const domain = Cypress.config() + .baseUrl?.replace("https://", "") + .split(":")[0]; + + cy.url().should("include", `http://${domain}:32002`); // The user is redirected to the OIDC provider login page and needs to login - cy.origin(`http://${baseUrl}:32002`, () => { + cy.origin(`http://${domain}:32002`, () => { // Find the username and password fields and fill them cy.get("#login").type("admin@example.com"); cy.get("#password").type("password"); @@ -55,7 +58,7 @@ describe("Login and Logout", () => { // The user tries to access the dashboard page without being connected // The user is redirected to the /auth page - cy.visit(`https://${baseUrl}:8000/`); + cy.visit("/"); cy.url().should("include", "/auth"); }); });