From 197ab8f58601b8a165c865f243630709b902f416 Mon Sep 17 00:00:00 2001 From: Carlos Bravo Date: Wed, 24 Jan 2024 14:00:49 +0100 Subject: [PATCH] Fix flaky test on-window, remove duplicate expect on-document --- .../specs/interactivity/directive-on-document.spec.ts | 1 - .../specs/interactivity/directive-on-window.spec.ts | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/test/e2e/specs/interactivity/directive-on-document.spec.ts b/test/e2e/specs/interactivity/directive-on-document.spec.ts index 56ac7e91d3121..02a6ac99d45c4 100644 --- a/test/e2e/specs/interactivity/directive-on-document.spec.ts +++ b/test/e2e/specs/interactivity/directive-on-document.spec.ts @@ -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' ); diff --git a/test/e2e/specs/interactivity/directive-on-window.spec.ts b/test/e2e/specs/interactivity/directive-on-window.spec.ts index e1d59e09cd35f..dd3a02e0bb400 100644 --- a/test/e2e/specs/interactivity/directive-on-window.spec.ts +++ b/test/e2e/specs/interactivity/directive-on-window.spec.ts @@ -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' ); } );