@@ -272,3 +272,42 @@ test('can require CJS module that is not bundled', async ({ simple }) => {
272
272
expect ( parsedBody . notBundledCJSModule . isBundled ) . toEqual ( false )
273
273
expect ( parsedBody . bundledCJSModule . isBundled ) . toEqual ( true )
274
274
} )
275
+
276
+ test ( 'next/after callback is executed and finishes' , async ( { page, simple } ) => {
277
+ test . skip ( ! nextVersionSatisfies ( '>=15.0.0' ) , 'This test is only for Next.js 15+' )
278
+
279
+ // trigger initial request to check page which might be stale and allow regenerating in background
280
+ await page . goto ( `${ simple . url } /after/check` )
281
+
282
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) )
283
+
284
+ // after it was possibly regenerated we can start checking actual content of the page
285
+ await page . goto ( `${ simple . url } /after/check` )
286
+ const pageInfoLocator1 = await page . locator ( '#page-info' )
287
+ const pageInfo1 = JSON . parse ( ( await pageInfoLocator1 . textContent ( ) ) ?? '{}' )
288
+
289
+ expect ( typeof pageInfo1 ?. timestamp , 'Check page should have timestamp' ) . toBe ( 'number' )
290
+
291
+ await page . goto ( `${ simple . url } /after/check` )
292
+ const pageInfoLocator2 = await page . locator ( '#page-info' )
293
+ const pageInfo2 = JSON . parse ( ( await pageInfoLocator2 . textContent ( ) ) ?? '{}' )
294
+
295
+ expect ( typeof pageInfo2 ?. timestamp , 'Check page should have timestamp' ) . toBe ( 'number' )
296
+
297
+ expect ( pageInfo2 . timestamp , 'Check page should be cached' ) . toBe ( pageInfo1 . timestamp )
298
+
299
+ await page . goto ( `${ simple . url } /after/trigger` )
300
+
301
+ // wait for next/after to trigger revalidation of check page
302
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) )
303
+
304
+ await page . goto ( `${ simple . url } /after/check` )
305
+ const pageInfoLocator3 = await page . locator ( '#page-info' )
306
+ const pageInfo3 = JSON . parse ( ( await pageInfoLocator3 . textContent ( ) ) ?? '{}' )
307
+
308
+ expect ( typeof pageInfo3 ?. timestamp , 'Check page should have timestamp' ) . toBe ( 'number' )
309
+ expect (
310
+ pageInfo3 . timestamp ,
311
+ 'Check page should be invalidated with newer timestamp' ,
312
+ ) . toBeGreaterThan ( pageInfo1 . timestamp )
313
+ } )
0 commit comments