Skip to content

Commit a80aa1a

Browse files
committed
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 <[email protected]>
1 parent 09d3e67 commit a80aa1a

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/pybind/mgr/dashboard/frontend/cypress/e2e/page-helper.po.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ export abstract class PageHelper {
1313
*/
1414
static restrictTo(page: string): Function {
1515
return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
16-
const fn: Function = descriptor.value;
17-
descriptor.value = function (...args: any) {
18-
cy.location('hash').should((url) => {
19-
expect(url).to.eq(
20-
page,
21-
`Method ${target.constructor.name}::${propertyKey} is supposed to be ` +
22-
`run on path "${page}", but was run on URL "${url}"`
23-
);
24-
});
25-
fn.apply(this, args);
26-
};
16+
if (descriptor) {
17+
const fn: Function = descriptor.value;
18+
descriptor.value = function (...args: any) {
19+
cy.location('hash').should((url) => {
20+
expect(url).to.eq(
21+
page,
22+
`Method ${target.constructor.name}::${propertyKey} is supposed to be ` +
23+
`run on path "${page}", but was run on URL "${url}"`
24+
);
25+
});
26+
fn.apply(this, args);
27+
};
28+
}
2729
};
2830
}
2931

0 commit comments

Comments
 (0)