test(hooks): stabilize session-memory hook tests

This commit is contained in:
Peter Steinberger
2026-02-06 17:18:25 -08:00
parent 80d42eb0ba
commit 4ba9809f18
2 changed files with 14 additions and 10 deletions

View File

@@ -1,10 +1,21 @@
import fs from "node:fs/promises";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { beforeAll, describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "../../../config/config.js";
import type { HookHandler } from "../../hooks.js";
import { makeTempWorkspace, writeWorkspaceFile } from "../../../test-helpers/workspace.js";
import { createHookEvent } from "../../hooks.js";
import handler from "./handler.js";
// Avoid calling the embedded Pi agent (global command lane); keep this unit test deterministic.
vi.mock("../../llm-slug-generator.js", () => ({
generateSlugViaLLM: vi.fn().mockResolvedValue("simple-math"),
}));
let handler: HookHandler;
beforeAll(async () => {
({ default: handler } = await import("./handler.js"));
});
/**
* Create a mock session JSONL file with various entry types