Open History to see the last commit
1import { describe, expect, it } from "vitest";
2import { Schema } from "effect";
3
4import {
5 GitCreateWorktreeInput,
6 GitPreparePullRequestThreadInput,
7 GitRunStackedActionInput,
8 GitResolvePullRequestResult,
9} from "./git";
10
11const decodeCreateWorktreeInput = Schema.decodeUnknownSync(GitCreateWorktreeInput);
12const decodePreparePullRequestThreadInput = Schema.decodeUnknownSync(
13 GitPreparePullRequestThreadInput,
14);
15const decodeRunStackedActionInput = Schema.decodeUnknownSync(GitRunStackedActionInput);
16const decodeResolvePullRequestResult = Schema.decodeUnknownSync(GitResolvePullRequestResult);
17
18describe("GitCreateWorktreeInput", () => {
19 it("accepts omitted newBranch for existing-branch worktrees", () => {
20 const parsed = decodeCreateWorktreeInput({
21 cwd: "/repo",
22 branch: "feature/existing",
23 path: "/tmp/worktree",
24 });
25
26 expect(parsed.newBranch).toBeUndefined();
27 expect(parsed.branch).toBe("feature/existing");
28 });
29});
30
31describe("GitPreparePullRequestThreadInput", () => {
32 it("accepts pull request references and mode", () => {
33 const parsed = decodePreparePullRequestThreadInput({
34 cwd: "/repo",
35 reference: "#42",
36 mode: "worktree",
37 });
38
39 expect(parsed.reference).toBe("#42");
40 expect(parsed.mode).toBe("worktree");
41 });
42});
43
44describe("GitResolvePullRequestResult", () => {
45 it("decodes resolved pull request metadata", () => {
46 const parsed = decodeResolvePullRequestResult({
47 pullRequest: {
48 number: 42,
49 title: "PR threads",
50 url: "https://github.com/pingdotgg/codething-mvp/pull/42",
51 baseBranch: "main",
52 headBranch: "feature/pr-threads",
53 state: "open",
54 },
55 });
56
57 expect(parsed.pullRequest.number).toBe(42);
58 expect(parsed.pullRequest.headBranch).toBe("feature/pr-threads");
59 });
60});
61
62describe("GitRunStackedActionInput", () => {
63 it("requires a client-provided actionId for progress correlation", () => {
64 const parsed = decodeRunStackedActionInput({
65 actionId: "action-1",
66 cwd: "/repo",
67 action: "commit",
68 });
69
70 expect(parsed.actionId).toBe("action-1");
71 expect(parsed.action).toBe("commit");
72 });
73});