Skip to content

Commit

Permalink
test: Use a different way to update window object in tests (#2095)
Browse files Browse the repository at this point in the history
* test: Use different way to update window object

* test: Remove unnecessary window chrome mock
  • Loading branch information
gkarat authored Nov 24, 2023
1 parent f4a9b0d commit aee1350
Show file tree
Hide file tree
Showing 18 changed files with 278 additions and 367 deletions.
31 changes: 12 additions & 19 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,20 @@ Cypress.Commands.add('mountWithContext', (Component, options = {}, props) => {

// one of the fec dependencies talks to window.insights.chrome
Cypress.Commands.add(
'mockWindowChrome',
'mockWindowInsights',
({ userPermissions } = { userPermissions: ['*:*:*'] }) => {
cy.window().then(
// one of the fec dependencies talks to window.insights.chrome
(window) => {
window.chrome = {
getApp: () => 'inventory',
};
window.insights = {
chrome: {
getUserPermissions: () => userPermissions,
auth: {
getUser: () => {
return Promise.resolve({});
},
},
getApp: () => 'inventory',
window.insights = {
...window.insights,
chrome: {
getUserPermissions: () => userPermissions,
auth: {
getUser: () => {
return Promise.resolve({});
},
};
}
);
},
getApp: () => 'inventory',
},
};
}
);

Expand Down
Loading

0 comments on commit aee1350

Please sign in to comment.