Skip to content

Commit 96926e3

Browse files
committed
test: update assertions for fully rolled out durable cache
1 parent c993184 commit 96926e3

14 files changed

+53
-78
lines changed

tests/e2e/cli-before-regional-blobs-support.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test('should serve 404 page when requesting non existing page (no matching route
1919
expect(await page.textContent('h1')).toBe('404')
2020

2121
expect(headers['netlify-cdn-cache-control']).toBe(
22-
'no-cache, no-store, max-age=0, must-revalidate',
22+
'no-cache, no-store, max-age=0, must-revalidate, durable',
2323
)
2424
expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate')
2525
})

tests/e2e/durable-cache.test.ts

-19
This file was deleted.

tests/e2e/on-demand-app.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ test.describe('app router on-demand revalidation', () => {
7676
expect(response1?.status()).toBe(200)
7777
expect(headers1['x-nextjs-cache']).toBeUndefined()
7878
expect(headers1['netlify-cdn-cache-control']).toBe(
79-
's-maxage=31536000, stale-while-revalidate=31536000',
79+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
8080
)
8181

8282
const date1 = await page.textContent('[data-testid="date-now"]')
@@ -104,7 +104,7 @@ test.describe('app router on-demand revalidation', () => {
104104
expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m)
105105
}
106106
expect(headers2['netlify-cdn-cache-control']).toBe(
107-
's-maxage=31536000, stale-while-revalidate=31536000',
107+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
108108
)
109109

110110
// the page is cached
@@ -134,7 +134,7 @@ test.describe('app router on-demand revalidation', () => {
134134
expect(response3?.status()).toBe(200)
135135
expect(headers3?.['x-nextjs-cache']).toBeUndefined()
136136
expect(headers3['netlify-cdn-cache-control']).toBe(
137-
's-maxage=31536000, stale-while-revalidate=31536000',
137+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
138138
)
139139

140140
// the page has now an updated date
@@ -161,7 +161,7 @@ test.describe('app router on-demand revalidation', () => {
161161
expect(headers4['cache-status']).toMatch(/"Next.js"; hit/m)
162162
}
163163
expect(headers4['netlify-cdn-cache-control']).toBe(
164-
's-maxage=31536000, stale-while-revalidate=31536000',
164+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
165165
)
166166

167167
// the page is cached

tests/e2e/page-router.test.ts

+23-23
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
111111
expect(headers1['x-nextjs-cache']).toBeUndefined()
112112
expect(headers1['netlify-cache-tag']).toBe(`_n_t_${pagePath}`)
113113
expect(headers1['netlify-cdn-cache-control']).toBe(
114-
's-maxage=31536000, stale-while-revalidate=31536000',
114+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
115115
)
116116

117117
const date1 = await page.textContent('[data-testid="date-now"]')
@@ -139,7 +139,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
139139
expect(headers1Json['x-nextjs-cache']).toBeUndefined()
140140
expect(headers1Json['netlify-cache-tag']).toBe(`_n_t_${pagePath}`)
141141
expect(headers1Json['netlify-cdn-cache-control']).toBe(
142-
's-maxage=31536000, stale-while-revalidate=31536000',
142+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
143143
)
144144
const data1 = (await response1Json?.json()) || {}
145145
expect(data1?.pageProps?.time).toBe(date1)
@@ -164,7 +164,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
164164
expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m)
165165
}
166166
expect(headers2['netlify-cdn-cache-control']).toBe(
167-
's-maxage=31536000, stale-while-revalidate=31536000',
167+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
168168
)
169169

170170
// the page is cached
@@ -195,7 +195,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
195195
expect(headers2Json['cache-status']).toMatch(/"Next.js"; hit/m)
196196
}
197197
expect(headers2Json['netlify-cdn-cache-control']).toBe(
198-
's-maxage=31536000, stale-while-revalidate=31536000',
198+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
199199
)
200200

201201
const data2 = (await response2Json?.json()) || {}
@@ -250,7 +250,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
250250
expect(response3Json?.status()).toBe(200)
251251
expect(headers3Json['x-nextjs-cache']).toBeUndefined()
252252
expect(headers3Json['netlify-cdn-cache-control']).toBe(
253-
's-maxage=31536000, stale-while-revalidate=31536000',
253+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
254254
)
255255

256256
const data3 = (await response3Json?.json()) || {}
@@ -341,7 +341,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
341341
expect(await page.textContent('h1')).toBe('404')
342342

343343
expect(headers['netlify-cdn-cache-control']).toBe(
344-
'no-cache, no-store, max-age=0, must-revalidate',
344+
'no-cache, no-store, max-age=0, must-revalidate, durable',
345345
)
346346
expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate')
347347
})
@@ -357,7 +357,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
357357
expect(await page.textContent('h1')).toBe('404')
358358

