| 722 | } |
| 723 | |
| 724 | function beWaitRouter(args: { |
| 725 | type?: string; |
| 726 | runStatus?: RunResponse['status'] | (() => RunResponse['status']); |
| 727 | result: () => BeResult; |
| 728 | }) { |
| 729 | const counts = { type: 0, result: 0, run: 0 }; |
| 730 | const handler = (url: string) => { |
| 731 | if (url.includes('/tests/test_xyz/result')) { |
| 732 | counts.result += 1; |
| 733 | return { body: args.result() }; |
| 734 | } |
| 735 | if (url.includes('/tests/test_xyz')) { |
| 736 | counts.type += 1; |
| 737 | return { |
| 738 | body: { |
| 739 | id: 'test_xyz', |
| 740 | projectId: 'p1', |
| 741 | name: 'BE test', |
| 742 | type: args.type ?? 'backend', |
| 743 | createdFrom: 'mcp', |
| 744 | status: 'running', |
| 745 | createdAt: '2026-05-15T10:00:00.000Z', |
| 746 | updatedAt: '2026-05-15T10:00:00.000Z', |
| 747 | }, |
| 748 | }; |
| 749 | } |
| 750 | counts.run += 1; |
| 751 | const rs = |
| 752 | typeof args.runStatus === 'function' ? args.runStatus() : (args.runStatus ?? 'running'); |
| 753 | return { body: makeRun(rs) }; |
| 754 | }; |
| 755 | return { handler, counts }; |
| 756 | } |
| 757 | |
| 758 | describe('runTestWait — backend testId fallback (L1888)', () => { |
| 759 | let logSpy: ReturnType<typeof vi.spyOn>; |