ReviewOS

also looking at this

stacks/drone

test: retain bounded browser launch evidence on failure

#70
Merged chris wants to merge codex/browser-startup-evidence into main
18 files +620 -23
tests/unit/public-safety-execution-browser.test.tsmodified+7-1
Changes to tests/unit/public-safety-execution-browser.test.ts
@@ -7,6 +7,7 @@ import { spawnWorkspaceFixture } from '../helpers/workspace-process'
77test.skipIf(process.env.EXECUTION_BROWSER_QA !== 'true')('compiled execution panel uses real native routes and a genuine Worker', async () => {
88 const directory = await mkdtemp(join(tmpdir(), 'drone-incident-access-'))
99 let owned: ReturnType<typeof spawnWorkspaceFixture> | undefined
10 let passed = false
1011 try {
1112 const config = join(directory, 'bunfig.toml'); await writeFile(config, 'preload=[]\n')
1213 owned = spawnWorkspaceFixture([process.execPath, `--config=${config}`, '--no-env-file', `${import.meta.dir}/../fixtures/public-safety-access/execution-browser.ts`], directory, { ...process.env, APP_ENV: 'test', APP_DEBUG: 'false', NODE_ENV: 'test', DB_CONNECTION: 'sqlite', DB_DATABASE_PATH: join(directory, 'access.sqlite'), STX_DIR: join(directory, 'stx') })
@@ -16,10 +17,15 @@ test.skipIf(process.env.EXECUTION_BROWSER_QA !== 'true')('compiled execution pan
1617 const [code, stdout, stderr] = await Promise.all([child.exited, new Response(child.stdout as ReadableStream).text(), new Response(child.stderr as ReadableStream).text()])
1718 expect(code, `${stdout}\n${stderr}`).toBe(0)
1819 expect(stdout).toContain('PASS actual execution browser: native live-before-return')
20 passed = true
1921 }
2022 finally { clearTimeout(timeout) }
2123 }
22 finally { await owned?.stop(); await rm(directory, { recursive: true, force: true }) }
24 finally {
25 await owned?.stop()
26 if (passed) await rm(directory, { recursive: true, force: true })
27 else console.log(JSON.stringify({ evidence: 'retained-private-browser-fixture', directory }))
28 }
2329}, 110000)
2430
2531test('execution browser fixture refuses an unguarded directory before database or application writes', async () => {