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

feedbackRequest.test.ts

81 lines2.7 KB

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: 2,
35 textTurns: 2,
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 { turn: 2, type: "user" as const, length: 1, text: "y" },
47 ],
48 };
49 expect(
50 feedbackPreviewFields({
51 kind: "bug",
52 subject: "t3_thread_read",
53 expected: "Items.",
54 actual: "None.",
55 workaround: "",
56 trace,
57 }).map((field) => field.label),
58 ).toEqual(["Kind", "About", "Expected", "Happened"]);
59 expect(feedbackTraceLines(trace)).toEqual([
60 { key: "0", line: "Turn 1 · You · 5 characters", text: "Hello" },
61 { key: "1", line: "Turn 1 · t3_thread_read · error · 1.5 s" },
62 { key: "2", line: "Turn 2 · You · 1 character", text: "y" },
63 ]);
64 // Text only in turn 4 of 5: the wording reaches back to it, not "the last turn".
65 const older = {
66 turns: 5,
67 textTurns: 1,
68 truncated: false,
69 entries: [
70 { turn: 4, type: "user" as const, length: 5, text: "Hello" },
71 { turn: 5, type: "tool" as const, tool: "shell", outcome: "ok" as const },
72 ],
73 };
74 expect(feedbackTraceSummary(older)).toBe(
75 "Outline of 5 recent turns, message text of the last 2 turns",
76 );
77 expect(feedbackConversationHint(older)).toBe(
78 "Adds the text of your messages and the agent's replies in the last 2 turns.",
79 );
80 });
81});