diff --git a/.github/workflows/js-ci.yml b/.github/workflows/js-ci.yml index 7f6357ce87e..cf421cfe7d2 100644 --- a/.github/workflows/js-ci.yml +++ b/.github/workflows/js-ci.yml @@ -327,6 +327,15 @@ jobs: name: admin-ui-server-log-${{ matrix.container }}-${{ matrix.browser }} path: ~/server.log + - name: Upload Cypress videos + uses: actions/upload-artifact@v3 + if: github.repository != 'keycloak/keycloak-private' + with: + name: cypress-videos-${{ matrix.container }}-${{ matrix.browser }} + path: js/apps/admin-ui/cypress/videos + if-no-files-found: ignore + retention-days: 10 + check: name: Status Check - Keycloak JavaScript CI if: always() diff --git a/js/apps/admin-ui/cypress.config.js b/js/apps/admin-ui/cypress.config.js index f6acc07d55f..f8072426685 100644 --- a/js/apps/admin-ui/cypress.config.js +++ b/js/apps/admin-ui/cypress.config.js @@ -1,7 +1,11 @@ import { defineConfig } from "cypress"; import cypressSplit from "cypress-split"; +import fs from "node:fs"; + +const isCI = process.env.CI === "true"; export default defineConfig({ + video: isCI, projectId: "j4yhox", chromeWebSecurity: false, viewportWidth: 1360, @@ -19,7 +23,22 @@ export default defineConfig({ slowTestThreshold: 30000, specPattern: "cypress/e2e/**/*.{js,jsx,ts,tsx}", setupNodeEvents(on, config) { + on("after:spec", (spec, results) => { + if (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); + } + } + }); + cypressSplit(on, config); + return config; }, },