]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: save video only on failure
authorNizamudeen A <nia@redhat.com>
Fri, 7 Mar 2025 15:24:36 +0000 (20:54 +0530)
committerNizamudeen A <nia@redhat.com>
Thu, 13 Mar 2025 04:47:18 +0000 (10:17 +0530)
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 <nia@redhat.com>
src/pybind/mgr/dashboard/frontend/cypress.config.ts

index fa334988305b6448683810b39a1debbbaa8c4e37..63b236078c3c32608b66a61e1b204c80055b906d 100644 (file)
@@ -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/',