Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { resolveThreadReferenceCopyTarget } from "./threadReference.ts";
4
5describe("resolveThreadReferenceCopyTarget", () => {
6 it("does not copy another reference while the open panel URL is unavailable", () => {
7 expect(
8 resolveThreadReferenceCopyTarget({
9 threadId: "thread-1",
10 openPanelPullRequestUrl: null,
11 linkedPullRequestUrl: "https://github.com/t3/pr/12",
12 }),
13 ).toBeNull();
14 });
15
16 it("prefers the open panel pull request over the thread pull request", () => {
17 expect(
18 resolveThreadReferenceCopyTarget({
19 threadId: "thread-1",
20 openPanelPullRequestUrl: "https://github.com/t3/pr/14",
21 linkedPullRequestUrl: "https://github.com/t3/pr/12",
22 }),
23 ).toMatchObject({
24 kind: "pull-request",
25 value: "https://github.com/t3/pr/14",
26 successTitle: "PR link copied",
27 });
28 });
29
30 it("uses the thread pull request when no panel is open", () => {
31 expect(
32 resolveThreadReferenceCopyTarget({
33 threadId: "thread-1",
34 linkedPullRequestUrl: "https://github.com/t3/pr/12",
35 }),
36 ).toMatchObject({
37 kind: "pull-request",
38 value: "https://github.com/t3/pr/12",
39 successTitle: "PR link copied",
40 });
41 });
42
43 it("falls back to the thread ID", () => {
44 expect(resolveThreadReferenceCopyTarget({ threadId: "thread-1" })).toEqual({
45 kind: "thread",
46 value: "thread-1",
47 clipboardTarget: "thread ID",
48 successTitle: "Thread ID copied",
49 failureTitle: "Failed to copy thread ID",
50 });
51 });
52});