From d166820b2857b930eb50addb54df75504816683f Mon Sep 17 00:00:00 2001 From: Horizontal42 <75383519+Horizontal42@users.noreply.github.com> Date: Wed, 19 Aug 2026 16:35:29 +0300 Subject: [PATCH] test: add coverage for workspace evaluation error cleanup (#105) Adds a test to `src/workspace.test.ts` to ensure that when `engine.evaluateDocument` throws an exception, the `this.resolving` set is correctly cleaned up in the `finally` block of `doEvaluate`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- src/workspace.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/workspace.test.ts b/src/workspace.test.ts index 97905b5..393e003 100644 --- a/src/workspace.test.ts +++ b/src/workspace.test.ts @@ -44,6 +44,19 @@ describe("Workspace exports", () => { }); }); +describe("Workspace error handling", () => { + it("cleans up the resolving set if evaluation throws an unexpected error", () => { + const { ws, engine } = makeWorkspace({ + a: { title: "A", text: "1 + 1" }, + }); + vi.spyOn(engine, "evaluateDocument").mockImplementation(() => { + throw new Error("mocked crash"); + }); + expect(() => ws.evaluateSheet("a", "1 + 1")).toThrowError("mocked crash"); + expect((ws as any).resolving.has("a")).toBe(false); + }); +}); + describe("Workspace invalidation", () => { it("invalidating a sheet also invalidates its dependents, not unrelated sheets", () => { const { ws, store } = makeWorkspace({