From: Nizamudeen A Date: Fri, 7 Mar 2025 15:24:36 +0000 (+0530) Subject: mgr/dashboard: save video only on failure X-Git-Tag: v20.3.0~378^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ddd01a5f7f1fdd1d5af0fcaf1bc2b39c28de812f;p=ceph.git mgr/dashboard: save video only on failure as per https://docs.cypress.io/app/guides/screenshots-and-videos#Delete-videos-for-specs-without-failing-or-retried-tests. This would save storage as saving entire video is useless Fixes: https://tracker.ceph.com/issues/68871 Signed-off-by: Nizamudeen A --- diff --git a/src/pybind/mgr/dashboard/frontend/cypress.config.ts b/src/pybind/mgr/dashboard/frontend/cypress.config.ts index fa334988305b..63b236078c3c 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress.config.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress.config.ts @@ -1,4 +1,5 @@ import { defineConfig } from 'cypress'; +import fs from 'fs' export default defineConfig({ video: true, @@ -37,6 +38,21 @@ export default defineConfig({ // We've imported your old cypress plugins here. // You may want to clean this up later by importing these. setupNodeEvents(on, config) { + on( + 'after: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) + } + } + } + ) return require('./cypress/plugins/index.js')(on, config); }, baseUrl: 'https://localhost:4200/',