@@ -266,12 +266,35 @@ function defineTransitionAwaitTests(getBase: () => string) {
266266 const page = await context . newPage ( ) ;
267267 const errors : Array < string > = [ ] ;
268268 page . on ( 'pageerror' , ( error ) => errors . push ( error . message ) ) ;
269+ let releaseResponse ! : ( ) => void ;
270+ const responseGate = new Promise < void > ( ( resolve ) => {
271+ releaseResponse = resolve ;
272+ } ) ;
269273 try {
270274 const url = `${ getBase ( ) } /transition-await` ;
271275 await page . goto ( url ) ;
272276 await page . waitForSelector ( '#app[data-hydrated="true"]' ) ;
277+ await page . route ( '**/transition-await?ping' , async ( route ) => {
278+ await responseGate ;
279+ await route . continue ( ) ;
280+ } ) ;
273281 const button = page . getByTestId ( 'async-contract' ) ;
274- await button . click ( ) ;
282+ // Cold dev compilation can exceed expect.poll's one-second default on
283+ // Windows. Wait for the server before checking the Action continuation.
284+ const [ response ] = await Promise . all ( [
285+ page . waitForResponse (
286+ ( response ) =>
287+ new URL ( response . url ( ) ) . pathname === '/transition-await' &&
288+ response . request ( ) . method ( ) === 'POST' ,
289+ ) ,
290+ ( async ( ) => {
291+ await button . click ( ) ;
292+ await expect . poll ( ( ) => button . textContent ( ) ) . toBe ( 'pending' ) ;
293+ await expect . poll ( ( ) => page . getByTestId ( 'optimistic' ) . textContent ( ) ) . toBe ( 'saving' ) ;
294+ releaseResponse ( ) ;
295+ } ) ( ) ,
296+ ] ) ;
297+ expect ( response . status ( ) ) . toBe ( 200 ) ;
275298 await expect . poll ( ( ) => page . getByTestId ( 'data-ready' ) . textContent ( ) ) . toBe ( 'ready' ) ;
276299 expect ( await button . textContent ( ) ) . toBe ( 'pending' ) ;
277300 expect ( await page . getByTestId ( 'optimistic' ) . textContent ( ) ) . toBe ( 'saving' ) ;
@@ -295,6 +318,7 @@ function defineTransitionAwaitTests(getBase: () => string) {
295318 await expect . poll ( ( ) => button . textContent ( ) ) . toBe ( 'run' ) ;
296319 expect ( errors ) . toEqual ( [ ] ) ;
297320 } finally {
321+ releaseResponse ( ) ;
298322 await context . close ( ) ;
299323 }
300324 } ) ;
0 commit comments