From d134e0669a72460abfdf2c554e57516895adecf0 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 9 May 2026 02:17:58 +0100 Subject: [PATCH] test: dedupe session memory absence assertions --- src/hooks/bundled/session-memory/handler.test.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hooks/bundled/session-memory/handler.test.ts b/src/hooks/bundled/session-memory/handler.test.ts index e48e42a5d64..86b4ec4bbec 100644 --- a/src/hooks/bundled/session-memory/handler.test.ts +++ b/src/hooks/bundled/session-memory/handler.test.ts @@ -193,6 +193,10 @@ function expectMemoryConversation(params: { } } +async function expectPathMissing(targetPath: string): Promise { + 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 () => {