Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 93dd2b6

Browse filesBrowse files
committed
test: adjust tests for next@15.0.0-canary.187
1 parent 4f5f563 commit 93dd2b6
Copy full SHA for 93dd2b6
Expand file treeCollapse file tree

9 files changed

+143
-49
lines changed

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

Copy file name to clipboardExpand all lines: tests/e2e/on-demand-app.test.ts
+13-4Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from '@playwright/test'
22
import { test } from '../utils/playwright-helpers.js'
3+
import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
34

45
test.describe('app router on-demand revalidation', () => {
56
for (const { label, prerendered, pagePath, revalidateApiPath, expectedH1Content } of [
@@ -90,7 +91,9 @@ test.describe('app router on-demand revalidation', () => {
9091
expect(response1?.status()).toBe(200)
9192
expect(headers1['x-nextjs-cache']).toBeUndefined()
9293
expect(headers1['netlify-cdn-cache-control']).toBe(
93-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
94+
nextVersionSatisfies('>=15.0.0-canary.187')
95+
? 's-maxage=31536000, durable'
96+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
9497
)
9598

9699
const date1 = await page.textContent('[data-testid="date-now"]')
@@ -118,7 +121,9 @@ test.describe('app router on-demand revalidation', () => {
118121
expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m)
119122
}
120123
expect(headers2['netlify-cdn-cache-control']).toBe(
121-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
124+
nextVersionSatisfies('>=15.0.0-canary.187')
125+
? 's-maxage=31536000, durable'
126+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
122127
)
123128

124129
// the page is cached
@@ -148,7 +153,9 @@ test.describe('app router on-demand revalidation', () => {
148153
expect(response3?.status()).toBe(200)
149154
expect(headers3?.['x-nextjs-cache']).toBeUndefined()
150155
expect(headers3['netlify-cdn-cache-control']).toBe(
151-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
156+
nextVersionSatisfies('>=15.0.0-canary.187')
157+
? 's-maxage=31536000, durable'
158+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
152159
)
153160

154161
// the page has now an updated date
@@ -175,7 +182,9 @@ test.describe('app router on-demand revalidation', () => {
175182
expect(headers4['cache-status']).toMatch(/"Next.js"; hit/m)
176183
}
177184
expect(headers4['netlify-cdn-cache-control']).toBe(
178-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
185+
nextVersionSatisfies('>=15.0.0-canary.187')
186+
? 's-maxage=31536000, durable'
187+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
179188
)
180189

181190
// the page is cached

‎tests/e2e/page-router.test.ts

Copy file name to clipboardExpand all lines: tests/e2e/page-router.test.ts
+60-20Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
128128
expect(headers1['x-nextjs-cache']).toBeUndefined()
129129
expect(headers1['netlify-cache-tag']).toBe(`_n_t_${encodeURI(pagePath).toLowerCase()}`)
130130
expect(headers1['netlify-cdn-cache-control']).toBe(
131-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
131+
nextVersionSatisfies('>=15.0.0-canary.187')
132+
? 's-maxage=31536000, durable'
133+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
132134
)
133135

134136
const date1 = await page.textContent('[data-testid="date-now"]')
@@ -156,7 +158,9 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
156158
expect(headers1Json['x-nextjs-cache']).toBeUndefined()
157159
expect(headers1Json['netlify-cache-tag']).toBe(`_n_t_${encodeURI(pagePath).toLowerCase()}`)
158160
expect(headers1Json['netlify-cdn-cache-control']).toBe(
159-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
161+
nextVersionSatisfies('>=15.0.0-canary.187')
162+
? 's-maxage=31536000, durable'
163+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
160164
)
161165
const data1 = (await response1Json?.json()) || {}
162166
expect(data1?.pageProps?.time).toBe(date1)
@@ -181,7 +185,9 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
181185
expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m)
182186
}
183187
expect(headers2['netlify-cdn-cache-control']).toBe(
184-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
188+
nextVersionSatisfies('>=15.0.0-canary.187')
189+
? 's-maxage=31536000, durable'
190+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
185191
)
186192

187193
// the page is cached
@@ -212,7 +218,9 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
212218
expect(headers2Json['cache-status']).toMatch(/"Next.js"; hit/m)
213219
}
214220
expect(headers2Json['netlify-cdn-cache-control']).toBe(
215-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
221+
nextVersionSatisfies('>=15.0.0-canary.187')
222+
? 's-maxage=31536000, durable'
223+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
216224
)
217225

218226
const data2 = (await response2Json?.json()) || {}
@@ -267,7 +275,9 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
267275
expect(response3Json?.status()).toBe(200)
268276
expect(headers3Json['x-nextjs-cache']).toBeUndefined()
269277
expect(headers3Json['netlify-cdn-cache-control']).toBe(
270-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
278+
nextVersionSatisfies('>=15.0.0-canary.187')
279+
? 's-maxage=31536000, durable'
280+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
271281
)
272282

273283
const data3 = (await response3Json?.json()) || {}
@@ -382,7 +392,9 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
382392
expect(await page.textContent('h1')).toBe('404')
383393

384394
expect(headers['netlify-cdn-cache-control']).toBe(
385-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
395+
nextVersionSatisfies('>=15.0.0-canary.187')
396+
? 's-maxage=31536000, durable'
397+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
386398
)
387399
expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate')
388400
})
@@ -532,7 +544,9 @@ test.describe('Page Router with basePath and i18n', () => {
532544
`_n_t_/en${encodeURI(pagePath).toLowerCase()}`,
533545
)
534546
expect(headers1ImplicitLocale['netlify-cdn-cache-control']).toBe(
535-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
547+
nextVersionSatisfies('>=15.0.0-canary.187')
548+
? 's-maxage=31536000, durable'
549+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
536550
)
537551

538552
const date1ImplicitLocale = await page.textContent('[data-testid="date-now"]')
@@ -560,7 +574,9 @@ test.describe('Page Router with basePath and i18n', () => {
560574
`_n_t_/en${encodeURI(pagePath).toLowerCase()}`,
561575
)
562576
expect(headers1ExplicitLocale['netlify-cdn-cache-control']).toBe(
563-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
577+
nextVersionSatisfies('>=15.0.0-canary.187')
578+
? 's-maxage=31536000, durable'
579+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
564580
)
565581

566582
const date1ExplicitLocale = await page.textContent('[data-testid="date-now"]')
@@ -594,7 +610,9 @@ test.describe('Page Router with basePath and i18n', () => {
594610
`_n_t_/en${encodeURI(pagePath).toLowerCase()}`,
595611
)
596612
expect(headers1Json['netlify-cdn-cache-control']).toBe(
597-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
613+
nextVersionSatisfies('>=15.0.0-canary.187')
614+
? 's-maxage=31536000, durable'
615+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
598616
)
599617
const data1 = (await response1Json?.json()) || {}
600618
expect(data1?.pageProps?.time).toBe(date1ImplicitLocale)
@@ -622,7 +640,9 @@ test.describe('Page Router with basePath and i18n', () => {
622640
expect(headers2ImplicitLocale['cache-status']).toMatch(/"Next.js"; hit/m)
623641
}
624642
expect(headers2ImplicitLocale['netlify-cdn-cache-control']).toBe(
625-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
643+
nextVersionSatisfies('>=15.0.0-canary.187')
644+
? 's-maxage=31536000, durable'
645+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
626646
)
627647

628648
// the page is cached
@@ -652,7 +672,9 @@ test.describe('Page Router with basePath and i18n', () => {
652672
expect(headers2ExplicitLocale['cache-status']).toMatch(/"Next.js"; hit/m)
653673
}
654674
expect(headers2ExplicitLocale['netlify-cdn-cache-control']).toBe(
655-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
675+
nextVersionSatisfies('>=15.0.0-canary.187')
676+
? 's-maxage=31536000, durable'
677+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
656678
)
657679

658680
// the page is cached
@@ -683,7 +705,9 @@ test.describe('Page Router with basePath and i18n', () => {
683705
expect(headers2Json['cache-status']).toMatch(/"Next.js"; hit/m)
684706
}
685707
expect(headers2Json['netlify-cdn-cache-control']).toBe(
686-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
708+
nextVersionSatisfies('>=15.0.0-canary.187')
709+
? 's-maxage=31536000, durable'
710+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
687711
)
688712

689713
const data2 = (await response2Json?.json()) || {}
@@ -777,7 +801,9 @@ test.describe('Page Router with basePath and i18n', () => {
777801
expect(headers3Json['cache-status']).toMatch(/"Next.js"; hit/m)
778802
}
779803
expect(headers3Json['netlify-cdn-cache-control']).toBe(
780-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
804+
nextVersionSatisfies('>=15.0.0-canary.187')
805+
? 's-maxage=31536000, durable'
806+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
781807
)
782808

783809
const data3 = (await response3Json?.json()) || {}
@@ -866,7 +892,9 @@ test.describe('Page Router with basePath and i18n', () => {
866892
expect(response4Json?.status()).toBe(200)
867893
expect(headers4Json['x-nextjs-cache']).toBeUndefined()
868894
expect(headers4Json['netlify-cdn-cache-control']).toBe(
869-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
895+
nextVersionSatisfies('>=15.0.0-canary.187')
896+
? 's-maxage=31536000, durable'
897+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
870898
)
871899

872900
const data4 = (await response4Json?.json()) || {}
@@ -912,7 +940,9 @@ test.describe('Page Router with basePath and i18n', () => {
912940
expect(headers1['x-nextjs-cache']).toBeUndefined()
913941
expect(headers1['netlify-cache-tag']).toBe(`_n_t_/de${encodeURI(pagePath).toLowerCase()}`)
914942
expect(headers1['netlify-cdn-cache-control']).toBe(
915-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
943+
nextVersionSatisfies('>=15.0.0-canary.187')
944+
? 's-maxage=31536000, durable'
945+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
916946
)
917947

918948
const date1 = await page.textContent('[data-testid="date-now"]')
@@ -943,7 +973,9 @@ test.describe('Page Router with basePath and i18n', () => {
943973
`_n_t_/de${encodeURI(pagePath).toLowerCase()}`,
944974
)
945975
expect(headers1Json['netlify-cdn-cache-control']).toBe(
946-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
976+
nextVersionSatisfies('>=15.0.0-canary.187')
977+
? 's-maxage=31536000, durable'
978+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
947979
)
948980
const data1 = (await response1Json?.json()) || {}
949981
expect(data1?.pageProps?.time).toBe(date1)
@@ -971,7 +1003,9 @@ test.describe('Page Router with basePath and i18n', () => {
9711003
expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m)
9721004
}
9731005
expect(headers2['netlify-cdn-cache-control']).toBe(
974-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
1006+
nextVersionSatisfies('>=15.0.0-canary.187')
1007+
? 's-maxage=31536000, durable'
1008+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
9751009
)
9761010

9771011
// the page is cached
@@ -1003,7 +1037,9 @@ test.describe('Page Router with basePath and i18n', () => {
10031037
expect(headers2Json['cache-status']).toMatch(/"Next.js"; hit/m)
10041038
}
10051039
expect(headers2Json['netlify-cdn-cache-control']).toBe(
1006-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
1040+
nextVersionSatisfies('>=15.0.0-canary.187')
1041+
? 's-maxage=31536000, durable'
1042+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
10071043
)
10081044

10091045
const data2 = (await response2Json?.json()) || {}
@@ -1070,7 +1106,9 @@ test.describe('Page Router with basePath and i18n', () => {
10701106
expect(headers3Json['cache-status']).toMatch(/"Next.js"; hit/m)
10711107
}
10721108
expect(headers3Json['netlify-cdn-cache-control']).toBe(
1073-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
1109+
nextVersionSatisfies('>=15.0.0-canary.187')
1110+
? 's-maxage=31536000, durable'
1111+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
10741112
)
10751113

10761114
const data3 = (await response3Json?.json()) || {}
@@ -1114,7 +1152,9 @@ test.describe('Page Router with basePath and i18n', () => {
11141152
expect(await page.textContent('h1')).toBe('404')
11151153

11161154
expect(headers['netlify-cdn-cache-control']).toBe(
1117-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
1155+
nextVersionSatisfies('>=15.0.0-canary.187')
1156+
? 's-maxage=31536000, durable'
1157+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
11181158
)
11191159
expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate')
11201160
})

‎tests/e2e/simple-app.test.ts

Copy file name to clipboardExpand all lines: tests/e2e/simple-app.test.ts
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ test('requesting a non existing page route that needs to be fetched from the blo
247247
expect(await page.textContent('h1')).toBe('404 Not Found')
248248

249249
expect(headers['netlify-cdn-cache-control']).toBe(
250-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
250+
nextVersionSatisfies('>=15.0.0-canary.187')
251+
? 's-maxage=31536000, durable'
252+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
251253
)
252254
expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate')
253255
})

‎tests/e2e/turborepo.test.ts

Copy file name to clipboardExpand all lines: tests/e2e/turborepo.test.ts
+13-4Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from '@playwright/test'
22
import { test } from '../utils/playwright-helpers.js'
3+
import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
34

45
// those tests have different fixtures and can run in parallel
56
test.describe.configure({ mode: 'parallel' })
@@ -35,7 +36,9 @@ test.describe('[PNPM] Package manager', () => {
3536
expect(response1?.status()).toBe(200)
3637
expect(headers1['x-nextjs-cache']).toBeUndefined()
3738
expect(headers1['netlify-cdn-cache-control']).toBe(
38-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
39+
nextVersionSatisfies('>=15.0.0-canary.187')
40+
? 's-maxage=31536000, durable'
41+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
3942
)
4043

4144
const date1 = await page.textContent('[data-testid="date-now"]')
@@ -65,7 +68,9 @@ test.describe('[PNPM] Package manager', () => {
6568
expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m)
6669
}
6770
expect(headers2['netlify-cdn-cache-control']).toBe(
68-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
71+
nextVersionSatisfies('>=15.0.0-canary.187')
72+
? 's-maxage=31536000, durable'
73+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
6974
)
7075

7176
// the page is cached
@@ -139,7 +144,9 @@ test.describe('[NPM] Package manager', () => {
139144
expect(response1?.status()).toBe(200)
140145
expect(headers1['x-nextjs-cache']).toBeUndefined()
141146
expect(headers1['netlify-cdn-cache-control']).toBe(
142-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
147+
nextVersionSatisfies('>=15.0.0-canary.187')
148+
? 's-maxage=31536000, durable'
149+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
143150
)
144151

145152
const date1 = await page.textContent('[data-testid="date-now"]')
@@ -169,7 +176,9 @@ test.describe('[NPM] Package manager', () => {
169176
expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m)
170177
}
171178
expect(headers2['netlify-cdn-cache-control']).toBe(
172-
's-maxage=31536000, stale-while-revalidate=31536000, durable',
179+
nextVersionSatisfies('>=15.0.0-canary.187')
180+
? 's-maxage=31536000, durable'
181+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
173182
)
174183

175184
// the page is cached

‎tests/integration/cache-handler.test.ts

Copy file name to clipboardExpand all lines: tests/integration/cache-handler.test.ts
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
getBlobEntries,
1818
startMockBlobStore,
1919
} from '../utils/helpers.js'
20+
import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
2021

2122
// Disable the verbose logging of the lambda-local runtime
2223
getLogger().level = 'alert'
@@ -89,7 +90,9 @@ describe('page router', () => {
8990
).toEqual(
9091
expect.objectContaining({
9192
'cache-status': '"Next.js"; hit',
92-
'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000, durable',
93+
'netlify-cdn-cache-control': nextVersionSatisfies('>=15.0.0-canary.187')
94+
? `s-maxage=5, stale-while-revalidate=${31536000 - 5}, durable`
95+
: 's-maxage=5, stale-while-revalidate=31536000, durable',
9396
}),
9497
)
9598
expect(
@@ -240,7 +243,9 @@ describe('app router', () => {
240243
// It will be hit instead of stale
241244
expect.objectContaining({
242245
'cache-status': '"Next.js"; hit',
243-
'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000, durable',
246+
'netlify-cdn-cache-control': nextVersionSatisfies('>=15.0.0-canary.187')
247+
? 's-maxage=31536000, durable'
248+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
244249
}),
245250
)
246251
expect(

‎tests/integration/fetch-handler.test.ts

Copy file name to clipboardExpand all lines: tests/integration/fetch-handler.test.ts
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { afterAll, beforeAll, beforeEach, expect, test, vi } from 'vitest'
77
import { type FixtureTestContext } from '../utils/contexts.js'
88
import { createFixture, invokeFunction, runPlugin, runPluginStep } from '../utils/fixture.js'
99
import { generateRandomObjectID, startMockBlobStore } from '../utils/helpers.js'
10+
import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
1011

1112
// Disable the verbose logging of the lambda-local runtime
1213
getLogger().level = 'alert'
@@ -229,7 +230,9 @@ test<FixtureTestContext>('if the fetch call is cached correctly (cached page res
229230
).toEqual(
230231
expect.objectContaining({
231232
'cache-status': '"Next.js"; hit',
232-
'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000, durable',
233+
'netlify-cdn-cache-control': nextVersionSatisfies('>=15.0.0-canary.187')
234+
? `s-maxage=5, stale-while-revalidate=${31536000 - 5}, durable`
235+
: 's-maxage=5, stale-while-revalidate=31536000, durable',
233236
}),
234237
)
235238

@@ -295,7 +298,9 @@ test<FixtureTestContext>('if the fetch call is cached correctly (cached page res
295298
).toEqual(
296299
expect.objectContaining({
297300
'cache-status': '"Next.js"; hit',
298-
'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000, durable',
301+
'netlify-cdn-cache-control': nextVersionSatisfies('>=15.0.0-canary.187')
302+
? `s-maxage=5, stale-while-revalidate=${31536000 - 5}, durable`
303+
: 's-maxage=5, stale-while-revalidate=31536000, durable',
299304
}),
300305
)
301306
})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.