diff --git a/.github/workflows/e2e-validation.yml b/.github/workflows/e2e-validation.yml index 8a7db8fe71..39a6d022e7 100644 --- a/.github/workflows/e2e-validation.yml +++ b/.github/workflows/e2e-validation.yml @@ -1,21 +1,29 @@ name: Cypress E2E Tests on: - workflow_dispatch: # schedule: # - cron: '*/5 * * * *' # Runs every 5 minutes + workflow_call: inputs: environment: - description: 'Select environment' + type: string required: true - default: 'PROD' + description: "where to deploy" + default: "tools" + workflow_dispatch: + inputs: + environment: type: choice + required: true + description: "where to deploy" + default: "tools" options: - - PROD - - TOOLS + - tools + - production jobs: cypress-tests: + environment: ${{ inputs.environment }} runs-on: ubuntu-latest strategy: # don't fail the entire matrix on failure @@ -25,31 +33,13 @@ jobs: containers: [1] # , 2, 3, 4, 5, 6, 7, 8, 9, 10] - temp disabled mass steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: '18.18.2' - - name: Setup authentication for vite & other synthetic test variables - working-directory: app/web - run: | - sudo apt update - sudo apt install uuid -y - cp .env .env.local - echo "VITE_AUTH0_USERNAME=${{ secrets.VITE_AUTH0_USERNAME }}" >> .env.local - echo "VITE_AUTH0_PASSWORD=${{ secrets.VITE_AUTH0_PASSWORD }}" >> .env.local - echo "VITE_SI_CYPRESS_MULTIPLIER=${{ vars.VITE_SI_CYPRESS_MULTIPLIER }}" >> .env.local - if [ "${{ github.event.inputs.environment }}" == "PROD" ]; then - echo "VITE_SI_WORKSPACE_URL=${{ vars.VITE_PROD_SI_WORKSPACE_URL }}" >> .env.local - echo "VITE_SI_WORKSPACE_ID=${{ vars.VITE_PROD_SI_WORKSPACE_ID }}" >> .env.local - elif [ "${{ github.event.inputs.environment }}" == "TOOLS" ]; then - echo "VITE_SI_WORKSPACE_URL=${{ vars.VITE_TOOLS_SI_WORKSPACE_URL }}" >> .env.local - echo "VITE_SI_WORKSPACE_ID=${{ vars.VITE_TOOLS_SI_WORKSPACE_ID }}" >> .env.local - fi - echo "VITE_UUID=$(uuid)" >> .env.local - - name: Setup pnpm uses: pnpm/action-setup@v2 with: @@ -60,19 +50,28 @@ jobs: run: | pnpm i pnpm install cypress - + + - name: install uuid + run: | + sudo apt update + sudo apt install uuid -y + - uses: nick-fields/retry@v2 with: max_attempts: 3 timeout_minutes: 20 command: | - if [ "${{ github.event.inputs.environment }}" == "PROD" ]; then - export VITE_HOST_URL=${{ vars.VITE_PROD_SI_WORKSPACE_URL }} - elif [ "${{ github.event.inputs.environment }}" == "TOOLS" ]; then - export VITE_HOST_URL=${{ vars.VITE_TOOLS_SI_WORKSPACE_URL }} - fi cd app/web - npx cypress run --spec "cypress/e2e/**" + export VITE_AUTH0_USERNAME=${{ secrets.VITE_AUTH0_USERNAME }} + export VITE_AUTH0_PASSWORD=${{ secrets.VITE_AUTH0_PASSWORD }},\ + export VITE_SI_CYPRESS_MULTIPLIER=${{ vars.VITE_SI_CYPRESS_MULTIPLIER }} + export VITE_SI_WORKSPACE_URL=${{ vars.VITE_SI_WORKSPACE_URL }} + export VITE_HOST_URL=${{ vars.VITE_SI_WORKSPACE_URL }} + export VITE_SI_WORKSPACE_ID=${{ vars.VITE_SI_WORKSPACE_ID }} + export VITE_UUID=$(uuid) + export VITE_AUTH_API_URL=https://auth-api.systeminit.com + export VITE_AUTH_PORTAL_URL=https://auth.systeminit.com + npx cypress run --spec "cypress/e2e/authentication/**" - name: 'Upload Cypress Recordings to Github' uses: actions/upload-artifact@v4 @@ -85,4 +84,4 @@ jobs: - name: Send Slack Failure Webhook if: failure() run: | - curl -X POST -H 'Content-type: application/json' --data "{\"text\": \":si: Failed Cypress E2E Test for ${{ github.event.inputs.environment }}: \"}" ${{ secrets.SLACK_WEBHOOK_URL }} + curl -X POST -H 'Content-type: application/json' --data "{\"text\": \":si: Failed Cypress E2E Test for ${{ inputs.environment }}: \"}" ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/app/web/cypress/e2e/authentication/login.cy.ts b/app/web/cypress/e2e/authentication/login.cy.ts index c2640a095f..7aa19e6c7e 100644 --- a/app/web/cypress/e2e/authentication/login.cy.ts +++ b/app/web/cypress/e2e/authentication/login.cy.ts @@ -14,6 +14,10 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => { it("log_in", () => { cy.loginToAuth0(AUTH0_USERNAME, AUTH0_PASSWORD); cy.visit(AUTH_API_URL + '/workspaces/' + SI_WORKSPACE_ID + '/go'); + cy.on('uncaught:exception', (e) => { + console.log(e); + return false; + }); cy.sendPosthogEvent(Cypress.currentTest.titlePath.join("/"), "test_uuid", UUID); // check that you're on head i.e. that you were redirected correctly cy.wait(4000) diff --git a/app/web/cypress/e2e/authentication/logout.cy.ts b/app/web/cypress/e2e/authentication/logout.cy.ts index 2f5a18e8c8..2e6f42e9f6 100644 --- a/app/web/cypress/e2e/authentication/logout.cy.ts +++ b/app/web/cypress/e2e/authentication/logout.cy.ts @@ -1,6 +1,8 @@ const SI_CYPRESS_MULTIPLIER = Cypress.env('VITE_SI_CYPRESS_MULTIPLIER') || import.meta.env.VITE_SI_CYPRESS_MULTIPLIER || 1; +const SI_WORKSPACE_ID = Cypress.env('VITE_SI_WORKSPACE_ID') || import.meta.env.VITE_SI_WORKSPACE_ID; 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 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"; @@ -12,7 +14,11 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => { }); it("log_out", () => { - cy.visit("/"); + cy.visit(AUTH_API_URL + '/workspaces/' + SI_WORKSPACE_ID + '/go'); + cy.on('uncaught:exception', (e) => { + console.log(e); + return false; + }); 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(); diff --git a/app/web/cypress/support/auth-provider-commands/auth0.ts b/app/web/cypress/support/auth-provider-commands/auth0.ts index e78538b25f..a0d09a0c17 100644 --- a/app/web/cypress/support/auth-provider-commands/auth0.ts +++ b/app/web/cypress/support/auth-provider-commands/auth0.ts @@ -39,12 +39,12 @@ Cypress.Commands.add("loginToAuth0", (username: string, password: string) => { cy.visit(import.meta.env.VITE_AUTH_API_URL + '/workspaces/' + import.meta.env.VITE_SI_WORKSPACE_ID + '/go'); }, - { - validate: () => { - // Validate presence of access token in localStorage. - cy.window().its("localStorage").invoke("getItem", "si-auth").should("exist"); - }, - } + // { + // validate: () => { + // // Validate presence of access token in localStorage. + // cy.window().its("localStorage").invoke("getItem", "si-auth").should("exist"); + // }, + // } ); log.snapshot("after");