























@@ -193,6 +193,10 @@ function expectMemoryConversation(params: {
193193}
194194}
195195196+async function expectPathMissing(targetPath: string): Promise<void> {
197+await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
198+}
199+196200describe("session-memory hook", () => {
197201it("skips non-command events", async () => {
198202const tempDir = await createCaseWorkspace("workspace");
@@ -205,7 +209,7 @@ describe("session-memory hook", () => {
205209206210// Memory directory should not be created for non-command events
207211const memoryDir = path.join(tempDir, "memory");
208-await expect(fs.access(memoryDir)).rejects.toThrow();
212+await expectPathMissing(memoryDir);
209213});
210214211215it("skips commands other than new", async () => {
@@ -219,7 +223,7 @@ describe("session-memory hook", () => {
219223220224// Memory directory should not be created for other commands
221225const memoryDir = path.join(tempDir, "memory");
222-await expect(fs.access(memoryDir)).rejects.toThrow();
226+await expectPathMissing(memoryDir);
223227});
224228225229it("creates memory file with session content on /new command", async () => {
@@ -473,7 +477,7 @@ describe("session-memory hook", () => {
473477expect(memoryContent).toContain("user: Remember this under Navi");
474478expect(memoryContent).toContain("assistant: Stored in the bound workspace");
475479expect(memoryContent).toContain("- **Session Key**: agent:navi:main");
476-await expect(fs.access(path.join(mainWorkspace, "memory"))).rejects.toThrow();
480+await expectPathMissing(path.join(mainWorkspace, "memory"));
477481});
478482479483it("filters out non-message entries (tool calls, system)", async () => {
@@ -768,7 +772,7 @@ describe("session-memory hook", () => {
768772expect(memoryContent).toContain("user: Custom agent conversation");
769773expect(memoryContent).toContain("assistant: Stored in agent workspace");
770774// Verify memory did NOT leak to the default workspace
771-await expect(fs.access(path.join(defaultWorkspace, "memory"))).rejects.toThrow();
775+await expectPathMissing(path.join(defaultWorkspace, "memory"));
772776});
773777774778it("handles session files with fewer messages than requested", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。