| 71 | } |
| 72 | |
| 73 | async function waitForRouterWorkflowStatus( |
| 74 | client: { |
| 75 | workflows: { |
| 76 | getRun(input: { workspaceId: string; runId: string }): Promise<{ status: string } | null>; |
| 77 | }; |
| 78 | }, |
| 79 | workspaceId: string, |
| 80 | runId: string, |
| 81 | status: string |
| 82 | ): Promise<void> { |
| 83 | const deadline = Date.now() + 1_000; |
| 84 | while (Date.now() < deadline) { |
| 85 | const run = await client.workflows.getRun({ workspaceId, runId }); |
| 86 | if (run?.status === status) { |
| 87 | return; |
| 88 | } |
| 89 | await new Promise((resolve) => setTimeout(resolve, 10)); |
| 90 | } |
| 91 | const run = await client.workflows.getRun({ workspaceId, runId }); |
| 92 | throw new Error(`Timed out waiting for ${runId} to become ${status}; got ${run?.status}`); |
| 93 | } |
| 94 | |
| 95 | describe("router workflow routes", () => { |
| 96 | let tempDir: string; |