Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adapt CI to diracx-charts changes #115

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
});
});