Skip to content

Commit db0ec61

Browse files
committed
test(e2e): fix failures due to latest and canary releases
[v14.2.10](https://github.com/vercel/next.js/releases/tag/v14.2.10) and [v15.0.0-canary.147](https://github.com/vercel/next.js/releases/tag/v15.0.0-canary.147) included vercel/next.js#69802 which added `private` back into `no-cache,no-store` `cache-control` headers in some cases.
1 parent 8a9a8d5 commit db0ec61

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

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

+10-2
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('should serve 404 page when requesting non existing page (no matching route) if site is deployed with CLI not supporting regional blobs', async ({
56
page,
@@ -19,7 +20,14 @@ test('should serve 404 page when requesting non existing page (no matching route
1920
expect(await page.textContent('h1')).toBe('404')
2021

2122
expect(headers['netlify-cdn-cache-control']).toBe(
22-
'no-cache, no-store, max-age=0, must-revalidate, durable',
23+
'private, no-cache, no-store, max-age=0, must-revalidate, durable',
24+
)
25+
// https://github.com/vercel/next.js/pull/69802 made changes to returned cache-control header,
26+
// after that 404 pages would have `private` directive, before that it would not
27+
const shouldHavePrivateDirective = nextVersionSatisfies(
28+
'>=14.2.10 <15.0.0 || >=15.0.0-canary.147',
29+
)
30+
expect(headers['cache-control']).toBe(
31+
(shouldHavePrivateDirective ? 'private,' : '') + 'no-cache,no-store,max-age=0,must-revalidate',
2332
)
24-
expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate')
2533
})

tests/e2e/page-router.test.ts

+19-2
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
export function waitFor(millis: number) {
56
return new Promise((resolve) => setTimeout(resolve, millis))
@@ -343,7 +344,15 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
343344
expect(headers['netlify-cdn-cache-control']).toBe(
344345
'no-cache, no-store, max-age=0, must-revalidate, durable',
345346
)
346-
expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate')
347+
// https://github.com/vercel/next.js/pull/69802 made changes to returned cache-control header,
348+
// after that 404 pages would have `private` directive, before that it would not
349+
const shouldHavePrivateDirective = nextVersionSatisfies(
350+
'>=14.2.10 <15.0.0 || >=15.0.0-canary.147',
351+
)
352+
expect(headers['cache-control']).toBe(
353+
(shouldHavePrivateDirective ? 'private,' : '') +
354+
'no-cache,no-store,max-age=0,must-revalidate',
355+
)
347356
})
348357

349358
test('should serve 404 page when requesting non existing page (marked with notFound: true in getStaticProps)', async ({
@@ -1042,7 +1051,15 @@ test.describe('Page Router with basePath and i18n', () => {
10421051
expect(headers['netlify-cdn-cache-control']).toBe(
10431052
'no-cache, no-store, max-age=0, must-revalidate, durable',
10441053
)
1045-
expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate')
1054+
// https://github.com/vercel/next.js/pull/69802 made changes to returned cache-control header,
1055+
// after that 404 pages would have `private` directive, before that it would not
1056+
const shouldHavePrivateDirective = nextVersionSatisfies(
1057+
'>=14.2.10 <15.0.0 || >=15.0.0-canary.147',
1058+
)
1059+
expect(headers['cache-control']).toBe(
1060+
(shouldHavePrivateDirective ? 'private,' : '') +
1061+
'no-cache,no-store,max-age=0,must-revalidate',
1062+
)
10461063
})
10471064

10481065
test('requesting a non existing page route that needs to be fetched from the blob store like 404.html (notFound: true)', async ({

tests/e2e/simple-app.test.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@ test('requesting a non existing page route that needs to be fetched from the blo
221221

222222
// https://github.com/vercel/next.js/pull/66674 made changes to returned cache-control header,
223223
// before that 404 page would have `private` directive, after that it would not
224-
const shouldHavePrivateDirective = !nextVersionSatisfies('>=14.2.4 <15.0.0 || >=15.0.0-canary.24')
224+
// ... and then https://github.com/vercel/next.js/pull/69802 changed it back again :(
225+
const shouldHavePrivateDirective = nextVersionSatisfies(
226+
'>=14.2.4 <14.2.10 || >=15.0.0-canary.24 < 15.0.0-canary.147',
227+
)
225228

226229
expect(headers['netlify-cdn-cache-control']).toBe(
227230
(shouldHavePrivateDirective ? 'private, ' : '') +

0 commit comments

Comments
 (0)