mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 00:50:43 +00:00
test: use vitest polling for session memory
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user