1import { describe, expect, it } from "vite-plus/test";
2
3import { resolveProjectThreadCreationBranch } from "./projectThreadCreationValidation";
4
5describe("resolveProjectThreadCreationBranch", () => {
6 it("uses the live checkout for an untouched local draft label and recorded branch", () => {
7 expect(
8 resolveProjectThreadCreationBranch({
9 workspaceMode: "local",
10 selectedBranch: null,
11 currentCheckoutBranch: "feature/x",
12 }),
13 ).toBe("feature/x");
14 });
15
16 it("prefers an explicit picker choice over the current checkout", () => {
17 expect(
18 resolveProjectThreadCreationBranch({
19 workspaceMode: "local",
20 selectedBranch: "main",
21 currentCheckoutBranch: "feature/x",
22 }),
23 ).toBe("main");
24 });
25
26 it("stays null when no ref is checked out (detached HEAD, non-repository, status not loaded)", () => {
27 expect(
28 resolveProjectThreadCreationBranch({
29 workspaceMode: "local",
30 selectedBranch: null,
31 currentCheckoutBranch: null,
32 }),
33 ).toBeNull();
34 });
35
36 it("never borrows the current checkout for a worktree draft", () => {
37 expect(
38 resolveProjectThreadCreationBranch({
39 workspaceMode: "worktree",
40 selectedBranch: null,
41 currentCheckoutBranch: "feature/x",
42 }),
43 ).toBeNull();
44 });
45
46 it("keeps the explicit base branch for a worktree draft", () => {
47 expect(
48 resolveProjectThreadCreationBranch({
49 workspaceMode: "worktree",
50 selectedBranch: "main",
51 currentCheckoutBranch: "feature/x",
52 }),
53 ).toBe("main");
54 });
55});