( received: Record<string, unknown>[], pred: (f: Record<string, unknown>) => boolean, timeoutMs = 2000, )
| 244 | } |
| 245 | |
| 246 | async function waitFor( |
| 247 | received: Record<string, unknown>[], |
| 248 | pred: (f: Record<string, unknown>) => boolean, |
| 249 | timeoutMs = 2000, |
| 250 | ): Promise<Record<string, unknown>> { |
| 251 | const start = Date.now(); |
| 252 | while (Date.now() - start < timeoutMs) { |
| 253 | const hit = received.find(pred); |
| 254 | if (hit !== undefined) return hit; |
| 255 | await new Promise((r) => setTimeout(r, 10)); |
| 256 | } |
| 257 | throw new Error( |
| 258 | `waitFor timed out; received: ${received.map((f) => f['type']).join(', ')}`, |
| 259 | ); |
| 260 | } |
| 261 | |
| 262 | describe('POST /api/v1/sessions/{sid}/prompts — submit validation (W7.2 / Chain 4)', () => { |
| 263 | it('rejects an empty content array with 40001', async () => { |
no test coverage detected