diff --git a/tests/integration/cache-handler.test.ts b/tests/integration/cache-handler.test.ts index b3910f8e62..7eaf6b70c5 100644 --- a/tests/integration/cache-handler.test.ts +++ b/tests/integration/cache-handler.test.ts @@ -17,7 +17,10 @@ import { getBlobEntries, startMockBlobStore, } from '../utils/helpers.js' -import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs' +import { + nextVersionSatisfies, + shouldHaveAppRouterNotFoundInPrerenderManifest, +} from '../utils/next-version-helpers.mjs' // Disable the verbose logging of the lambda-local runtime getLogger().level = 'alert' @@ -212,14 +215,17 @@ describe('app router', () => { console.timeEnd('runPlugin') // check if the blob entries where successful set on the build plugin const blobEntries = await getBlobEntries(ctx) - expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual([ - '/404', - '/index', - '/posts/1', - '/posts/2', - '404.html', - '500.html', - ]) + expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual( + [ + '/404', + shouldHaveAppRouterNotFoundInPrerenderManifest() ? '/_not-found' : undefined, + '/index', + '/posts/1', + '/posts/2', + '404.html', + '500.html', + ].filter(Boolean), + ) // test the function call const post1 = await invokeFunction(ctx, { url: 'posts/1' }) @@ -362,23 +368,26 @@ describe('plugin', () => { await runPlugin(ctx) // check if the blob entries where successful set on the build plugin const blobEntries = await getBlobEntries(ctx) - expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual([ - '/404', - '/api/revalidate-handler', - '/api/static/first', - '/api/static/second', - '/api/zero-length-response', - '/index', - '/product/事前レンダリング,test', - '/revalidate-fetch', - '/static-fetch-1', - '/static-fetch-2', - '/static-fetch-3', - '/static-fetch/1', - '/static-fetch/2', - '404.html', - '500.html', - ]) + expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual( + [ + '/404', + shouldHaveAppRouterNotFoundInPrerenderManifest() ? '/_not-found' : undefined, + '/api/revalidate-handler', + '/api/static/first', + '/api/static/second', + '/api/zero-length-response', + '/index', + '/product/事前レンダリング,test', + '/revalidate-fetch', + '/static-fetch-1', + '/static-fetch-2', + '/static-fetch-3', + '/static-fetch/1', + '/static-fetch/2', + '404.html', + '500.html', + ].filter(Boolean), + ) }) }) diff --git a/tests/integration/simple-app.test.ts b/tests/integration/simple-app.test.ts index 6fc02f387c..f70eed2871 100644 --- a/tests/integration/simple-app.test.ts +++ b/tests/integration/simple-app.test.ts @@ -34,7 +34,10 @@ import { getBlobEntries, startMockBlobStore, } from '../utils/helpers.js' -import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs' +import { + nextVersionSatisfies, + shouldHaveAppRouterNotFoundInPrerenderManifest, +} from '../utils/next-version-helpers.mjs' const mockedCp = cp as Mock<(typeof import('node:fs/promises'))['cp']> @@ -95,26 +98,29 @@ test('Test that the simple next app is working', async (ctx) await runPlugin(ctx) // check if the blob entries where successful set on the build plugin const blobEntries = await getBlobEntries(ctx) - expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual([ - '/404', - '/api/cached-permanent', - '/api/cached-revalidate', - '/config-redirect', - '/config-redirect/dest', - '/config-rewrite', - '/config-rewrite/dest', - '/image/local', - '/image/migration-from-v4-runtime', - '/image/remote-domain', - '/image/remote-pattern-1', - '/image/remote-pattern-2', - '/index', - '/other', - '/route-resolves-to-not-found', - '404.html', - '500.html', - 'fully-static.html', - ]) + expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual( + [ + '/404', + shouldHaveAppRouterNotFoundInPrerenderManifest() ? '/_not-found' : undefined, + '/api/cached-permanent', + '/api/cached-revalidate', + '/config-redirect', + '/config-redirect/dest', + '/config-rewrite', + '/config-rewrite/dest', + '/image/local', + '/image/migration-from-v4-runtime', + '/image/remote-domain', + '/image/remote-pattern-1', + '/image/remote-pattern-2', + '/index', + '/other', + '/route-resolves-to-not-found', + '404.html', + '500.html', + 'fully-static.html', + ].filter(Boolean), + ) // test the function call const home = await invokeFunction(ctx) @@ -385,12 +391,15 @@ test.skipIf(process.env.NEXT_VERSION !== 'canary')( await runPlugin(ctx) // check if the blob entries where successful set on the build plugin const blobEntries = await getBlobEntries(ctx) - expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual([ - '/404', - '/index', - '404.html', - '500.html', - ]) + expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual( + [ + '/404', + shouldHaveAppRouterNotFoundInPrerenderManifest() ? '/_not-found' : undefined, + '/index', + '404.html', + '500.html', + ].filter(Boolean), + ) // test the function call const home = await invokeFunction(ctx) diff --git a/tests/utils/next-version-helpers.mjs b/tests/utils/next-version-helpers.mjs index b462517b21..b9bffcc28c 100644 --- a/tests/utils/next-version-helpers.mjs +++ b/tests/utils/next-version-helpers.mjs @@ -24,6 +24,20 @@ export function nextVersionSatisfies(condition) { return satisfies(checkVersion, condition, { includePrerelease: true }) || version === condition } +export function isNextCanary() { + return [process.env.NEXT_RESOLVED_VERSION, process.env.NEXT_VERSION].some((tagOrVersionOrEmpty) => + tagOrVersionOrEmpty?.includes('canary'), + ) +} + +export function shouldHaveAppRouterNotFoundInPrerenderManifest() { + // https://github.com/vercel/next.js/pull/82199 + + // The canary versions are out of band, as there stable/latest patch versions higher than base of canary versions + // and change was not backported to stable versions + return nextVersionSatisfies('>=15.4.2-canary.33') && isNextCanary() +} + /** * Check if current next version requires React 19 * @param {string} version Next version