mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 11:50:43 +00:00
test: dedupe session memory absence assertions
This commit is contained in:
@@ -193,6 +193,10 @@ function expectMemoryConversation(params: {
|
||||
}
|
||||
}
|
||||
|
||||
async function expectPathMissing(targetPath: string): Promise<void> {
|
||||
await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
}
|
||||
|
||||
describe("session-memory hook", () => {
|
||||
it("skips non-command events", async () => {
|
||||
const tempDir = await createCaseWorkspace("workspace");
|
||||
@@ -205,7 +209,7 @@ describe("session-memory hook", () => {
|
||||
|
||||
// Memory directory should not be created for non-command events
|
||||
const memoryDir = path.join(tempDir, "memory");
|
||||
await expect(fs.access(memoryDir)).rejects.toThrow();
|
||||
await expectPathMissing(memoryDir);
|
||||
});
|
||||
|
||||
it("skips commands other than new", async () => {
|
||||
@@ -219,7 +223,7 @@ describe("session-memory hook", () => {
|
||||
|
||||
// Memory directory should not be created for other commands
|
||||
const memoryDir = path.join(tempDir, "memory");
|
||||
await expect(fs.access(memoryDir)).rejects.toThrow();
|
||||
await expectPathMissing(memoryDir);
|
||||
});
|
||||
|
||||
it("creates memory file with session content on /new command", async () => {
|
||||
@@ -473,7 +477,7 @@ describe("session-memory hook", () => {
|
||||
expect(memoryContent).toContain("user: Remember this under Navi");
|
||||
expect(memoryContent).toContain("assistant: Stored in the bound workspace");
|
||||
expect(memoryContent).toContain("- **Session Key**: agent:navi:main");
|
||||
await expect(fs.access(path.join(mainWorkspace, "memory"))).rejects.toThrow();
|
||||
await expectPathMissing(path.join(mainWorkspace, "memory"));
|
||||
});
|
||||
|
||||
it("filters out non-message entries (tool calls, system)", async () => {
|
||||
@@ -768,7 +772,7 @@ describe("session-memory hook", () => {
|
||||
expect(memoryContent).toContain("user: Custom agent conversation");
|
||||
expect(memoryContent).toContain("assistant: Stored in agent workspace");
|
||||
// Verify memory did NOT leak to the default workspace
|
||||
await expect(fs.access(path.join(defaultWorkspace, "memory"))).rejects.toThrow();
|
||||
await expectPathMissing(path.join(defaultWorkspace, "memory"));
|
||||
});
|
||||
|
||||
it("handles session files with fewer messages than requested", async () => {
|
||||
|
||||
Reference in New Issue
Block a user