also looking at this
test: label native browser transport failures
#66
7 files
+177
-11
| @@ -2,17 +2,15 @@ import assert from 'node:assert/strict' | ||
| 2 | 2 | import { mkdir, readFile, writeFile } from 'node:fs/promises' |
| 3 | 3 | import { basename, join } from 'node:path' |
| 4 | 4 | import { startWorkspaceBrowser } from './workspace-browser' |
| 5 | import type { BrowserControlAction } from './browser-operation' | |
| 6 | import { requestWorkspaceControl } from './workspace-control' | |
| 5 | 7 | |
| 6 | 8 | // Controller is isolated from native Auth/SQLite and reads owner-only fixture credentials. |
| 7 | 9 | const root = process.cwd() |
| 8 | 10 | assert(basename(root).startsWith('drone-incident-access-')) |
| 9 | 11 | const data = JSON.parse(await readFile(join(root, 'credentials.json'), 'utf8')) as { url: string, key: string, sourceDigest: string, senderToken: string, recipientToken: string, recipientId: number, control: string, capture: { id: string, width: number }, pixel: number } |
| 10 | 12 | assert(/^http:\/\/127\.0\.0\.1:\d+$/.test(data.url)) |
| 11 | const control = async (action: string): Promise<any> => { | |
| 12 | const response = await fetch(`${data.url}/__fixture/${action}`, { method: 'GET', headers: { 'x-fixture-control': data.control }, signal: AbortSignal.timeout(5000) }) | |
| 13 | assert(response.ok, `Private fixture control must succeed: ${action}, ${response.status}`) | |
| 14 | return response.json() | |
| 15 | } | |
| 13 | const control = async (action: BrowserControlAction): Promise<any> => requestWorkspaceControl(data, action) | |
| 16 | 14 | const browser = await startWorkspaceBrowser(root) |
| 17 | 15 | const evidence = process.env.WORKSPACE_BROWSER_EVIDENCE ?? join(root, 'evidence') |
| 18 | 16 | await mkdir(evidence, { recursive: true }) |