Skip to content

Commit

Permalink
test: Mock window process in cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel.carrera committed Sep 12, 2024
1 parent 0f9ad6d commit 04cbf82
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cypress/component/Modal.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,16 @@ context(`given the [Components/Popups/Modal, Without close icon] story is render

context(`given the [Components/Popups/Modal, Custom focus] story is rendered`, () => {
beforeEach(() => {
cy.window().then(win => {
// @ts-ignore mocking window process
win.process = {
env: {
NODE_ENV: 'development',
},
};
});

cy.mount(<CustomFocus />);
cy.wait(150);
});

context('when button is focused', () => {
Expand All @@ -467,7 +475,9 @@ context(`given the [Components/Popups/Modal, Custom focus] story is rendered`, (

context('when the target button is clicked', () => {
beforeEach(() => {
cy.findByRole('button', {name: 'Acknowledge License'}).click();
cy.findByRole('button', {name: 'Acknowledge License'}).should('exist');
cy.findByRole('button', {name: 'Acknowledge License'}).focus();
cy.focused().click();
});

it('should open the modal', () => {
Expand Down

0 comments on commit 04cbf82

Please sign in to comment.