@@ -12,30 +12,51 @@ test.describe('page-router', () => {
12
12
await ctx ?. cleanup ?.( ! ! testInfo . errors . length )
13
13
} )
14
14
15
- // NOT working yet as blob storage upload ins not working with the CLI
15
+ // The cache purge does not work :(
16
16
test . skip ( 'Static revalidate works correctly' , async ( { page } ) => {
17
- const response1 = await page . goto ( new URL ( 'static/revalidate' , ctx . url ) . href )
17
+ const response1 = await page . goto ( new URL ( 'static/revalidate-manual ' , ctx . url ) . href )
18
18
const headers1 = response1 ?. headers ( ) || { }
19
19
expect ( response1 ?. status ( ) ) . toBe ( 200 )
20
20
expect ( headers1 [ 'x-nextjs-cache' ] ) . toBe ( 'HIT' )
21
- expect ( headers1 [ 'netlify-cdn-cache-control' ] ) . toBe ( 's-maxage=3, stale-while-revalidate' )
22
21
22
+ const date1 = await page . textContent ( '[data-testid="date-now"]' )
23
23
const h1 = await page . textContent ( 'h1' )
24
24
expect ( h1 ) . toBe ( 'Show #71' )
25
25
26
- const date1 = await page . textContent ( '[data-testid="date-now"]' )
27
-
28
- // wait to have a stale page
29
- page . waitForTimeout ( 3_000 )
30
-
31
- const response2 = await page . goto ( new URL ( 'static/revalidate' , ctx . url ) . href )
32
- const headers2 = response1 ?. headers ( ) || { }
26
+ const response2 = await page . goto ( new URL ( 'static/revalidate-manual' , ctx . url ) . href )
27
+ const headers2 = response2 ?. headers ( ) || { }
33
28
expect ( response2 ?. status ( ) ) . toBe ( 200 )
34
- expect ( response1 ?. status ( ) ) . toBe ( 200 )
35
- expect ( headers2 [ 'x-nextjs-cache' ] ) . toBe ( 'MISS' )
29
+ expect ( headers2 [ 'x-nextjs-cache' ] ) . toBe ( 'HIT' )
36
30
31
+ // the page is cached
37
32
const date2 = await page . textContent ( '[data-testid="date-now"]' )
33
+ expect ( date2 ) . toBe ( date1 )
34
+
35
+ const revalidate = await page . goto ( new URL ( '/api/revalidate' , ctx . url ) . href )
36
+ expect ( revalidate ?. status ( ) ) . toBe ( 200 )
37
+
38
+ // wait a bit until the page got regenerated
39
+ await page . waitForTimeout ( 100 )
40
+
41
+ // now after the revalidation it should have a different date
42
+ const response3 = await page . goto ( new URL ( 'static/revalidate-manual' , ctx . url ) . href )
43
+ const headers3 = response3 ?. headers ( ) || { }
44
+ expect ( response3 ?. status ( ) ) . toBe ( 200 )
45
+ expect ( headers3 [ 'x-nextjs-cache' ] ) . toBe ( 'HIT' )
46
+
47
+ // the page has now an updated date
48
+ const date3 = await page . textContent ( '[data-testid="date-now"]' )
49
+ expect ( date3 ) . not . toBe ( date2 )
50
+ } )
51
+
52
+ // Only works locally with the patched CLI that have blob support enable once this is released
53
+ test . skip ( 'requesting a non existing page route that needs to be fetched from the blob store like 404.html' , async ( {
54
+ page,
55
+ } ) => {
56
+ const response = await page . goto ( new URL ( 'non-exisitng' , ctx . url ) . href )
57
+ const headers = response ?. headers ( ) || { }
58
+ expect ( response ?. status ( ) ) . toBe ( 404 )
38
59
39
- expect ( date1 ) . not . toBe ( date2 )
60
+ expect ( await page . textContent ( 'h1' ) ) . toBe ( '404' )
40
61
} )
41
62
} )
0 commit comments