( received: Record<string, unknown>[], pred: (f: Record<string, unknown>) => boolean, timeoutMs = 2000, )
| 167 | } |
| 168 | |
| 169 | async function waitFor( |
| 170 | received: Record<string, unknown>[], |
| 171 | pred: (f: Record<string, unknown>) => boolean, |
| 172 | timeoutMs = 2000, |
| 173 | ): Promise<Record<string, unknown>> { |
| 174 | const start = Date.now(); |
| 175 | while (Date.now() - start < timeoutMs) { |
| 176 | const hit = received.find(pred); |
| 177 | if (hit !== undefined) return hit; |
| 178 | await new Promise((r) => setTimeout(r, 10)); |
| 179 | } |
| 180 | throw new Error( |
| 181 | `waitFor timed out; received: ${received.map((f) => f['type']).join(', ')}`, |
| 182 | ); |
| 183 | } |
| 184 | |
| 185 | describe('WS abort control message (W7.3 / Chain 4b)', () => { |
| 186 | it('on first abort: ack with aborted:true + broadcast prompt.aborted', async () => { |
no test coverage detected