@@ -98,3 +98,59 @@ test("Incremental Static Regeneration with data cache", async ({ page }) => {
98
98
expect ( originalCachedDate ) . toEqual ( finalCachedDate ) ;
99
99
expect ( originalFetchedDate ) . toEqual ( finalFetchedDate ) ;
100
100
} ) ;
101
+
102
+ test . describe ( "dynamicParams set to true" , ( ) => {
103
+ test ( "should be HIT on a path that was prebuilt" , async ( { page } ) => {
104
+ const res = await page . goto ( "/isr/dynamic-params-true/1" ) ;
105
+ expect ( res ?. status ( ) ) . toEqual ( 200 ) ;
106
+ expect ( res ?. headers ( ) [ "x-nextjs-cache" ] ) . toEqual ( "HIT" ) ;
107
+ const title = await page . getByTestId ( "title" ) . textContent ( ) ;
108
+ const content = await page . getByTestId ( "content" ) . textContent ( ) ;
109
+ expect ( title ) . toEqual ( "Post 1" ) ;
110
+ expect ( content ) . toEqual ( "This is post 1" ) ;
111
+ } ) ;
112
+
113
+ // In `next start` this test would fail on subsequent requests because `x-nextjs-cache` would be `HIT`
114
+ // However, once deployed to AWS, Cloudfront will cache `MISS`
115
+ // We are gonna skip this one for now, turborepo caching can cause this page to be STALE once deployed
116
+ test . skip ( "should SSR on a path that was not prebuilt" , async ( { page } ) => {
117
+ const res = await page . goto ( "/isr/dynamic-params-true/11" ) ;
118
+ expect ( res ?. headers ( ) [ "x-nextjs-cache" ] ) . toEqual ( "MISS" ) ;
119
+ const title = await page . getByTestId ( "title" ) . textContent ( ) ;
120
+ const content = await page . getByTestId ( "content" ) . textContent ( ) ;
121
+ expect ( title ) . toEqual ( "Post 11" ) ;
122
+ expect ( content ) . toEqual ( "This is post 11" ) ;
123
+ } ) ;
124
+
125
+ test ( "should 404 when you call notFound" , async ( { page } ) => {
126
+ const res = await page . goto ( "/isr/dynamic-params-true/21" ) ;
127
+ expect ( res ?. status ( ) ) . toEqual ( 404 ) ;
128
+ expect ( res ?. headers ( ) [ "cache-control" ] ) . toBe ( "private, no-cache, no-store, max-age=0, must-revalidate" ) ;
129
+ await expect ( page . getByText ( "404" ) ) . toBeAttached ( ) ;
130
+ } ) ;
131
+
132
+ test ( "should 500 for a path that throws an error" , async ( { page } ) => {
133
+ const res = await page . goto ( "/isr/dynamic-params-true/1337" ) ;
134
+ expect ( res ?. status ( ) ) . toEqual ( 500 ) ;
135
+ expect ( res ?. headers ( ) [ "cache-control" ] ) . toBe ( "private, no-cache, no-store, max-age=0, must-revalidate" ) ;
136
+ } ) ;
137
+ } ) ;
138
+
139
+ test . describe ( "dynamicParams set to false" , ( ) => {
140
+ test ( "should be HIT on a path that was prebuilt" , async ( { page } ) => {
141
+ const res = await page . goto ( "/isr/dynamic-params-false/1" ) ;
142
+ expect ( res ?. status ( ) ) . toEqual ( 200 ) ;
143
+ expect ( res ?. headers ( ) [ "x-nextjs-cache" ] ) . toEqual ( "HIT" ) ;
144
+ const title = await page . getByTestId ( "title" ) . textContent ( ) ;
145
+ const content = await page . getByTestId ( "content" ) . textContent ( ) ;
146
+ expect ( title ) . toEqual ( "Post 1" ) ;
147
+ expect ( content ) . toEqual ( "This is post 1" ) ;
148
+ } ) ;
149
+
150
+ test ( "should 404 for a path that is not found" , async ( { page } ) => {
151
+ const res = await page . goto ( "/isr/dynamic-params-false/11" ) ;
152
+ expect ( res ?. status ( ) ) . toEqual ( 404 ) ;
153
+ expect ( res ?. headers ( ) [ "cache-control" ] ) . toBe ( "private, no-cache, no-store, max-age=0, must-revalidate" ) ;
154
+ await expect ( page . getByText ( "404" ) ) . toBeAttached ( ) ;
155
+ } ) ;
156
+ } ) ;
0 commit comments