test(ai-chat): stub sandboxStore.asSink in AiChatToolsService spec

The blob-sandbox feature (#243/#250) made AiChatToolsService.forUser()
eagerly call this.sandboxStore.asSink() while wiring the stash tool, but
the spec still passed an empty {} as the sandboxStore constructor arg.
That object has no asSink method, so all 19 tests in the suite failed in
CI with 'TypeError: this.sandboxStore.asSink is not a function'.

Replace the stale {} mock at all 4 constructor sites with a no-op sink
exposing asSink() -> { put, has, evict } (jest.fn()). These tests never
execute the stash tool, so a no-op sink is sufficient for forUser() to
wire successfully. Test-only change; production code is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
claude_code
2026-06-28 23:45:06 +03:00
parent 6daa10db67
commit 62eb7d082f

View File

@@ -63,9 +63,12 @@ describe('AiChatToolsService deletePage guardrail (H4)', () => {
{} as never,
{} as never,
{} as never,
// sandboxStore (only used by the stash tool closure, which these tests do
// not execute).
{} as never,
// sandboxStore: forUser() eagerly calls asSink() to wire the stash tool,
// even though these tests never execute it — return a no-op sink so the
// tool wiring in forUser() succeeds.
{
asSink: () => ({ put: jest.fn(), has: jest.fn(), evict: jest.fn() }),
} as never,
);
});
@@ -178,9 +181,12 @@ describe('AiChatToolsService expanded toolset guardrails', () => {
{} as never,
{} as never,
{} as never,
// sandboxStore (only used by the stash tool closure, which these tests do
// not execute).
{} as never,
// sandboxStore: forUser() eagerly calls asSink() to wire the stash tool,
// even though these tests never execute it — return a no-op sink so the
// tool wiring in forUser() succeeds.
{
asSink: () => ({ put: jest.fn(), has: jest.fn(), evict: jest.fn() }),
} as never,
);
});
@@ -296,9 +302,12 @@ describe('AiChatToolsService node-arg JSON-string coercion', () => {
{} as never,
{} as never,
{} as never,
// sandboxStore (only used by the stash tool closure, which these tests do
// not execute).
{} as never,
// sandboxStore: forUser() eagerly calls asSink() to wire the stash tool,
// even though these tests never execute it — return a no-op sink so the
// tool wiring in forUser() succeeds.
{
asSink: () => ({ put: jest.fn(), has: jest.fn(), evict: jest.fn() }),
} as never,
);
});
@@ -449,9 +458,12 @@ describe('AiChatToolsService model-friendly input validation (#190)', () => {
{} as never,
{} as never,
{} as never,
// sandboxStore (only used by the stash tool closure, which these tests do
// not execute).
{} as never,
// sandboxStore: forUser() eagerly calls asSink() to wire the stash tool,
// even though these tests never execute it — return a no-op sink so the
// tool wiring in forUser() succeeds.
{
asSink: () => ({ put: jest.fn(), has: jest.fn(), evict: jest.fn() }),
} as never,
);
});