Skip to content

Commit 039c9e1

Browse files
authored
test: adjust tests for next@16 (#3169)
1 parent ba1d3b3 commit 039c9e1

File tree

8 files changed

+58
-11
lines changed

8 files changed

+58
-11
lines changed

.github/workflows/run-tests.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,22 @@ jobs:
2828
repo: context.repo.repo,
2929
issue_number: context.payload.pull_request.number,
3030
});
31-
return labels.some(label => label.name === 'autorelease: pending' || label.name === 'test all versions');
31+
const shouldTestAllVersions = labels.some(label => label.name === 'autorelease: pending' || label.name === 'test all versions');
32+
if (shouldTestAllVersions) {
33+
return 'all'
34+
}
35+
36+
return labels.some(label => label.name === 'test latest and canary') ? 'latest-and-canary' : 'latest'
3237
- name: Set Next.js versions to test
3338
id: set-matrix
3439
# If this is the nightly build or a release PR then run the full matrix of versions
3540
run: |
3641
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
3742
echo "matrix=${{ github.event.inputs.versions }}" >> $GITHUB_OUTPUT
38-
elif [ "${{ github.event_name }}" = "schedule" ] || [ "${{ steps.check-labels.outputs.result }}" = "true" ]; then
43+
elif [ "${{ github.event_name }}" = "schedule" ] || [ "${{ steps.check-labels.outputs.result }}" = "all" ]; then
3944
echo "matrix=[\"latest\", \"canary\", \"14.2.15\", \"13.5.1\"]" >> $GITHUB_OUTPUT
45+
elif [ "${{ steps.check-labels.outputs.result }}" = "latest-and-canary" ]; then
46+
echo "matrix=[\"latest\", \"canary\"]" >> $GITHUB_OUTPUT
4047
else
4148
echo "matrix=[\"latest\"]" >> $GITHUB_OUTPUT
4249
fi

tests/e2e/simple-app.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ test('requesting a non existing page route that needs to be fetched from the blo
234234
// would not ... and then https://github.com/vercel/next.js/pull/69802 changed it back again
235235
// (14.2.10 and canary.147)
236236
const shouldHavePrivateDirective = nextVersionSatisfies(
237-
'<14.2.4 || >=14.2.10 <15.0.0-canary.24 || ^15.0.0-canary.147',
237+
'<14.2.4 || >=14.2.10 <15.0.0-canary.24 || >=15.0.0-canary.147',
238238
)
239239

240240
expect(headers['debug-netlify-cdn-cache-control']).toBe(

tests/fixtures/ppr/next.config.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
1+
const { satisfies } = require('semver')
2+
3+
// https://github.com/vercel/next.js/pull/84280
4+
const pprConfigHardDeprecated = satisfies(
5+
require('next/package.json').version,
6+
'>=15.6.0-canary.54',
7+
{
8+
includePrerelease: true,
9+
},
10+
)
11+
112
/** @type {import('next').NextConfig} */
213
const nextConfig = {
314
output: 'standalone',
415
eslint: {
516
ignoreDuringBuilds: true,
617
},
7-
experimental: {
8-
ppr: true,
9-
},
18+
experimental: pprConfigHardDeprecated
19+
? {
20+
cacheComponents: true,
21+
}
22+
: {
23+
ppr: true,
24+
},
1025
outputFileTracingRoot: __dirname,
1126
}
1227

tests/fixtures/ppr/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"dependencies": {
1111
"next": "canary",
1212
"react": "18.2.0",
13-
"react-dom": "18.2.0"
13+
"react-dom": "18.2.0",
14+
"semver": "^7.7.2"
1415
},
1516
"test": {
1617
"dependencies": {

tests/fixtures/server-components/app/api/on-demand-revalidate/tag/route.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { NextRequest, NextResponse } from 'next/server'
2-
import { revalidateTag } from 'next/cache'
2+
import { revalidateTag as typedRevalidateTag } from 'next/cache'
3+
4+
// https://github.com/vercel/next.js/pull/83822 deprecated revalidateTag with single argument, but it still is working
5+
// types however do not allow single param usage, so typing as any to workaround type error
6+
const revalidateTag = typedRevalidateTag as any
37

48
export async function GET(request: NextRequest) {
59
const url = new URL(request.url)

tests/fixtures/use-cache/app/api/revalidate/[...slug]/route.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { revalidateTag } from 'next/cache'
1+
import { revalidateTag as typedRevalidateTag } from 'next/cache'
22
import { NextRequest } from 'next/server'
33

4+
// https://github.com/vercel/next.js/pull/83822 deprecated revalidateTag with single argument, but it still is working
5+
// types however do not allow single param usage, so typing as any to workaround type error
6+
const revalidateTag = typedRevalidateTag as any
7+
48
export async function GET(request: NextRequest, { params }) {
59
const { slug } = await params
610

tests/integration/simple-app.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ import {
3636
} from '../utils/helpers.js'
3737
import {
3838
hasDefaultTurbopackBuilds,
39+
isExperimentalPPRHardDeprecated,
3940
nextVersionSatisfies,
4041
shouldHaveAppRouterGlobalErrorInPrerenderManifest,
4142
shouldHaveAppRouterNotFoundInPrerenderManifest,
43+
shouldHaveSlashIndexTagForIndexPage,
4244
} from '../utils/next-version-helpers.mjs'
4345

4446
const mockedCp = cp as Mock<(typeof import('node:fs/promises'))['cp']>
@@ -205,7 +207,11 @@ test<FixtureTestContext>('index should be normalized within the cacheHandler and
205207
await runPlugin(ctx)
206208
const index = await invokeFunction(ctx, { url: '/' })
207209
expect(index.statusCode).toBe(200)
208-
expect(index.headers?.['netlify-cache-tag']).toBe('_N_T_/layout,_N_T_/page,_N_T_/')
210+
expect(index.headers?.['netlify-cache-tag']).toBe(
211+
shouldHaveSlashIndexTagForIndexPage()
212+
? '_N_T_/layout,_N_T_/page,_N_T_/,_N_T_/index'
213+
: '_N_T_/layout,_N_T_/page,_N_T_/',
214+
)
209215
})
210216

211217
// with 15.0.0-canary.187 and later Next.js no longer produce `stale-while-revalidate` directive
@@ -398,7 +404,7 @@ test.skipIf(process.env.NEXT_VERSION !== 'canary')<FixtureTestContext>(
398404
'/1',
399405
'/2',
400406
'/404',
401-
'/[dynamic]',
407+
isExperimentalPPRHardDeprecated() ? undefined : '/[dynamic]',
402408
shouldHaveAppRouterGlobalErrorInPrerenderManifest() ? '/_global-error' : undefined,
403409
shouldHaveAppRouterNotFoundInPrerenderManifest() ? '/_not-found' : undefined,
404410
'/index',

tests/utils/next-version-helpers.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ export function hasDefaultTurbopackBuilds() {
5353
return nextVersionSatisfies('>=15.6.0-canary.40')
5454
}
5555

56+
export function shouldHaveSlashIndexTagForIndexPage() {
57+
// https://github.com/vercel/next.js/pull/84586
58+
return nextVersionSatisfies('>=v15.6.0-canary.50')
59+
}
60+
61+
export function isExperimentalPPRHardDeprecated() {
62+
// https://github.com/vercel/next.js/pull/84280
63+
return nextVersionSatisfies('>=15.6.0-canary.54')
64+
}
65+
5666
/**
5767
* Check if current next version requires React 19
5868
* @param {string} version Next version

0 commit comments

Comments
 (0)