Skip to content

Commit 6a200d5

Browse files
MamadukaDAreRodzluisherranz
authored
Try: Fix flaky router styles e2e tests (#72329)
* Try: Fix flaky router styles e2e tests * Add a hydration check before each test --------- Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: DAreRodz <darerodz@git.wordpress.org> Co-authored-by: luisherranz <luisherranz@git.wordpress.org>
1 parent 99a5118 commit 6a200d5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/e2e-tests/plugins/interactive-blocks/router-styles-wrapper/render.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ function () {
8484
<?php echo $content; ?>
8585
</div>
8686

87+
<!-- Flag to check whether hydration has occurred. -->
88+
<div
89+
data-testid="hydrated"
90+
data-wp-interactive="test/router-styles"
91+
data-wp-bind--hidden="state.undefined"
92+
hidden
93+
>
94+
Hydrated
95+
</div>
96+
8797
<!-- Text to check whether a navigation was client-side. -->
8898
<div
8999
data-testid="client-side navigation"

test/e2e/specs/interactivity/router-styles.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ test.describe( 'Router styles', () => {
5353

5454
test.beforeEach( async ( { page, interactivityUtils: utils } ) => {
5555
await page.goto( utils.getLink( 'none' ) );
56+
await expect( page.getByTestId( 'hydrated' ) ).toBeVisible();
5657
} );
5758

5859
test.afterAll( async ( { interactivityUtils: utils } ) => {
@@ -305,7 +306,7 @@ test.describe( 'Router styles', () => {
305306
const linkPattern = '**/router-styles-red/style-from-link.css*';
306307
await page.route( linkPattern, async ( route ) => {
307308
await route.abort( 'failed' );
308-
await page.unroute( linkPattern );
309+
await page.unrouteAll( { behavior: 'ignoreErrors' } );
309310
} );
310311

311312
// Navigate to the page with the Red block

0 commit comments

Comments
 (0)