test: use vitest polling for session memory

This commit is contained in:
Shakker
2026-05-09 00:52:58 +01:00
parent 6aa7e371e4
commit 34649d3257

View File

@@ -193,16 +193,6 @@ function expectMemoryConversation(params: {
}
}
async function waitUntil(condition: () => boolean, timeoutMs = 500): Promise<void> {
const deadline = Date.now() + timeoutMs;
while (!condition()) {
if (Date.now() > deadline) {
throw new Error("condition was not met before timeout");
}
await new Promise((resolve) => setTimeout(resolve, 5));
}
}
describe("session-memory hook", () => {
it("skips non-command events", async () => {
const tempDir = await createCaseWorkspace("workspace");
@@ -370,7 +360,7 @@ describe("session-memory hook", () => {
await handler(event);
expect(Date.now() - startedAt).toBeLessThan(100);
await waitUntil(() => generateSlug.mock.calls.length === 1);
await vi.waitFor(() => expect(generateSlug).toHaveBeenCalledTimes(1), { interval: 1 });
resolveSlug?.("slow-reset");
await flushSessionMemoryWritesForTest();