DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
test(web): smoke coverage for StandaloneComposer send gating (#1744)
evan188199-techf2ce12cef39a
diff --git a/evidence/test-standalone-composer-20261003/summary.md b/evidence/test-standalone-composer-20261003/summary.mdnew file mode 100644index 000000000..96aee7d75--- /dev/null+++ b/evidence/test-standalone-composer-20261003/summary.md@@ -0,0 +1,41 @@+# StandaloneComposer smoke coverage — 2026-10-03++Closes the 0% statement-coverage gap on `web/components/chat/home/StandaloneComposer.tsx`+(395/395 statements missed, Top-3 entry in `evidence/coverage-2026-10-02/frontend/summary.md`+on branch `audit/coverage-gaps-20261003`).++## What was added++- `web/tests/chat/StandaloneComposer.smoke.spec.tsx` — 4 vitest tests driving the+ composer's own state pool through the `onSend` prop it hands to `ChatComposer`+ (shell stubbed, pickers and network modules mocked):++| # | Behavior pinned | Guard under test |+|---|---|---|+| 1 | Empty / whitespace-only input never submits | `!content.trim() && !hasReferences` early return |+| 2 | Text submits once with the full payload; a follow-up empty send stays refused | submission shape + one-shot state consumption |+| 3 | Send locked while `isStreaming` | `isStreaming && !awaitingUserReply` early return |+| 4 | ask_user answer passes the lock | `awaitingUserReply` exception |++## Numbers++| Run | Command (from `web/`) | Result |+|---|---|---|+| New file | `npx vitest run tests/chat/StandaloneComposer.smoke.spec.tsx` | 1 file / **4 passed** (0.6s) |+| Full unit suite | `npx vitest run` | 114 files / **475 passed** (18.9s), 0 failed |++Other checks: `eslint tests/chat/StandaloneComposer.smoke.spec.tsx` clean;+`npm run typecheck` clean. No product code changed — the diff adds the test file+and this evidence only.++## Deviation from the card++The card named `StandaloneComposer.smoke.test.tsx`; the web vitest config only+collects `tests/**/*.spec.ts(x)`, so a `.test.tsx` file would never run+(verified: `vitest run` reports "No test files found"). The file is therefore+`StandaloneComposer.smoke.spec.tsx`, matching repo convention.++## Files++- `vitest-smoke-run.txt` — targeted run output+- `vitest-full-run.txt` — full suite outputdiff --git a/evidence/test-standalone-composer-20261003/vitest-full-run.txt b/evidence/test-standalone-composer-20261003/vitest-full-run.txtnew file mode 100644index 000000000..bcd4e5b48--- /dev/null+++ b/evidence/test-standalone-composer-20261003/vitest-full-run.txt@@ -0,0 +1,9 @@++ RUN v4.1.11 /Users/xzh/services/ai-development/multica-pilot/workspaces/agents-plan-5fede2af789a/agen-444-776ec44ad184/workdir/dt-agen444-wt/web+++ Test Files 114 passed (114)+ Tests 475 passed (475)+ Start at 23:26:02+ Duration 18.91s (transform 12.78s, setup 27.34s, import 31.09s, tests 29.14s, environment 101.33s)+diff --git a/evidence/test-standalone-composer-20261003/vitest-smoke-run.txt b/evidence/test-standalone-composer-20261003/vitest-smoke-run.txtnew file mode 100644index 000000000..cf5beac34--- /dev/null+++ b/evidence/test-standalone-composer-20261003/vitest-smoke-run.txt@@ -0,0 +1,9 @@++ RUN v4.1.11 /Users/xzh/services/ai-development/multica-pilot/workspaces/agents-plan-5fede2af789a/agen-444-776ec44ad184/workdir/dt-agen444-wt/web+++ Test Files 1 passed (1)+ Tests 4 passed (4)+ Start at 23:25:32+ Duration 644ms (transform 152ms, setup 78ms, import 211ms, tests 21ms, environment 271ms)+diff --git a/web/tests/chat/StandaloneComposer.smoke.spec.tsx b/web/tests/chat/StandaloneComposer.smoke.spec.tsxnew file mode 100644index 000000000..1da575b50--- /dev/null+++ b/web/tests/chat/StandaloneComposer.smoke.spec.tsx@@ -0,0 +1,183 @@+import { act, render } from "@testing-library/react";+import { beforeEach, describe, expect, it, vi } from "vitest";++import { initI18n } from "@/i18n/init";++initI18n("en");++/**+ * Smoke coverage for the state pool `StandaloneComposer` owns behind the+ * stateless `ChatComposer`: the empty-input guard, the happy-path send+ * payload, and the streaming lock (with its ask_user escape hatch). The+ * composer shell itself is stood in by a stub that records the props, so+ * these tests pin the pool's decisions, not the presentation.+ */+const harness = vi.hoisted(() => ({+ submitted: vi.fn(),+ composerProps: null as Record<string, unknown> | null,+}));++vi.mock("@/components/chat/home/ChatComposer", () => ({+ default: (props: Record<string, unknown>) => {+ harness.composerProps = props;+ return null;+ },+}));++vi.mock("@/features/knowledge/api/catalog", async (importOriginal) => ({+ ...(await importOriginal<+ typeof import("@/features/knowledge/api/catalog")+ >()),+ listKnowledgeBases: vi.fn(async () => []),+}));++vi.mock("@/lib/llm-options", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@/lib/llm-options")>()),+ listLLMOptions: vi.fn(async () => ({ options: [], active: null })),+}));++vi.mock("@/lib/subagents-api", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@/lib/subagents-api")>()),+ getSubagentSettings: vi.fn(async () => ({ consult_budget: 3 })),+}));++vi.mock("@/lib/attachment-limits", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@/lib/attachment-limits")>()),+ useAttachmentLimits: () => ({+ maxFileBytes: 50 * 1024 * 1024,+ maxTotalBytes: 200 * 1024 * 1024,+ }),+}));++vi.mock("@/components/notebook/NotebookRecordPicker", () => ({+ default: () => null,+}));+vi.mock("@/components/chat/HistorySessionPicker", () => ({+ default: () => null,+}));+vi.mock("@/components/chat/QuestionBankPicker", () => ({+ default: () => null,+}));+vi.mock("@/components/chat/PersonaPicker", () => ({ default: () => null }));+vi.mock("@/components/chat/MemoryPicker", () => ({ default: () => null }));+vi.mock("@/components/chat/BookReferencePicker", () => ({+ default: () => null,+}));+vi.mock("@/components/chat/home/CapabilityConfigCard", () => ({+ default: () => null,+}));+vi.mock("@/components/quiz/QuizConfigPanel", () => ({ default: () => null }));+vi.mock("@/components/visualize/VisualizeConfigPanel", () => ({+ default: () => null,+}));+vi.mock("@/components/research/ResearchConfigPanel", () => ({+ default: () => null,+}));++const { default: StandaloneComposer } = await import(+ "@/components/chat/home/StandaloneComposer"+);++type ComposerSend = (content: string) => Promise<void> | void;++async function mount(+ overrides: { isStreaming?: boolean; awaitingUserReply?: boolean } = {},+): Promise<{ onSend: ComposerSend }> {+ await act(async () => {+ render(+ <StandaloneComposer+ onSubmit={harness.submitted}+ onCancelStreaming={() => undefined}+ isStreaming={overrides.isStreaming ?? false}+ awaitingUserReply={overrides.awaitingUserReply ?? false}+ hasMessages={false}+ inputPlaceholder="Ask"+ />,+ );+ });+ return {+ onSend: harness.composerProps!.onSend as ComposerSend,+ };+}++const lastSubmission = () =>+ harness.submitted.mock.calls.at(-1)![0] as Record<string, unknown>;++describe("StandaloneComposer smoke", () => {+ beforeEach(() => {+ harness.submitted.mockClear();+ harness.composerProps = null;+ });++ it("refuses to send while the input is empty", async () => {+ const { onSend } = await mount();++ await act(async () => {+ await onSend("");+ });+ await act(async () => {+ await onSend(" ");+ });++ expect(harness.submitted).not.toHaveBeenCalled();+ });++ it("sends the text and consumes one-shot state after the send", async () => {+ const { onSend } = await mount();++ await act(async () => {+ await onSend("hello");+ });++ expect(harness.submitted).toHaveBeenCalledTimes(1);+ expect(lastSubmission()).toEqual(+ expect.objectContaining({+ content: "hello",+ attachments: [],+ knowledgeBases: [],+ notebookReferences: [],+ historyReferences: [],+ bookReferences: [],+ questionNotebookReferences: [],+ memoryReferences: [],+ persona: null,+ llmSelection: null,+ subagentBudget: null,+ }),+ );+ expect(lastSubmission().config).toMatchObject({+ _persistent_knowledge_bases: [],+ });++ await act(async () => {+ await onSend("");+ });+ expect(harness.submitted).toHaveBeenCalledTimes(1);+ });++ it("locks the send while a turn is streaming", async () => {+ const { onSend } = await mount({ isStreaming: true });++ await act(async () => {+ await onSend("hello");+ });++ expect(harness.submitted).not.toHaveBeenCalled();+ });++ it("lets an ask_user answer through the streaming lock", async () => {+ const { onSend } = await mount({+ isStreaming: true,+ awaitingUserReply: true,+ });++ await act(async () => {+ await onSend("the answer");+ });++ expect(harness.submitted).toHaveBeenCalledTimes(1);+ expect(lastSubmission()).toEqual(+ expect.objectContaining({ content: "the answer" }),+ );+ });+});