Files
fusion/packages/dashboard/app/components/__tests__/chatReportHandoff.test.ts
gsxdsm 98ad663011 FN-8872: add structural mail reports from chat
Add a report-oriented mail workflow that turns completed chat responses into structured, reviewable messages.

- Render structural report items with dedicated visual treatment and tests across mail surfaces.
- Add report-mode composer fields and route Send as report handoffs from completed chat responses.
- Document the mail/chat workflow and publish a Fusion changeset.

Files changed:
 .changeset/fn-8872-structural-mail-ui.md           |   7 +
 docs/dashboard-guide.md                            |   3 +
 packages/dashboard/app/App.tsx                     |   9 +
 packages/dashboard/app/components/ChatView.tsx     |  36 ++--
 packages/dashboard/app/components/MailboxModal.tsx |  28 ++-
 .../app/components/MailboxStructuralItem.css       |  73 +++++++
 .../app/components/MailboxStructuralItem.tsx       | 100 ++++++++++
 packages/dashboard/app/components/MailboxView.tsx  |  50 ++++-
 .../dashboard/app/components/MessageComposer.css   |  18 ++
 .../dashboard/app/components/MessageComposer.tsx   |  57 +++++-
 .../__tests__/ChatMailReportRouting.test.tsx       | 144 ++++++++++++++
 .../__tests__/ChatView.send-as-report.test.tsx     |  96 +++++++++
 .../__tests__/MailboxStructuralItem.test.tsx       |  90 +++++++++
 .../MailboxStructuralMail.surfaces.test.tsx        | 217 +++++++++++++++++++++
 .../app/components/__tests__/MailboxView.test.tsx  |  28 +++
 .../__tests__/MessageComposer.report-mode.test.tsx | 106 ++++++++++
 .../components/__tests__/chatReportHandoff.test.ts |  26 +++
 .../dashboard/app/components/chatReportHandoff.ts  |  65 ++++++
 .../app/components/dashboard/MainContent.tsx       |   4 +
 .../dashboard/app/components/dashboard/types.ts    |   3 +
 20 files changed, 1135 insertions(+), 25 deletions(-)

Fusion-Task-Id: FN-8872

Fusion-Task-Lineage: 55e4bf5e-e7f3-48a5-8084-4090ab24710a

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-09 06:07:01 -07:00

27 lines
1.6 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { CHAT_REPORT_MAX_BODY, buildChatReportHandoff } from "../chatReportHandoff";
describe("buildChatReportHandoff", () => {
it("rejects blank mail and always derives a usable title", () => {
expect(buildChatReportHandoff(" \n", "Fallback")).toEqual({ handoff: null, truncated: false });
expect(buildChatReportHandoff("```ts\nconst x = 1;\n```", "Fallback").handoff?.title).toBe("Fallback");
expect(buildChatReportHandoff("```md\n# A code heading\n```", "Fallback").handoff?.title).toBe("Fallback");
expect(buildChatReportHandoff("~~~md\n# Another code heading\n~~~", "Fallback").handoff?.title).toBe("Fallback");
expect(buildChatReportHandoff("!!!", "Fallback").handoff?.title).toBe("Fallback");
});
it("uses headings and bounds report bodies to the composer limit", () => {
expect(buildChatReportHandoff("# Delivery update\nBody", "Fallback").handoff?.title).toBe("Delivery update");
const result = buildChatReportHandoff("x".repeat(CHAT_REPORT_MAX_BODY + 1), "Fallback");
expect(result.truncated).toBe(true);
expect(result.handoff?.body).toHaveLength(CHAT_REPORT_MAX_BODY);
expect(buildChatReportHandoff("x".repeat(CHAT_REPORT_MAX_BODY), "Fallback").truncated).toBe(false);
});
it("limits a prose-derived title without turning a degenerate message into a blank title", () => {
const prose = "Release ".repeat(20);
expect(buildChatReportHandoff(prose, "Fallback").handoff?.title).toHaveLength(79);
expect(buildChatReportHandoff("...\n---", "Fallback").handoff?.title).toBe("Fallback");
});
});