fix(tests): serve.mjs marks immutable by the resolved file's folder, not the request prefix; offline harness kills its server when setup fails

This commit is contained in:
bchanot committed 2026-10-21 00:30:47 +02:00
1 parent 1598b9befe
commit baebb98bc6
3 files changed
+8 -6

No files matched your search

+5 -4
View File
@@ -147,10 +147,11 @@ async function offlineRun(page, context, server, mode) {
/** One engine and mode: its own server, browser and context. */
async function runOne(pw, engine, mode) {
const server = startChildServer()
const baseUrl = await server.url
const headers = await cacheHeaders(baseUrl)
const session = await launchEngine(pw, engine)
let session = null
try {
const baseUrl = await server.url
const headers = await cacheHeaders(baseUrl)
session = await launchEngine(pw, engine)
const context = await session.browser.newContext({ locale: 'fr-FR' })
const seed = { draft: null, locale: 'fr', skipDisclaimer: true }
const { page, events } = await probedPage(context, seed)
@@ -158,7 +159,7 @@ async function runOne(pw, engine, mode) {
const run = await offlineRun(page, context, server, mode)
return { engine, mode, headers, ...run, pageErrors: events.pageErrors }
} finally {
await closeEngine(session)
if (session) await closeEngine(session)
server.child.kill('SIGKILL')
}
}
@@ -24,7 +24,7 @@
"bytes": 8175,
"sha256": "f667c4c5222bc7cd3311da788e3ecd6cf6156a4a9757b21c8730d93463ac5200"
},
"headCommit": "4509313"
"headCommit": "1598b9b"
},
"runs": [
{"engine":"chromium","mode":"emulate","headers":{"envJs":"no-store, no-cache, must-revalidate","workerChunk":"public, max-age=31536000, immutable","asNginx":true},"online":"editor","replaced":true,"offline":"editor","errorText":null,"pageErrors":[],"problems":[]},
+2 -1
View File
@@ -170,7 +170,8 @@ async function route(root, path, mounts) {
return { body: LOCAL_TOOL_ENV_JS, type: MIME['.js'], cache: NO_STORE }
}
const file = await fileUnder(root, path)
if (file && path.startsWith('/assets/')) {
// By where the file lives, not the request's spelling (`/assets/..%2f…`).
if (file && file.startsWith(join(root, 'assets') + sep)) {
return { ...(await fileAnswer(file)), cache: IMMUTABLE }
}
if (file) return fileAnswer(file)