(assertion: () => void)
| 14 | // The actual post-compaction state computation is covered elsewhere. |
| 15 | |
| 16 | async function waitForCondition(assertion: () => void): Promise<void> { |
| 17 | const deadline = Date.now() + 1000; |
| 18 | let lastError: unknown; |
| 19 | |
| 20 | while (Date.now() < deadline) { |
| 21 | try { |
| 22 | assertion(); |
| 23 | return; |
| 24 | } catch (error) { |
| 25 | lastError = error; |
| 26 | await new Promise((resolve) => setTimeout(resolve, 10)); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | try { |
| 31 | assertion(); |
| 32 | } catch (error) { |
| 33 | if (error instanceof Error) throw error; |
| 34 | throw new Error(String(error)); |
| 35 | } |
| 36 | |
| 37 | if (lastError instanceof Error) throw lastError; |
| 38 | if (lastError != null) throw new Error("condition failed with non-Error value"); |
| 39 | } |
| 40 | |
| 41 | describe("AgentSession post-compaction refresh trigger", () => { |
| 42 | let historyCleanup: (() => Promise<void>) | undefined; |
no outgoing calls
no test coverage detected