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