359359
expect(headers['netlify-cdn-cache-control']).toBe(
360-
's-maxage=31536000, stale-while-revalidate=31536000',
360+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
361361
)
362362
expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate')
363363
})
@@ -401,7 +401,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
401401
const response = await page.goto(new URL('static/fully-static', pageRouter.url).href)
402402
const headers = response?.headers() || {}
403403

404-
expect(headers['netlify-cdn-cache-control']).toBe('max-age=31536000')
404+
expect(headers['netlify-cdn-cache-control']).toBe('max-age=31536000, durable')
405405
expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate')
406406
})
407407

@@ -487,7 +487,7 @@ test.describe('Page Router with basePath and i18n', () => {
487487
expect(headers1ImplicitLocale['x-nextjs-cache']).toBeUndefined()
488488
expect(headers1ImplicitLocale['netlify-cache-tag']).toBe(`_n_t_/en${pagePath}`)
489489
expect(headers1ImplicitLocale['netlify-cdn-cache-control']).toBe(
490-
's-maxage=31536000, stale-while-revalidate=31536000',
490+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
491491
)
492492

493493
const date1ImplicitLocale = await page.textContent('[data-testid="date-now"]')
@@ -513,7 +513,7 @@ test.describe('Page Router with basePath and i18n', () => {
513513
expect(headers1ExplicitLocale['x-nextjs-cache']).toBeUndefined()
514514
expect(headers1ExplicitLocale['netlify-cache-tag']).toBe(`_n_t_/en${pagePath}`)
515515
expect(headers1ExplicitLocale['netlify-cdn-cache-control']).toBe(
516-
's-maxage=31536000, stale-while-revalidate=31536000',
516+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
517517
)
518518

519519
const date1ExplicitLocale = await page.textContent('[data-testid="date-now"]')
@@ -545,7 +545,7 @@ test.describe('Page Router with basePath and i18n', () => {
545545
expect(headers1Json['x-nextjs-cache']).toBeUndefined()
546546
expect(headers1Json['netlify-cache-tag']).toBe(`_n_t_/en${pagePath}`)
547547
expect(headers1Json['netlify-cdn-cache-control']).toBe(
548-
's-maxage=31536000, stale-while-revalidate=31536000',
548+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
549549
)
550550
const data1 = (await response1Json?.json()) || {}
551551
expect(data1?.pageProps?.time).toBe(date1ImplicitLocale)
@@ -573,7 +573,7 @@ test.describe('Page Router with basePath and i18n', () => {
573573
expect(headers2ImplicitLocale['cache-status']).toMatch(/"Next.js"; hit/m)
574574
}
575575
expect(headers2ImplicitLocale['netlify-cdn-cache-control']).toBe(
576-
's-maxage=31536000, stale-while-revalidate=31536000',
576+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
577577
)
578578

579579
// the page is cached
@@ -603,7 +603,7 @@ test.describe('Page Router with basePath and i18n', () => {
603603
expect(headers2ExplicitLocale['cache-status']).toMatch(/"Next.js"; hit/m)
604604
}
605605
expect(headers2ExplicitLocale['netlify-cdn-cache-control']).toBe(
606-
's-maxage=31536000, stale-while-revalidate=31536000',
606+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
607607
)
608608

609609
// the page is cached
@@ -634,7 +634,7 @@ test.describe('Page Router with basePath and i18n', () => {
634634
expect(headers2Json['cache-status']).toMatch(/"Next.js"; hit/m)
635635
}
636636
expect(headers2Json['netlify-cdn-cache-control']).toBe(
637-
's-maxage=31536000, stale-while-revalidate=31536000',
637+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
638638
)
639639

640640
const data2 = (await response2Json?.json()) || {}
@@ -728,7 +728,7 @@ test.describe('Page Router with basePath and i18n', () => {
728728
expect(headers3Json['cache-status']).toMatch(/"Next.js"; hit/m)
729729
}
730730
expect(headers3Json['netlify-cdn-cache-control']).toBe(
731-
's-maxage=31536000, stale-while-revalidate=31536000',
731+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
732732
)
733733

734734
const data3 = (await response3Json?.json()) || {}
@@ -817,7 +817,7 @@ test.describe('Page Router with basePath and i18n', () => {
817817
expect(response4Json?.status()).toBe(200)
818818
expect(headers4Json['x-nextjs-cache']).toBeUndefined()
819819
expect(headers4Json['netlify-cdn-cache-control']).toBe(
820-
's-maxage=31536000, stale-while-revalidate=31536000',
820+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
821821
)
822822

823823
const data4 = (await response4Json?.json()) || {}
@@ -863,7 +863,7 @@ test.describe('Page Router with basePath and i18n', () => {
863863
expect(headers1['x-nextjs-cache']).toBeUndefined()
864864
expect(headers1['netlify-cache-tag']).toBe(`_n_t_/de${pagePath}`)
865865
expect(headers1['netlify-cdn-cache-control']).toBe(
866-
's-maxage=31536000, stale-while-revalidate=31536000',
866+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
867867
)
868868

869869
const date1 = await page.textContent('[data-testid="date-now"]')
@@ -892,7 +892,7 @@ test.describe('Page Router with basePath and i18n', () => {
892892
expect(headers1Json['x-nextjs-cache']).toBeUndefined()
893893
expect(headers1Json['netlify-cache-tag']).toBe(`_n_t_/de${pagePath}`)
894894
expect(headers1Json['netlify-cdn-cache-control']).toBe(
895-
's-maxage=31536000, stale-while-revalidate=31536000',
895+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
896896
)
897897
const data1 = (await response1Json?.json()) || {}
898898
expect(data1?.pageProps?.time).toBe(date1)
@@ -920,7 +920,7 @@ test.describe('Page Router with basePath and i18n', () => {
920920
expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m)
921921
}
922922
expect(headers2['netlify-cdn-cache-control']).toBe(
923-
's-maxage=31536000, stale-while-revalidate=31536000',
923+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
924924
)
925925

926926
// the page is cached
@@ -952,7 +952,7 @@ test.describe('Page Router with basePath and i18n', () => {
952952
expect(headers2Json['cache-status']).toMatch(/"Next.js"; hit/m)
953953
}
954954
expect(headers2Json['netlify-cdn-cache-control']).toBe(
955-
's-maxage=31536000, stale-while-revalidate=31536000',
955+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
956956
)
957957

958958
const data2 = (await response2Json?.json()) || {}
@@ -1019,7 +1019,7 @@ test.describe('Page Router with basePath and i18n', () => {
10191019
expect(headers3Json['cache-status']).toMatch(/"Next.js"; hit/m)
10201020
}
10211021
expect(headers3Json['netlify-cdn-cache-control']).toBe(
1022-
's-maxage=31536000, stale-while-revalidate=31536000',
1022+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
10231023
)
10241024

10251025
const data3 = (await response3Json?.json()) || {}
@@ -1040,7 +1040,7 @@ test.describe('Page Router with basePath and i18n', () => {
10401040
expect(await page.textContent('h1')).toBe('404')
10411041

10421042
expect(headers['netlify-cdn-cache-control']).toBe(
1043-
'no-cache, no-store, max-age=0, must-revalidate',
1043+
'no-cache, no-store, max-age=0, must-revalidate, durable',
10441044
)
10451045
expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate')
10461046
})
@@ -1056,7 +1056,7 @@ test.describe('Page Router with basePath and i18n', () => {
10561056
expect(await page.textContent('h1')).toBe('404')
10571057

10581058
expect(headers['netlify-cdn-cache-control']).toBe(
1059-
's-maxage=31536000, stale-while-revalidate=31536000',
1059+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
10601060
)
10611061
expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate')
10621062
})

tests/e2e/simple-app.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ test('requesting a non existing page route that needs to be fetched from the blo
222222

223223
expect(headers['netlify-cdn-cache-control']).toBe(
224224
(shouldHavePrivateDirective ? 'private, ' : '') +
225-
'no-cache, no-store, max-age=0, must-revalidate',
225+
'no-cache, no-store, max-age=0, must-revalidate, durable',
226226
)
227227
expect(headers['cache-control']).toBe(
228228
(shouldHavePrivateDirective ? 'private,' : '') + 'no-cache,no-store,max-age=0,must-revalidate',
@@ -240,7 +240,7 @@ test('requesting a non existing page route that needs to be fetched from the blo
240240
expect(await page.textContent('h1')).toBe('404 Not Found')
241241

242242
expect(headers['netlify-cdn-cache-control']).toBe(
243-
's-maxage=31536000, stale-while-revalidate=31536000',
243+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
244244
)
245245
expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate')
246246
})

tests/e2e/turborepo.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ test.describe('[PNPM] Package manager', () => {
3535
expect(response1?.status()).toBe(200)
3636
expect(headers1['x-nextjs-cache']).toBeUndefined()
3737
expect(headers1['netlify-cdn-cache-control']).toBe(
38-
's-maxage=31536000, stale-while-revalidate=31536000',
38+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
3939
)
4040

4141
const date1 = await page.textContent('[data-testid="date-now"]')
@@ -65,7 +65,7 @@ test.describe('[PNPM] Package manager', () => {
6565
expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m)
6666
}
6767
expect(headers2['netlify-cdn-cache-control']).toBe(
68-
's-maxage=31536000, stale-while-revalidate=31536000',
68+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
6969
)
7070

7171
// the page is cached
@@ -139,7 +139,7 @@ test.describe('[NPM] Package manager', () => {
139139
expect(response1?.status()).toBe(200)
140140
expect(headers1['x-nextjs-cache']).toBeUndefined()
141141
expect(headers1['netlify-cdn-cache-control']).toBe(
142-
's-maxage=31536000, stale-while-revalidate=31536000',
142+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
143143
)
144144

145145
const date1 = await page.textContent('[data-testid="date-now"]')
@@ -169,7 +169,7 @@ test.describe('[NPM] Package manager', () => {
169169
expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m)
170170
}
171171
expect(headers2['netlify-cdn-cache-control']).toBe(
172-
's-maxage=31536000, stale-while-revalidate=31536000',
172+
's-maxage=31536000, stale-while-revalidate=31536000, durable',
173173
)
174174

175175
// the page is cached

tests/integration/cache-handler.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('page router', () => {
8888
).toEqual(
8989
expect.objectContaining({
9090
'cache-status': '"Next.js"; hit',
91-
'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000',
91+
'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000, durable',
9292
}),
9393
)
9494
expect(
@@ -239,7 +239,7 @@ describe('app router', () => {
239239
// It will be hit instead of stale
240240
expect.objectContaining({
241241
'cache-status': '"Next.js"; hit',
242-
'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000',
242+
'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000, durable',
243243
}),
244244
)
245245
expect(

tests/integration/fetch-handler.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ test<FixtureTestContext>('if the fetch call is cached correctly (cached page res
229229
).toEqual(
230230
expect.objectContaining({
231231
'cache-status': '"Next.js"; hit',
232-
'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000',
232+
'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000, durable',
233233
}),
234234
)
235235

@@ -295,7 +295,7 @@ test<FixtureTestContext>('if the fetch call is cached correctly (cached page res
295295
).toEqual(
296296
expect.objectContaining({
297297
'cache-status': '"Next.js"; hit',
298-
'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000',
298+
'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000, durable',
299299
}),
300300
)
301301
})

tests/integration/page-router.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ test.skipIf(platform === 'win32')<FixtureTestContext>(
121121
url: '/static/fully-static',
122122
})
123123

124-
expect(response.headers?.['netlify-cdn-cache-control']).toBe('max-age=31536000')
124+
expect(response.headers?.['netlify-cdn-cache-control']).toBe('max-age=31536000, durable')
125125
expect(response.headers?.['cache-control']).toBe('public, max-age=0, must-revalidate')
126126
},
127127
)

0 commit comments

Comments
 (0)