Skip to content

Commit

Permalink
Fix flaky test on-window, remove duplicate expect on-document (#58181)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Jan 24, 2024
1 parent 01fb505 commit 6e71cc2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion test/e2e/specs/interactivity/directive-on-document.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ test.describe( 'data-wp-on-document', () => {
// Add the element back.
await visibilityButton.click();
await expect( counter ).toHaveText( '1' );
await expect( counter ).toHaveText( '1' );

// Wait until the effects run again.
await expect( isEventAttached ).toHaveText( 'yes' );
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/specs/interactivity/directive-on-window.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,27 @@ test.describe( 'data-wp-on-window', () => {
page,
} ) => {
const counter = page.getByTestId( 'counter' );
const isEventAttached = page.getByTestId( 'isEventAttached' );
const visibilityButton = page.getByTestId( 'visibility' );

await expect( counter ).toHaveText( '0' );
await expect( isEventAttached ).toHaveText( 'yes' );
await page.setViewportSize( { width: 600, height: 600 } );
await expect( counter ).toHaveText( '1' );

// Remove the element.
await visibilityButton.click();

// This resize should not increase the counter.
await page.setViewportSize( { width: 300, height: 600 } );

// Add the element back.
await visibilityButton.click();
await expect( counter ).toHaveText( '1' );

// Wait until the effects run again.
await expect( isEventAttached ).toHaveText( 'yes' );

await page.setViewportSize( { width: 200, height: 600 } );
await expect( counter ).toHaveText( '2' );
} );
Expand Down

0 comments on commit 6e71cc2

Please sign in to comment.