Unverified Commit bbd0abe8 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

[test] Fix failing determinism test using adapter (#95051)

https://github.com/nextjs/adapter-vercel/pull/70 broke the test

Instead, read the test-only `__NEXT_SUPPORTS_IMMUTABLE_ASSETS` after
modifyConfig.
parent 79142d78
...@@ -1154,17 +1154,6 @@ function assignDefaultsAndValidate( ...@@ -1154,17 +1154,6 @@ function assignDefaultsAndValidate(
result.deploymentId = process.env.NEXT_DEPLOYMENT_ID result.deploymentId = process.env.NEXT_DEPLOYMENT_ID
} }
// Only read process.env.__NEXT_IMMUTABLE_ASSET_TOKEN to make our testing setup easier. This is
// actually done by the adapter's modifyConfig
if (
process.env.__NEXT_TEST_MODE &&
process.env.IS_TURBOPACK_TEST &&
result.deploymentId &&
process.env.__NEXT_SUPPORTS_IMMUTABLE_ASSETS
) {
result.experimental.supportsImmutableAssets = true
}
if (process.env.NEXT_HASH_SALT) { if (process.env.NEXT_HASH_SALT) {
result.experimental.outputHashSalt = result.experimental.outputHashSalt =
(result.experimental.outputHashSalt ?? '') + process.env.NEXT_HASH_SALT (result.experimental.outputHashSalt ?? '') + process.env.NEXT_HASH_SALT
...@@ -1669,6 +1658,18 @@ function finalizeConfig(config: NextConfigComplete): NextConfigComplete { ...@@ -1669,6 +1658,18 @@ function finalizeConfig(config: NextConfigComplete): NextConfigComplete {
validationLevel: validationLevel:
config.experimental.instantInsights?.validationLevel ?? 'warning', config.experimental.instantInsights?.validationLevel ?? 'warning',
} }
// Only read process.env.__NEXT_IMMUTABLE_ASSET_TOKEN to make our testing setup easier. In the
// real world, this is done by the adapter's modifyConfig
if (
process.env.__NEXT_TEST_MODE &&
process.env.IS_TURBOPACK_TEST &&
config.deploymentId &&
process.env.__NEXT_SUPPORTS_IMMUTABLE_ASSETS
) {
config.experimental.supportsImmutableAssets = true
}
return config return config
} }
......
...@@ -25,12 +25,11 @@ const IGNORE_CONTENT_NEXT_REGEX = new RegExp( ...@@ -25,12 +25,11 @@ const IGNORE_CONTENT_NEXT_REGEX = new RegExp(
.join('|') .join('|')
) )
const IGNORE = /(^|\/)(trace|trace-build)$/
async function readFilesNext( async function readFilesNext(
next: NextInstance next: NextInstance
): Promise<Map<string, Map<string, string>>> { ): Promise<Map<string, Map<string, string>>> {
// These are cosmetic files which aren't deployed.
const IGNORE = /^trace$|^trace-build$/
const files = ( const files = (
(await glob('**/*', { (await glob('**/*', {
cwd: path.join(next.testDir, next.distDir), cwd: path.join(next.testDir, next.distDir),
...@@ -66,9 +65,28 @@ async function readFilesBuilder( ...@@ -66,9 +65,28 @@ async function readFilesBuilder(
nodir: true, nodir: true,
})) as string[] })) as string[]
).sort() ).sort()
const statics = (
(await glob('.vercel/output/static/**/*', {
cwd: next.testDir,
nodir: true,
})) as string[]
)
.sort()
// HTML Prerenders contain `<html data-dpl-id="foo-dpl-id">`
.filter((f) => !f.endsWith('.html') && !IGNORE.test(f))
return new Map( return new Map([
[
'static' as string,
new Map(
await Promise.all( await Promise.all(
statics.map(async (f) => {
return [f, await next.readFile(f)] as const
})
)
),
] as const,
...(await Promise.all(
functions.map(async (fn) => { functions.map(async (fn) => {
let config = await next.readJSON(fn) let config = await next.readJSON(fn)
let fnDir = path.dirname(fn) let fnDir = path.dirname(fn)
...@@ -111,8 +129,8 @@ async function readFilesBuilder( ...@@ -111,8 +129,8 @@ async function readFilesBuilder(
), ),
] as const ] as const
}) })
) )),
) ])
} }
async function runTest( async function runTest(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment