From 7000f34c484c3d9b98f098bfdce5acc8744ff8b9 Mon Sep 17 00:00:00 2001 From: Ramnique Singh <30795890+ramnique@users.noreply.github.com> Date: Tue, 7 Jul 2026 21:02:03 +0530 Subject: [PATCH] test(core): fix type errors in the elision test suite The resolver helper's inline policy type predated middlePaneContent and no longer satisfied ElisionPolicy; use the exported type. Coerce message content to string where the preview assertions call string methods. Co-Authored-By: Claude Fable 5 --- .../core/src/turns/context-elision.test.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/apps/x/packages/core/src/turns/context-elision.test.ts b/apps/x/packages/core/src/turns/context-elision.test.ts index bb844aa6..2e3d51f3 100644 --- a/apps/x/packages/core/src/turns/context-elision.test.ts +++ b/apps/x/packages/core/src/turns/context-elision.test.ts @@ -12,6 +12,7 @@ import { elideHistoricMiddlePaneContent, elideHistoricToolResults, loadElisionPolicy, + type ElisionPolicy, } from "./context-elision.js"; import { TurnRepoContextResolver } from "./context-resolver.js"; import { InMemoryTurnRepo } from "./in-memory-turn-repo.js"; @@ -189,12 +190,14 @@ describe("elideHistoricToolResults", () => { const content = `SKILL GUIDE${"y".repeat(5000)}`; const [elided] = elideHistoricToolResults([toolMsg(content)], 2500); // Starts with the first 400 chars verbatim, then the marker. - expect(elided.content.startsWith(content.slice(0, 400))).toBe(true); + expect(String(elided.content).startsWith(content.slice(0, 400))).toBe(true); expect(elided.content).toContain("Rest of tool result elided"); - expect(elided.content.length).toBeLessThan(700); + expect(String(elided.content).length).toBeLessThan(700); // Preview never exceeds a tiny threshold. const [tiny] = elideHistoricToolResults([toolMsg(content)], 50); - expect(tiny.content.startsWith(`${content.slice(0, 50)}\n[Rest`)).toBe(true); + expect(String(tiny.content).startsWith(`${content.slice(0, 50)}\n[Rest`)).toBe( + true, + ); }); it("keeps tool results at or below the threshold verbatim", () => { @@ -340,14 +343,7 @@ describe("createContextResolver", () => { }); describe("ElidingContextResolver", () => { - function resolver( - repo: InMemoryTurnRepo, - policy: { - toolResults: boolean; - toolResultThresholdChars: number; - images: boolean; - }, - ) { + function resolver(repo: InMemoryTurnRepo, policy: ElisionPolicy) { return new ElidingContextResolver({ inner: new TurnRepoContextResolver({ turnRepo: repo }), loadPolicy: () => policy,