Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ChatView.logic.test.ts

69 lines2.2 KB

1import { ThreadId } from "@t3tools/contracts";
2import { describe, expect, it } from "vitest";
3​
4import { buildExpiredTerminalContextToastCopy, deriveComposerSendState } from "./ChatView.logic";
5​
6describe("deriveComposerSendState", () => {
7 it("treats expired terminal pills as non-sendable content", () => {
8 const state = deriveComposerSendState({
9 prompt: "\uFFFC",
10 imageCount: 0,
11 terminalContexts: [
12 {
13 id: "ctx-expired",
14 threadId: ThreadId.makeUnsafe("thread-1"),
15 terminalId: "default",
16 terminalLabel: "Terminal 1",
17 lineStart: 4,
18 lineEnd: 4,
19 text: "",
20 createdAt: "2026-03-17T12:52:29.000Z",
21 },
22 ],
23 });
24​
25 expect(state.trimmedPrompt).toBe("");
26 expect(state.sendableTerminalContexts).toEqual([]);
27 expect(state.expiredTerminalContextCount).toBe(1);
28 expect(state.hasSendableContent).toBe(false);
29 });
30​
31 it("keeps text sendable while excluding expired terminal pills", () => {
32 const state = deriveComposerSendState({
33 prompt: `yoo \uFFFC waddup`,
34 imageCount: 0,
35 terminalContexts: [
36 {
37 id: "ctx-expired",
38 threadId: ThreadId.makeUnsafe("thread-1"),
39 terminalId: "default",
40 terminalLabel: "Terminal 1",
41 lineStart: 4,
42 lineEnd: 4,
43 text: "",
44 createdAt: "2026-03-17T12:52:29.000Z",
45 },
46 ],
47 });
48​
49 expect(state.trimmedPrompt).toBe("yoo waddup");
50 expect(state.expiredTerminalContextCount).toBe(1);
51 expect(state.hasSendableContent).toBe(true);
52 });
53});
54​
55describe("buildExpiredTerminalContextToastCopy", () => {
56 it("formats clear empty-state guidance", () => {
57 expect(buildExpiredTerminalContextToastCopy(1, "empty")).toEqual({
58 title: "Expired terminal context won't be sent",
59 description: "Remove it or re-add it to include terminal output.",
60 });
61 });
62​
63 it("formats omission guidance for sent messages", () => {
64 expect(buildExpiredTerminalContextToastCopy(2, "omitted")).toEqual({
65 title: "Expired terminal contexts omitted from message",
66 description: "Re-add it if you want that terminal output included.",
67 });
68 });
69});