@@ -17,42 +17,45 @@ test.describe('Dynamic CMS', () => {
17
17
/ s - m a x a g e = 3 1 5 3 6 0 0 0 , ( s t a l e - w h i l e - r e v a l i d a t e = 3 1 5 3 6 0 0 0 , ) ? d u r a b l e / ,
18
18
)
19
19
20
- // 2. Publish the blob, revalidate the dynamic page, and wait to regenerate
21
- await page . goto ( new URL ( '/cms/publish' , dynamicCms . url ) . href )
22
- await page . goto ( new URL ( '/api/revalidate?path=/content/blog' , dynamicCms . url ) . href )
23
- await page . waitForTimeout ( 1000 )
24
-
25
- // 3. Verify the status and headers of the dynamic page
26
- const response2 = await page . goto ( new URL ( '/content/blog' , dynamicCms . url ) . href )
27
- const headers2 = response2 ?. headers ( ) || { }
28
-
29
- expect ( response2 ?. status ( ) ) . toEqual ( 200 )
30
- expect ( headers2 [ 'cache-control' ] ) . toEqual ( 'public,max-age=0,must-revalidate' )
31
- expect ( headers2 [ 'cache-status' ] ) . toMatch (
32
- / " N e x t .j s " ; h i t , " N e t l i f y D u r a b l e " ; f w d = s t a l e ; t t l = [ 0 - 9 ] + ; s t o r e d , " N e t l i f y E d g e " ; f w d = ( s t a l e | m i s s ) / ,
33
- )
34
- expect ( headers2 [ 'netlify-cache-tag' ] ) . toEqual ( '_n_t_/content/blog' )
35
- expect ( headers2 [ 'netlify-cdn-cache-control' ] ) . toMatch (
36
- / s - m a x a g e = 3 1 5 3 6 0 0 0 , ( s t a l e - w h i l e - r e v a l i d a t e = 3 1 5 3 6 0 0 0 , ) ? d u r a b l e / ,
37
- )
38
-
39
- // 4. Unpublish the blob, revalidate the dynamic page, and wait to regenerate
40
- await page . goto ( new URL ( '/cms/unpublish' , dynamicCms . url ) . href )
41
- await page . goto ( new URL ( '/api/revalidate?path=/content/blog' , dynamicCms . url ) . href )
42
- await page . waitForTimeout ( 1000 )
43
-
44
- // 5. Verify the status and headers of the dynamic page
45
- const response3 = await page . goto ( new URL ( '/content/blog' , dynamicCms . url ) . href )
46
- const headers3 = response3 ?. headers ( ) || { }
47
-
48
- expect ( response3 ?. status ( ) ) . toEqual ( 404 )
49
- expect ( headers3 [ 'cache-control' ] ) . toEqual ( 'public,max-age=0,must-revalidate' )
50
- expect ( headers3 [ 'cache-status' ] ) . toMatch (
51
- / " N e x t .j s " ; f w d = m i s s , " N e t l i f y D u r a b l e " ; f w d = s t a l e ; t t l = [ 0 - 9 ] + ; s t o r e d , " N e t l i f y E d g e " ; f w d = ( s t a l e | m i s s ) / ,
52
- )
53
- expect ( headers3 [ 'netlify-cache-tag' ] ) . toEqual ( '_n_t_/content/blog' )
54
- expect ( headers3 [ 'netlify-cdn-cache-control' ] ) . toMatch (
55
- / s - m a x a g e = 3 1 5 3 6 0 0 0 , ( s t a l e - w h i l e - r e v a l i d a t e = 3 1 5 3 6 0 0 0 , ) ? d u r a b l e / ,
56
- )
20
+ // repeat Publish and Unpublish to ensure the flow is repeatable
21
+ for ( let i = 0 ; i < 2 ; i ++ ) {
22
+ // 2. Publish the blob, revalidate the dynamic page, and wait to regenerate
23
+ await page . goto ( new URL ( '/cms/publish' , dynamicCms . url ) . href )
24
+ await page . goto ( new URL ( '/api/revalidate?path=/content/blog' , dynamicCms . url ) . href )
25
+ await page . waitForTimeout ( 1000 )
26
+
27
+ // 3. Verify the status and headers of the dynamic page
28
+ const response2 = await page . goto ( new URL ( '/content/blog' , dynamicCms . url ) . href )
29
+ const headers2 = response2 ?. headers ( ) || { }
30
+
31
+ expect ( response2 ?. status ( ) ) . toEqual ( 200 )
32
+ expect ( headers2 [ 'cache-control' ] ) . toEqual ( 'public,max-age=0,must-revalidate' )
33
+ expect ( headers2 [ 'cache-status' ] ) . toMatch (
34
+ / " N e x t .j s " ; h i t , " N e t l i f y D u r a b l e " ; f w d = s t a l e ; t t l = [ 0 - 9 ] + ; s t o r e d , " N e t l i f y E d g e " ; f w d = ( s t a l e | m i s s ) / ,
35
+ )
36
+ expect ( headers2 [ 'netlify-cache-tag' ] ) . toEqual ( '_n_t_/content/blog' )
37
+ expect ( headers2 [ 'netlify-cdn-cache-control' ] ) . toMatch (
38
+ / s - m a x a g e = 3 1 5 3 6 0 0 0 , ( s t a l e - w h i l e - r e v a l i d a t e = 3 1 5 3 6 0 0 0 , ) ? d u r a b l e / ,
39
+ )
40
+
41
+ // 4. Unpublish the blob, revalidate the dynamic page, and wait to regenerate
42
+ await page . goto ( new URL ( '/cms/unpublish' , dynamicCms . url ) . href )
43
+ await page . goto ( new URL ( '/api/revalidate?path=/content/blog' , dynamicCms . url ) . href )
44
+ await page . waitForTimeout ( 1000 )
45
+
46
+ // 5. Verify the status and headers of the dynamic page
47
+ const response3 = await page . goto ( new URL ( '/content/blog' , dynamicCms . url ) . href )
48
+ const headers3 = response3 ?. headers ( ) || { }
49
+
50
+ expect ( response3 ?. status ( ) ) . toEqual ( 404 )
51
+ expect ( headers3 [ 'cache-control' ] ) . toEqual ( 'public,max-age=0,must-revalidate' )
52
+ expect ( headers3 [ 'cache-status' ] ) . toMatch (
53
+ / " N e x t .j s " ; f w d = m i s s , " N e t l i f y D u r a b l e " ; f w d = s t a l e ; t t l = [ 0 - 9 ] + ; s t o r e d , " N e t l i f y E d g e " ; f w d = ( s t a l e | m i s s ) / ,
54
+ )
55
+ expect ( headers3 [ 'netlify-cache-tag' ] ) . toEqual ( '_n_t_/content/blog' )
56
+ expect ( headers3 [ 'netlify-cdn-cache-control' ] ) . toMatch (
57
+ / s - m a x a g e = 3 1 5 3 6 0 0 0 , ( s t a l e - w h i l e - r e v a l i d a t e = 3 1 5 3 6 0 0 0 , ) ? d u r a b l e / ,
58
+ )
59
+ }
57
60
} )
58
61
} )
0 commit comments