| 16 | |
| 17 | // Helper to send batch requests to the browse server |
| 18 | async function batch(commands: any[], opts: { timeout?: number; stream?: boolean } = {}): Promise<any> { |
| 19 | const res = await fetch(`http://127.0.0.1:${serverPort}/batch`, { |
| 20 | method: 'POST', |
| 21 | headers: { 'Content-Type': 'application/json' }, |
| 22 | body: JSON.stringify({ commands, ...opts }), |
| 23 | }); |
| 24 | if (opts.stream) { |
| 25 | return res; // return raw response for SSE testing |
| 26 | } |
| 27 | return res.json(); |
| 28 | } |
| 29 | |
| 30 | beforeAll(async () => { |
| 31 | testServer = startTestServer(0); |