Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import {
4 feedbackConversationHint,
5 feedbackPreviewFields,
6 feedbackRequestDisplay,
7 feedbackTraceLines,
8 feedbackTraceSummary,
9} from "./feedbackRequest.ts";
10
11describe("feedbackRequestDisplay", () => {
12 it("lets only the thread that asked answer, and names how each card ended", () => {
13 expect(feedbackRequestDisplay({ feedbackStatus: "pending" }, "local")).toEqual({
14 kind: "pending",
15 });
16 expect(feedbackRequestDisplay({ feedbackStatus: "pending" }, "inherited").kind).toBe(
17 "pending-elsewhere",
18 );
19 expect(
20 (["sent", "declined", "cancelled"] as const).map((feedbackStatus) =>
21 feedbackRequestDisplay({ feedbackStatus }, "local"),
22 ),
23 ).toEqual([
24 { kind: "answered", outcome: "sent", label: "Sent" },
25 { kind: "answered", outcome: "not-sent", label: "Not sent" },
26 { kind: "answered", outcome: "not-sent", label: "Closed without sending" },
27 ]);
28 });
29});
30
31describe("feedback preview", () => {
32 it("shows every field that is sent, and each outline entry with its text", () => {
33 const trace = {
34 turns: 1,
35 textTurns: 1,
36 truncated: false,
37 entries: [
38 { turn: 1, type: "user" as const, length: 5, text: "Hello" },
39 {
40 turn: 1,
41 type: "tool" as const,
42 tool: "t3_thread_read",
43 outcome: "error" as const,
44 durationMs: 1_500,
45 },
46 ],
47 };
48 expect(
49 feedbackPreviewFields({
50 kind: "bug",
51 subject: "t3_thread_read",
52 expected: "Items.",
53 actual: "None.",
54 workaround: "",
55 trace,
56 }).map((field) => field.label),
57 ).toEqual(["Kind", "About", "Expected", "Happened"]);
58 expect(feedbackTraceLines(trace)).toEqual([
59 { key: "0", line: "Turn 1 · You · 5 characters", text: "Hello" },
60 { key: "1", line: "Turn 1 · t3_thread_read · error · 1.5 s" },
61 ]);
62 // Text only in turn 4 of 5: the wording reaches back to it, not "the last turn".
63 const older = {
64 turns: 5,
65 textTurns: 1,
66 truncated: false,
67 entries: [
68 { turn: 4, type: "user" as const, length: 5, text: "Hello" },
69 { turn: 5, type: "tool" as const, tool: "shell", outcome: "ok" as const },
70 ],
71 };
72 expect(feedbackTraceSummary(older)).toBe(
73 "Outline of 5 recent turns, message text of the last 2 turns",
74 );
75 expect(feedbackConversationHint(older)).toBe(
76 "Adds the text of your messages and the agent's replies in the last 2 turns.",
77 );
78 });
79});