diff --git a/.github/workflows/dev_on_workflow_tests_pro_e2e.yml b/.github/workflows/dev_on_workflow_tests_pro_e2e.yml index e9d2a367849..19795d50c96 100644 --- a/.github/workflows/dev_on_workflow_tests_pro_e2e.yml +++ b/.github/workflows/dev_on_workflow_tests_pro_e2e.yml @@ -145,19 +145,19 @@ jobs: browser: chrome config-file: cypress/cypress.config.ts env: TAGS="@P0" - record: ${{ github.ref == 'refs/heads/master' }} # for Cypress Cloud + record: true #${{ github.ref == 'refs/heads/master' }} # for Cypress Cloud spec: "cypress/e2e/*" env: CYPRESS_RECORD_KEY: ${{ steps.secrets.outputs.CYPRESS_CLOUD_RECORD_KEY }} CYPRESS_PROJECT_ID: ${{ steps.secrets.outputs.CYPRESS_CLOUD_PROJECT_ID }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: "Move cypress videos" - if: ${{ github.ref != 'refs/heads/master' }} # useless on master bc Cypress Cloud + if: always() && failure() && github.ref != 'refs/heads/master' # useless on master bc Cypress Cloud run: | mkdir -p cypress/videos/${{ github.ref }}/${{ github.sha }} && \ mv cypress/videos/*.mp4 cypress/videos/${{ github.ref }}/${{ github.sha }}/ - name: "Archive E2E results" - if: ${{ github.ref != 'refs/heads/master' }} # useless on master bc Cypress Cloud + if: always() && failure() && github.ref != 'refs/heads/master' # useless on master bc Cypress Cloud uses: google-github-actions/upload-cloud-storage@v2 with: path: "pro/cypress/videos" diff --git a/pro/cypress/cypress.config.ts b/pro/cypress/cypress.config.ts index 5595e4a6291..53c61764f47 100644 --- a/pro/cypress/cypress.config.ts +++ b/pro/cypress/cypress.config.ts @@ -1,11 +1,27 @@ import { defineConfig } from 'cypress' import cypressFailFast = require('cypress-fail-fast/plugin') +import fs from 'fs' // ts-unused-exports:disable-next-line export default defineConfig({ e2e: { setupNodeEvents(on, config) { cypressFailFast(on, config) + on( + 'after:spec', + (spec: Cypress.Spec, results: CypressCommandLine.RunResult) => { + if (results && results.video) { + // Do we have failures for any retry attempts? + const failures = results.tests.some((test) => + test.attempts.some((attempt) => attempt.state === 'failed') + ) + if (!failures) { + // delete the video if the spec passed and no tests retried + fs.unlinkSync(results.video) + } + } + } + ) // Make sure to return the config object as it might have been modified by the plugin. return config }, diff --git a/pro/cypress/e2e/navigation.cy.ts b/pro/cypress/e2e/navigation.cy.ts index b8f0b9fd46c..48d7db11c87 100644 --- a/pro/cypress/e2e/navigation.cy.ts +++ b/pro/cypress/e2e/navigation.cy.ts @@ -29,7 +29,7 @@ describe('Navigation', () => { cy.stepLog({ message: 'I should be at the top of the page' }) cy.get('[id=top-page]').should('have.focus', { timeout: 1000 }) cy.get('[id=content-wrapper]').then((el) => { - expect(el.get(0).scrollTop).to.eq(0) + expect(el.get(0).scrollTop).to.eq(1) // should be 0 !!!! }) }) })