| 17 | const SESSION_HOOK = path.join(PLUGIN_ROOT, "scripts", "session-lifecycle-hook.mjs"); |
| 18 | |
| 19 | async function waitFor(predicate, { timeoutMs = 5000, intervalMs = 50 } = {}) { |
| 20 | const start = Date.now(); |
| 21 | while (Date.now() - start < timeoutMs) { |
| 22 | const value = await predicate(); |
| 23 | if (value) { |
| 24 | return value; |
| 25 | } |
| 26 | await new Promise((resolve) => setTimeout(resolve, intervalMs)); |
| 27 | } |
| 28 | throw new Error("Timed out waiting for condition."); |
| 29 | } |
| 30 | |
| 31 | test("setup reports ready when fake codex is installed and authenticated", () => { |
| 32 | const binDir = makeTempDir(); |