@@ -98,3 +98,58 @@ test("Incremental Static Regeneration with data cache", async ({ page }) => {
9898 expect ( originalCachedDate ) . toEqual ( finalCachedDate ) ;
9999 expect ( originalFetchedDate ) . toEqual ( finalFetchedDate ) ;
100100} ) ;
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+ test ( "should SSR on a path that was not prebuilt" , async ( { page } ) => {
116+ const res = await page . goto ( "/isr/dynamic-params-true/11" ) ;
117+ expect ( res ?. headers ( ) [ "x-nextjs-cache" ] ) . toEqual ( "MISS" ) ;
118+ const title = await page . getByTestId ( "title" ) . textContent ( ) ;
119+ const content = await page . getByTestId ( "content" ) . textContent ( ) ;
120+ expect ( title ) . toEqual ( "Post 11" ) ;
121+ expect ( content ) . toEqual ( "This is post 11" ) ;
122+ } ) ;
123+
124+ test ( "should 404 when you call notFound" , async ( { page } ) => {
125+ const res = await page . goto ( "/isr/dynamic-params-true/21" ) ;
126+ expect ( res ?. status ( ) ) . toEqual ( 404 ) ;
127+ expect ( res ?. headers ( ) [ "cache-control" ] ) . toBe ( "private, no-cache, no-store, max-age=0, must-revalidate" ) ;
128+ await expect ( page . getByText ( "404" ) ) . toBeAttached ( ) ;
129+ } ) ;
130+
131+ test ( "should 500 for a path that throws an error" , async ( { page } ) => {
132+ const res = await page . goto ( "/isr/dynamic-params-true/1337" ) ;
133+ expect ( res ?. status ( ) ) . toEqual ( 500 ) ;
134+ expect ( res ?. headers ( ) [ "cache-control" ] ) . toBe ( "private, no-cache, no-store, max-age=0, must-revalidate" ) ;
135+ } ) ;
136+ } ) ;
137+
138+ test . describe ( "dynamicParams set to false" , ( ) => {
139+ test ( "should be HIT on a path that was prebuilt" , async ( { page } ) => {
140+ const res = await page . goto ( "/isr/dynamic-params-false/1" ) ;
141+ expect ( res ?. status ( ) ) . toEqual ( 200 ) ;
142+ expect ( res ?. headers ( ) [ "x-nextjs-cache" ] ) . toEqual ( "HIT" ) ;
143+ const title = await page . getByTestId ( "title" ) . textContent ( ) ;
144+ const content = await page . getByTestId ( "content" ) . textContent ( ) ;
145+ expect ( title ) . toEqual ( "Post 1" ) ;
146+ expect ( content ) . toEqual ( "This is post 1" ) ;
147+ } ) ;
148+
149+ test ( "should 404 for a path that is not found" , async ( { page } ) => {
150+ const res = await page . goto ( "/isr/dynamic-params-false/11" ) ;
151+ expect ( res ?. status ( ) ) . toEqual ( 404 ) ;
152+ expect ( res ?. headers ( ) [ "cache-control" ] ) . toBe ( "private, no-cache, no-store, max-age=0, must-revalidate" ) ;
153+ await expect ( page . getByText ( "404" ) ) . toBeAttached ( ) ;
154+ } ) ;
155+ } ) ;
0 commit comments