]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: cypress failure after angular upgrade
authorNizamudeen A <nia@redhat.com>
Sun, 9 Feb 2025 16:12:59 +0000 (21:42 +0530)
committerNizamudeen A <nia@redhat.com>
Thu, 13 Mar 2025 04:47:18 +0000 (10:17 +0530)
after angular upgrade, the tests started failing with
An uncaught error was detected outside of a test:
     TypeError: The following error originated from your test code, not from Cypress.
Cannot read properties of undefined (reading 'value')

which seems to originate from the page-helper.po. So handling the
undefined value.

Example run: https://jenkins.ceph.com/job/ceph-dashboard-pull-requests/17541/consoleFull#204663575173a8703b-5adb-41c5-84a0-8cf4e065ba3d

Fixes: https://tracker.ceph.com/issues/68871
Signed-off-by: Nizamudeen A <nia@redhat.com>
src/pybind/mgr/dashboard/frontend/cypress/e2e/page-helper.po.ts

index 2e94179aa743369a4a6b1815663223c491f17b47..85e15be330e877d7505ff29acb99b4cd67733d80 100644 (file)
@@ -13,17 +13,19 @@ export abstract class PageHelper {
    */
   static restrictTo(page: string): Function {
     return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
-      const fn: Function = descriptor.value;
-      descriptor.value = function (...args: any) {
-        cy.location('hash').should((url) => {
-          expect(url).to.eq(
-            page,
-            `Method ${target.constructor.name}::${propertyKey} is supposed to be ` +
-              `run on path "${page}", but was run on URL "${url}"`
-          );
-        });
-        fn.apply(this, args);
-      };
+      if (descriptor) {
+        const fn: Function = descriptor.value;
+        descriptor.value = function (...args: any) {
+          cy.location('hash').should((url) => {
+            expect(url).to.eq(
+              page,
+              `Method ${target.constructor.name}::${propertyKey} is supposed to be ` +
+                `run on path "${page}", but was run on URL "${url}"`
+            );
+          });
+          fn.apply(this, args);
+        };
+      }
     };
   }