-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3477: feat: add target for cypress e2e tests into BUCK r=johnrwatson a=johnrwatson This PR adds a new toolchain into our BUCK build system to allow us to execute Cypress end to end tests via BUCK directly. In a follow up PR, the test will then be executed in CI. The added target is runnable and buildable, depending on how you would like to execute it. You can explicitly invoke as follows: `buck2 run app/web:e2e-test -- --tests 'cypress/e2e/**' --web-endpoint http://localhost:8080` This will run all our e2e tests against your local stack. These values are the defaults and can be excluded entirely on invocation if you desire, i.e. `buck2 run app/web:e2e-test` When executed, the target will check a few things before executing, these are listed below: - The stack is responsive on the given `--web-endpoint` within 60s - Cypress installation is valid - You are on an supported OS / Architecture During execution, it will then output the log contents and videos from cypress into the BUCK out path, which is usually something in the form of: `si/buck-out/v2/gen/root/<uuid>/app/web/__e2e-test__/<content here>` **Variables** Some variables are required to allow these tests to execute successfully and each test has slightly differing requirements. In the header of each of the cypress typescript test files you will see a block like follows: ``` const AUTH0_USERNAME = Cypress.env('VITE_AUTH0_USERNAME') || import.meta.env.VITE_AUTH0_USERNAME; const AUTH0_PASSWORD = Cypress.env('VITE_AUTH0_PASSWORD') || import.meta.env.VITE_AUTH0_PASSWORD; const AUTH_API_URL = Cypress.env('VITE_AUTH_API_URL') || import.meta.env.VITE_AUTH_API_URL; const SI_WORKSPACE_ID = Cypress.env('VITE_SI_WORKSPACE_ID') || import.meta.env.VITE_SI_WORKSPACE_ID; ``` This basically means, either have the variables in your local shell environment or within the .env files for vite, i.e. `.env.local` usually. I've included some psuedocode in `app/web/cypress/support/commands.ts` as to how we might refactor this to centralise the variables in one place, but I got into a bit of a tizzy with cypress coinage so I may have to come back to this in a follow up PR to implement the new test into CI. Co-authored-by: John Watson <[email protected]>
- Loading branch information
Showing
21 changed files
with
562 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
Cypress._.times(import.meta.env.VITE_SI_CYPRESS_MULTIPLIER ? import.meta.env.VITE_SI_CYPRESS_MULTIPLIER : 1, () => { | ||
const SI_CYPRESS_MULTIPLIER = Cypress.env('VITE_SI_CYPRESS_MULTIPLIER') || import.meta.env.VITE_SI_CYPRESS_MULTIPLIER || 1; | ||
const AUTH0_USERNAME = Cypress.env('VITE_AUTH0_USERNAME') || import.meta.env.VITE_AUTH0_USERNAME; | ||
const AUTH0_PASSWORD = Cypress.env('VITE_AUTH0_PASSWORD') || import.meta.env.VITE_AUTH0_PASSWORD; | ||
const AUTH_PORTAL_URL = Cypress.env('VITE_AUTH_PORTAL_URL') || import.meta.env.VITE_AUTH_PORTAL_URL; | ||
const UUID = Cypress.env('VITE_UUID') || import.meta.env.VITE_UUID || "local"; | ||
|
||
Cypress._.times(SI_CYPRESS_MULTIPLIER, () => { | ||
describe("logout", () => { | ||
beforeEach(() => { | ||
cy.visit("/"); | ||
cy.loginToAuth0(import.meta.env.VITE_AUTH0_USERNAME, import.meta.env.VITE_AUTH0_PASSWORD); | ||
cy.loginToAuth0(AUTH0_USERNAME, AUTH0_PASSWORD); | ||
}); | ||
|
||
it("log_out", () => { | ||
cy.visit("/"); | ||
cy.sendPosthogEvent(Cypress.currentTest.titlePath.join("/"), "test_uuid", import.meta.env.VITE_UUID ? import.meta.env.VITE_UUID: "local"); | ||
cy.contains('Create change set', { timeout: 10000 }).should('be.visible').click(); | ||
cy.sendPosthogEvent(Cypress.currentTest.titlePath.join("/"), "test_uuid", UUID); | ||
cy.contains('Create change set', { timeout: 10000 }).should('be.visible'); | ||
cy.get('.modal-close-button').should('exist').click(); | ||
cy.get('[aria-label="Profile"]').should('exist').click(); | ||
cy.get('#dropdown-menu-item-1').should('exist').should('be.visible').click({ force: true }); | ||
|
||
// There is a bug currently where you log out of the product & it just logs you out to the dashboard page | ||
// of the UI in auth portal | ||
cy.url().should("contain", import.meta.env.VITE_AUTH_PORTAL_URL + '/dashboard'); | ||
|
||
cy.url().should("contain", AUTH_PORTAL_URL + '/dashboard'); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.