| 92 | } |
| 93 | |
| 94 | async function waitForTrailBase(url: string): Promise<void> { |
| 95 | return new Promise<void>((resolve, reject) => { |
| 96 | const timeout = setTimeout(() => { |
| 97 | reject( |
| 98 | new Error(`Timed out waiting for TrailBase to be active at ${url}`), |
| 99 | ) |
| 100 | }, 60000) // 60 seconds timeout for startup |
| 101 | |
| 102 | const check = async (): Promise<void> => { |
| 103 | try { |
| 104 | // Try the healthz endpoint first, then fall back to root |
| 105 | const res = await fetch(`${url}/api/healthcheck`) |
| 106 | if (res.ok) { |
| 107 | clearTimeout(timeout) |
| 108 | return resolve() |
| 109 | } |
| 110 | } catch {} |
| 111 | |
| 112 | setTimeout(() => void check(), 500) |
| 113 | } |
| 114 | |
| 115 | void check() |
| 116 | }) |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Global setup for TrailBase e2e test suite |