-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFooterLine.test.tsx
More file actions
81 lines (73 loc) · 2.35 KB
/
Copy pathFooterLine.test.tsx
File metadata and controls
81 lines (73 loc) · 2.35 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
import { describe, expect, it } from "vitest";
import { render } from "ink-testing-library";
import { FooterLine } from "../../chrome/FooterLine.js";
import type { UsageTotals } from "../../session/types.js";
function usage(partial: Partial<UsageTotals> = {}): UsageTotals {
return {
inputTokens: 0,
outputTokens: 0,
cacheReadTokens: 0,
cacheCreationTokens: 0,
lastAgent: null,
...partial,
};
}
function props(overrides: Partial<Parameters<typeof FooterLine>[0]> = {}) {
return {
turns: 3,
approxTokens: 1234,
contextPercent: 1,
baseUrl: "http://localhost:8000",
profileName: null,
pendingApprovals: 0,
...overrides,
};
}
describe("<FooterLine />", () => {
it("shows turns, context estimate, and base url", () => {
const { lastFrame } = render(<FooterLine {...props()} />);
const frame = lastFrame() ?? "";
expect(frame).toContain("turns 3");
expect(frame).toContain("ctx≈1234tok (1%)");
expect(frame).toContain("http://localhost:8000");
});
it("includes the profile name when present", () => {
const { lastFrame } = render(
<FooterLine {...props({ profileName: "staging" })} />,
);
expect(lastFrame() ?? "").toContain("profile staging");
});
it("shows a token usage segment when usageTotals has any tokens", () => {
const { lastFrame } = render(
<FooterLine
{...props({
usageTotals: usage({
inputTokens: 1234,
outputTokens: 56,
lastAgent: "synthesizer",
}),
})}
/>,
);
const frame = lastFrame() ?? "";
expect(frame).toContain("1234→56");
// The dollar cost is never shown to the client.
expect(frame).not.toContain("$");
});
it("hides the usage segment when there are no tokens yet", () => {
const { lastFrame } = render(
<FooterLine {...props({ usageTotals: usage() })} />,
);
expect(lastFrame() ?? "").not.toContain("→");
});
it("shows a pending-approvals segment when there is one", () => {
const { lastFrame } = render(
<FooterLine {...props({ pendingApprovals: 2 })} />,
);
expect(lastFrame() ?? "").toContain("approvals 2");
});
it("hides the approvals segment when there are none", () => {
const { lastFrame } = render(<FooterLine {...props()} />);
expect(lastFrame() ?? "").not.toContain("approvals");
});
});