@@ -50,25 +50,35 @@ export async function check(
50
50
51
51
test . describe ( 'Simple Page Router (no basePath, no i18n)' , ( ) => {
52
52
test . describe ( 'On-demand revalidate works correctly' , ( ) => {
53
- for ( const { label, prerendered, pagePath, expectedH1Content } of [
53
+ for ( const { label, prerendered, pagePath, revalidateApiBasePath , expectedH1Content } of [
54
54
{
55
- label : 'prerendered page with static path' ,
55
+ label : 'prerendered page with static path and awaited res.revalidate() ' ,
56
56
prerendered : true ,
57
57
pagePath : '/static/revalidate-manual' ,
58
+ revalidateApiBasePath : '/api/revalidate' ,
58
59
expectedH1Content : 'Show #71' ,
59
60
} ,
60
61
{
61
- label : 'prerendered page with dynamic path' ,
62
+ label : 'prerendered page with dynamic path and awaited res.revalidate() ' ,
62
63
prerendered : true ,
63
64
pagePath : '/products/prerendered' ,
65
+ revalidateApiBasePath : '/api/revalidate' ,
64
66
expectedH1Content : 'Product prerendered' ,
65
67
} ,
66
68
{
67
- label : 'not prerendered page with dynamic path' ,
69
+ label : 'not prerendered page with dynamic path and awaited res.revalidate() ' ,
68
70
prerendered : false ,
69
71
pagePath : '/products/not-prerendered' ,
72
+ revalidateApiBasePath : '/api/revalidate' ,
70
73
expectedH1Content : 'Product not-prerendered' ,
71
74
} ,
75
+ {
76
+ label : 'not prerendered page with dynamic path and not awaited res.revalidate()' ,
77
+ prerendered : false ,
78
+ pagePath : '/products/not-prerendered-and-not-awaited-revalidation' ,
79
+ revalidateApiBasePath : '/api/revalidate-no-await' ,
80
+ expectedH1Content : 'Product not-prerendered-and-not-awaited-revalidation' ,
81
+ } ,
72
82
] ) {
73
83
test ( label , async ( { page, pollUntilHeadersMatch, pageRouter } ) => {
74
84
// in case there is retry or some other test did hit that path before
@@ -192,7 +202,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
192
202
expect ( data2 ?. pageProps ?. time ) . toBe ( date1 )
193
203
194
204
const revalidate = await page . goto (
195
- new URL ( `/api/revalidate ?path=${ pagePath } ` , pageRouter . url ) . href ,
205
+ new URL ( `${ revalidateApiBasePath } ?path=${ pagePath } ` , pageRouter . url ) . href ,
196
206
)
197
207
expect ( revalidate ?. status ( ) ) . toBe ( 200 )
198
208
@@ -411,25 +421,35 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
411
421
412
422
test . describe ( 'Page Router with basePath and i18n' , ( ) => {
413
423
test . describe ( 'Static revalidate works correctly' , ( ) => {
414
- for ( const { label, prerendered, pagePath, expectedH1Content } of [
424
+ for ( const { label, prerendered, pagePath, revalidateApiBasePath , expectedH1Content } of [
415
425
{
416
- label : 'prerendered page with static path' ,
426
+ label : 'prerendered page with static path and awaited res.revalidate() ' ,
417
427
prerendered : true ,
418
428
pagePath : '/static/revalidate-manual' ,
429
+ revalidateApiBasePath : '/api/revalidate' ,
419
430
expectedH1Content : 'Show #71' ,
420
431
} ,
421
432
{
422
- label : 'prerendered page with dynamic path' ,
433
+ label : 'prerendered page with dynamic path and awaited res.revalidate() ' ,
423
434
prerendered : true ,
424
435
pagePath : '/products/prerendered' ,
436
+ revalidateApiBasePath : '/api/revalidate' ,
425
437
expectedH1Content : 'Product prerendered' ,
426
438
} ,
427
439
{
428
- label : 'not prerendered page with dynamic path' ,
440
+ label : 'not prerendered page with dynamic path and awaited res.revalidate() ' ,
429
441
prerendered : false ,
430
442
pagePath : '/products/not-prerendered' ,
443
+ revalidateApiBasePath : '/api/revalidate' ,
431
444
expectedH1Content : 'Product not-prerendered' ,
432
445
} ,
446
+ {
447
+ label : 'not prerendered page with dynamic path and not awaited res.revalidate()' ,
448
+ prerendered : false ,
449
+ pagePath : '/products/not-prerendered-and-not-awaited-revalidation' ,
450
+ revalidateApiBasePath : '/api/revalidate-no-await' ,
451
+ expectedH1Content : 'Product not-prerendered-and-not-awaited-revalidation' ,
452
+ } ,
433
453
] ) {
434
454
test . describe ( label , ( ) => {
435
455
test ( `default locale` , async ( { page, pollUntilHeadersMatch, pageRouterBasePathI18n } ) => {
@@ -622,7 +642,10 @@ test.describe('Page Router with basePath and i18n', () => {
622
642
623
643
// revalidate implicit locale path
624
644
const revalidateImplicit = await page . goto (
625
- new URL ( `/base/path/api/revalidate?path=${ pagePath } ` , pageRouterBasePathI18n . url ) . href ,
645
+ new URL (
646
+ `/base/path${ revalidateApiBasePath } ?path=${ pagePath } ` ,
647
+ pageRouterBasePathI18n . url ,
648
+ ) . href ,
626
649
)
627
650
expect ( revalidateImplicit ?. status ( ) ) . toBe ( 200 )
628
651
@@ -713,8 +736,10 @@ test.describe('Page Router with basePath and i18n', () => {
713
736
714
737
// revalidate implicit locale path
715
738
const revalidateExplicit = await page . goto (
716
- new URL ( `/base/path/api/revalidate?path=/en${ pagePath } ` , pageRouterBasePathI18n . url )
717
- . href ,
739
+ new URL (
740
+ `/base/path${ revalidateApiBasePath } ?path=/en${ pagePath } ` ,
741
+ pageRouterBasePathI18n . url ,
742
+ ) . href ,
718
743
)
719
744
expect ( revalidateExplicit ?. status ( ) ) . toBe ( 200 )
720
745
@@ -934,8 +959,10 @@ test.describe('Page Router with basePath and i18n', () => {
934
959
expect ( data2 ?. pageProps ?. time ) . toBe ( date1 )
935
960
936
961
const revalidate = await page . goto (
937
- new URL ( `/base/path/api/revalidate?path=/de${ pagePath } ` , pageRouterBasePathI18n . url )
938
- . href ,
962
+ new URL (
963
+ `/base/path${ revalidateApiBasePath } ?path=/de${ pagePath } ` ,
964
+ pageRouterBasePathI18n . url ,
965
+ ) . href ,
939
966
)
940
967
expect ( revalidate ?. status ( ) ) . toBe ( 200 )
941
968
0 commit comments