diff options
| author | Adam Malczewski <[email protected]> | 2026-05-23 05:06:12 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-05-23 05:06:12 +0900 |
| commit | 9287cccb29d135ea19f2612c26f3090c94820d8c (patch) | |
| tree | 2d68e8cacf6d71786f305d5f4a512a68f19137c5 /packages/api/tests | |
| parent | ef427d3eae77fca716c203dd8bd84939710c518a (diff) | |
| download | dispatch-9287cccb29d135ea19f2612c26f3090c94820d8c.tar.gz dispatch-9287cccb29d135ea19f2612c26f3090c94820d8c.zip | |
feat: add is_subagent flag to agents, fix all lint/type/test issues
- Add is_subagent checkbox to agent editor; subagents are hidden from Chat Settings
- Add is_subagent field to AgentDefinition type, TOML serialization, and API route
- Filter subagents from ModelSelector agent list
- Fix all biome lint/format errors across codebase (useLiteralKeys, noNonNullAssertion, noExplicitAny, formatting, import sorting)
- Fix svelte-check errors (type narrowing in SkillsBrowser, ToolPermissions, SidebarPanel)
- Fix a11y warnings in App.svelte (label-control associations)
- Fix test mocks missing BackgroundShellStore, BackgroundTranscriptStore, createWebSearchTool, createYoutubeTranscribeTool
- Update stale 409 test to match current message-queuing behavior
- Exclude packaging/ and release/ dirs from biome to avoid linting stale build artifacts
Diffstat (limited to 'packages/api/tests')
| -rw-r--r-- | packages/api/tests/agent-manager.test.ts | 32 | ||||
| -rw-r--r-- | packages/api/tests/routes.test.ts | 41 |
2 files changed, 70 insertions, 3 deletions
diff --git a/packages/api/tests/agent-manager.test.ts b/packages/api/tests/agent-manager.test.ts index f8e5e12..b426c4e 100644 --- a/packages/api/tests/agent-manager.test.ts +++ b/packages/api/tests/agent-manager.test.ts @@ -169,6 +169,38 @@ vi.mock("@dispatch/core", () => ({ return null; }, appendMessage() {}, + BackgroundShellStore: class MockBackgroundShellStore { + has() { + return false; + } + getResult() { + return Promise.resolve({ status: "error", error: "not found" }); + } + }, + BackgroundTranscriptStore: class MockBackgroundTranscriptStore { + has() { + return false; + } + getResult() { + return Promise.resolve({ status: "error", error: "not found" }); + } + }, + createWebSearchTool() { + return { + name: "web_search", + description: "web search", + parameters: { _type: "z.ZodObject", shape: {} }, + execute: async () => "mock", + }; + }, + createYoutubeTranscribeTool() { + return { + name: "youtube_transcribe", + description: "youtube transcribe", + parameters: { _type: "z.ZodObject", shape: {} }, + execute: async () => "mock", + }; + }, })); // Import after mock is defined (Vitest hoists vi.mock automatically) diff --git a/packages/api/tests/routes.test.ts b/packages/api/tests/routes.test.ts index 05f8358..c3c7eaa 100644 --- a/packages/api/tests/routes.test.ts +++ b/packages/api/tests/routes.test.ts @@ -170,6 +170,38 @@ vi.mock("@dispatch/core", () => ({ return null; }, appendMessage() {}, + BackgroundShellStore: class MockBackgroundShellStore { + has() { + return false; + } + getResult() { + return Promise.resolve({ status: "error", error: "not found" }); + } + }, + BackgroundTranscriptStore: class MockBackgroundTranscriptStore { + has() { + return false; + } + getResult() { + return Promise.resolve({ status: "error", error: "not found" }); + } + }, + createWebSearchTool() { + return { + name: "web_search", + description: "web search", + parameters: { _type: "z.ZodObject", shape: {} }, + execute: async () => "mock", + }; + }, + createYoutubeTranscribeTool() { + return { + name: "youtube_transcribe", + description: "youtube transcribe", + parameters: { _type: "z.ZodObject", shape: {} }, + execute: async () => "mock", + }; + }, })); const { app } = await import("../src/app.js"); @@ -241,7 +273,7 @@ describe("POST /chat", () => { expect(res.status).toBe(400); }); - it("returns 409 when agent is already running", async () => { + it("queues message when agent is already running", async () => { // Start a message (non-blocking) await app.request("/chat", { method: "POST", @@ -252,12 +284,15 @@ describe("POST /chat", () => { // Small delay to let the async generator start and emit "running" status await new Promise<void>((r) => setTimeout(r, 20)); - // Immediately send a second — agent should be running + // Send a second — agent should queue it const res = await app.request("/chat", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ tabId: "tab-2", message: "second message" }), }); - expect(res.status).toBe(409); + expect(res.status).toBe(200); + const body = await res.json(); + expect(body.status).toBe("queued"); + expect(typeof body.messageId).toBe("string"); }); }); |
