-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathChatView.logic.test.ts
More file actions
88 lines (80 loc) · 2.68 KB
/
ChatView.logic.test.ts
File metadata and controls
88 lines (80 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { ThreadId } from "@okcode/contracts";
import { describe, expect, it } from "vitest";
import {
buildAutoSelectedWorktreeBaseBranchToastCopy,
buildExpiredTerminalContextToastCopy,
deriveComposerSendState,
} from "./ChatView.logic";
describe("deriveComposerSendState", () => {
it("treats expired terminal pills as non-sendable content", () => {
const state = deriveComposerSendState({
prompt: "\uFFFC",
imageCount: 0,
terminalContexts: [
{
id: "ctx-expired",
threadId: ThreadId.makeUnsafe("thread-1"),
terminalId: "default",
terminalLabel: "Terminal 1",
lineStart: 4,
lineEnd: 4,
text: "",
createdAt: "2026-03-17T12:52:29.000Z",
},
],
});
expect(state.trimmedPrompt).toBe("");
expect(state.sendableTerminalContexts).toEqual([]);
expect(state.expiredTerminalContextCount).toBe(1);
expect(state.hasSendableContent).toBe(false);
});
it("keeps text sendable while excluding expired terminal pills", () => {
const state = deriveComposerSendState({
prompt: `yoo \uFFFC waddup`,
imageCount: 0,
terminalContexts: [
{
id: "ctx-expired",
threadId: ThreadId.makeUnsafe("thread-1"),
terminalId: "default",
terminalLabel: "Terminal 1",
lineStart: 4,
lineEnd: 4,
text: "",
createdAt: "2026-03-17T12:52:29.000Z",
},
],
});
expect(state.trimmedPrompt).toBe("yoo waddup");
expect(state.expiredTerminalContextCount).toBe(1);
expect(state.hasSendableContent).toBe(true);
});
});
describe("buildExpiredTerminalContextToastCopy", () => {
it("formats clear empty-state guidance", () => {
expect(buildExpiredTerminalContextToastCopy(1, "empty")).toEqual({
title: "Expired terminal context won't be sent",
description: "Remove it or re-add it to include terminal output.",
});
});
it("formats omission guidance for sent messages", () => {
expect(buildExpiredTerminalContextToastCopy(2, "omitted")).toEqual({
title: "Expired terminal contexts omitted from message",
description: "Re-add it if you want that terminal output included.",
});
});
});
describe("buildAutoSelectedWorktreeBaseBranchToastCopy", () => {
it("explains the branch fallback clearly", () => {
expect(
buildAutoSelectedWorktreeBaseBranchToastCopy({
requestedBranch: "main",
selectedBranch: "master",
}),
).toEqual({
title: "Using master instead of main",
description:
"The requested base branch main was unavailable, so OK Code created this worktree from master.",
});
});
});