diff --git a/tests/boundary/filesystem/jsonOutputOwnership.test.ts b/tests/boundary/filesystem/jsonOutputOwnership.test.ts index 18928cf71a..9f25d9ef33 100644 --- a/tests/boundary/filesystem/jsonOutputOwnership.test.ts +++ b/tests/boundary/filesystem/jsonOutputOwnership.test.ts @@ -208,10 +208,13 @@ it("preserves cancellation when staging cleanup also fails", async () => { if (result.ok) throw new Error("Expected cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cleanupIncomplete).toBe(true); - expect(result.error.cause).toMatchObject({ - cause: expect.any(AnalysisCancelledError), - owner: { directory: expect.stringContaining(".rea-write-") }, - }); + // The caller's exact abort reason stays the cause; the retained staging + // directory is reported as cleanup state, not as the cancellation cause. + expect(result.error.cause).toBe(controller.signal.reason); + expect(result.error.cleanupPrimary).toBeInstanceOf(AnalysisCancelledError); + expect(result.error.cleanupResources).toEqual([ + expect.stringContaining(".rea-write-"), + ]); await expect(fs.access(join(root, "cancelled.json"))).rejects.toThrow(); const stage = requireStages(root)[0]; if (stage !== undefined) await fs.rm(join(root, stage, "unexpected"));