Open History to see the last commit
1import { formatAssistantCitationHref } from "@t3tools/shared/assistantCitations";
2import { describe, expect, it } from "vite-plus/test";
3
4import { resolveThreadQueueRowControls } from "./threadQueueControlPresentation";
5
6describe("threadQueueControlPresentation", () => {
7 it.each([
8 { busy: false, isEditing: false, expected: true },
9 { busy: true, isEditing: false, expected: false },
10 { busy: false, isEditing: true, expected: false },
11 ])(
12 "gates sending a stopped thread's queued message with $busy busy and $isEditing editing",
13 ({ busy, isEditing, expected }) => {
14 const controls = resolveThreadQueueRowControls({
15 busy,
16 isEditing,
17 canPromoteToSteer: false,
18 canSendNow: true,
19 text: "Queued message",
20 });
21
22 expect(controls.canSend).toBe(expected);
23 },
24 );
25
26 it("shows an assistant quote as its quoted text", () => {
27 const href = formatAssistantCitationHref({
28 version: 1,
29 environmentId: "environment:test" as never,
30 threadId: "thread:test" as never,
31 messageId: "message:assistant" as never,
32 text: "Retry the sync after the lock clears.",
33 start: 0,
34 end: 37,
35 prefix: "",
36 suffix: "",
37 });
38 const controls = resolveThreadQueueRowControls({
39 busy: false,
40 canPromoteToSteer: true,
41 canSendNow: false,
42 text: `[Assistant quote](${href}) Can we add a backoff here?`,
43 });
44
45 expect(controls.displayText).toBe(
46 "Retry the sync after the lock clears. Can we add a backoff here?",
47 );
48 });
49
50 it("keeps the row already open in the composer from being reopened or steered", () => {
51 const editing = resolveThreadQueueRowControls({
52 busy: false,
53 canPromoteToSteer: true,
54 canSendNow: false,
55 isEditing: true,
56 text: "Being edited",
57 });
58
59 expect(editing.isEditing).toBe(true);
60 expect(editing.canEdit).toBe(false);
61 expect(editing.canSend).toBe(false);
62 expect(editing.canDismiss).toBe(true);
63 });
64
65 it("lets the owner cancel a guest's queued message but not rewrite it", () => {
66 const guest = resolveThreadQueueRowControls({
67 busy: false,
68 canPromoteToSteer: true,
69 canSendNow: false,
70 isGuestMessage: true,
71 text: "Why?",
72 });
73
74 expect(guest.canEdit).toBe(false);
75 expect(guest.canDismiss).toBe(true);
76 });
77});