From: Nizamudeen A Date: Sun, 9 Feb 2025 16:12:59 +0000 (+0530) Subject: mgr/dashboard: cypress failure after angular upgrade X-Git-Tag: v20.3.0~378^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a80aa1a84a324296106d4de7f2cb9b3c52b7a134;p=ceph.git mgr/dashboard: cypress failure after angular upgrade 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 --- diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/page-helper.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/e2e/page-helper.po.ts index 2e94179aa7433..85e15be330e87 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/e2e/page-helper.po.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/page-helper.po.ts @@ -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); + }; + } }; }