Skip to content

Commit

Permalink
fix: adapt CI to diracx-charts changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Apr 11, 2024
1 parent d366033 commit e5331a9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ npm test
End-to-end tests are launched through `cypress` such as:

```
export CYPRESS_BASE_URL=<ip address used by diracx-charts>
npx cypress open
npx cypress open --config baseUrl=$DIRACX_URL
```

## Learn More
Expand Down
15 changes: 9 additions & 6 deletions test/e2e/login_out.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -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("[email protected]");
cy.get("#password").type("password");
Expand Down Expand Up @@ -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");
});
});

0 comments on commit e5331a9

Please sign in to comment.