Open History to see the last commit
1import { ASSISTANT_CITATION_MAX_COMMENT_LENGTH } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3
4import { resolveAssistantCitationCommentDismissal } from "./assistantCitationCommentDismissal";
5
6describe("resolveAssistantCitationCommentDismissal", () => {
7 it("commits typed text when the popover is dismissed by clicking away", () => {
8 expect(
9 resolveAssistantCitationCommentDismissal({
10 reason: "outside-press",
11 draft: "needs a retry",
12 savedComment: undefined,
13 }),
14 ).toEqual({ kind: "commit", comment: "needs a retry" });
15 });
16
17 it("commits an edited comment when focus leaves the popover", () => {
18 expect(
19 resolveAssistantCitationCommentDismissal({
20 reason: "focus-out",
21 draft: "second thought",
22 savedComment: "first thought",
23 }),
24 ).toEqual({ kind: "commit", comment: "second thought" });
25 });
26
27 it("keeps the popover open instead of dropping an over-length draft", () => {
28 expect(
29 resolveAssistantCitationCommentDismissal({
30 reason: "outside-press",
31 draft: "x".repeat(ASSISTANT_CITATION_MAX_COMMENT_LENGTH + 1),
32 savedComment: undefined,
33 }),
34 ).toEqual({ kind: "keep-open" });
35 });
36});