Skip to content

Commit c273234

Browse files
committed
Test stylesheet loading fails
1 parent 5ee64ce commit c273234

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

+27
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,31 @@ test.describe( 'Router styles', () => {
258258
await expect( csn ).toBeVisible();
259259
await expect( orderChecker ).toHaveCSS( 'color', COLOR_GREEN );
260260
} );
261+
262+
test( 'should refresh the page when stylesheet loading fails', async ( {
263+
page,
264+
} ) => {
265+
const csn = page.getByTestId( 'client-side navigation' );
266+
const red = page.getByTestId( 'red-from-link' );
267+
const redBlock = page.getByTestId( 'red-block' );
268+
269+
await expect( red ).toHaveCSS( 'color', COLOR_WRAPPER );
270+
await expect( redBlock ).toBeHidden();
271+
272+
// Setup a route handler to make requests to the red stylesheet fail.
273+
// The route handler is removed after navigation to simulate a
274+
// temporary error.
275+
const linkPattern = '**/router-styles-red/style-from-link.css*';
276+
await page.route( linkPattern, async ( route ) => {
277+
await page.unroute( linkPattern );
278+
return route.abort( 'failed' );
279+
} );
280+
281+
// Navigate to the page with the Red block
282+
await page.getByTestId( 'link red' ).click();
283+
284+
await expect( csn ).toBeHidden();
285+
await expect( red ).toHaveCSS( 'color', COLOR_RED );
286+
await expect( redBlock ).toBeVisible();
287+
} );
261288
} );

0 commit comments

Comments
 (0)