@@ -47,49 +47,33 @@ export async function waitForPageReady(
4747) : Promise < void > {
4848 const { timeout = WAIT_TIMEOUTS . TEST_READY } = options
4949
50- << < < < << HEAD
51- // Wait for fonts to be loaded
52- = === ===
5350 // Wait for fonts to be ready
54- >>> >>> > origin / leader
5551 await page . evaluate ( async ( ) => {
5652 await document . fonts . ready
5753 } )
5854
55+ // Wait for actual content to be present first (Fail-Fast check)
56+ await page . waitForSelector ( 'main, [data-testid="dashboard"], [role="main"]' , {
57+ state : 'visible' ,
58+ timeout,
59+ } )
60+
5961 // Wait for loading skeletons to disappear
60- << < < < << HEAD
62+ // We use hidden state to ensure they are either removed or invisible.
6163 // NOTE: We wrap this in a try-catch to prevent timeouts from failing the entire test.
62- // In some CI environments, dynamic content loading (like Spotify or Google Docs)
63- // or WebSocket connection states might cause skeletons to persist longer than expected.
64- // Proceeding allows visual regression tests to capture the state (even if loading)
65- // rather than failing with a timeout error.
64+ // If skeletons persist (e.g. infinite loading or bug), we want VRT to capture that state
65+ // rather than crashing with a generic TimeoutError.
6666 try {
6767 await page . waitForSelector ( '.MuiSkeleton-root' , {
68- state : 'detached ' ,
68+ state : 'hidden ' ,
6969 timeout,
7070 } )
7171 } catch ( error ) {
7272 console . warn (
73- `[waitForPageReady] Skeletons did not detach within ${ timeout } ms. Proceeding anyway .` ,
73+ `[waitForPageReady] Skeletons did not disappear within ${ timeout } ms. Proceeding to snapshot/test .` ,
7474 error
7575 )
7676 }
77- === === =
78- await page
79- . waitForSelector ( '.MuiSkeleton-root' , {
80- state : 'hidden' ,
81- timeout,
82- } )
83- . catch ( ( ) => {
84- // Ignore errors if skeletons are not found (already hidden/removed)
85- } )
86-
87- // Wait for actual content to be present
88- await page . waitForSelector ( 'main, [data-testid="dashboard"], [role="main"]' , {
89- state : 'visible' ,
90- timeout,
91- } )
92- >>> > >>> origin / leader
9377}
9478
9579/**
0 commit comments