Files
t3code/packages/contracts/src/git.test.ts
T
Julius Marminge 3d3586800e Add pull-request thread setup for local and worktree modes
- Add git APIs to resolve PR refs and prepare PR thread workspaces
- Support fetching PR head refs into local branches and reusing existing worktrees
- Wire new websocket/contracts/web composer flows for PR-based thread creation
- Expand server/web/contracts tests for PR routing and branch/worktree behavior
2026-03-09 22:50:45 -07:00

57 lines
1.7 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { Schema } from "effect";
import {
GitCreateWorktreeInput,
GitPreparePullRequestThreadInput,
GitResolvePullRequestResult,
} from "./git";
const decodeCreateWorktreeInput = Schema.decodeUnknownSync(GitCreateWorktreeInput);
const decodePreparePullRequestThreadInput = Schema.decodeUnknownSync(GitPreparePullRequestThreadInput);
const decodeResolvePullRequestResult = Schema.decodeUnknownSync(GitResolvePullRequestResult);
describe("GitCreateWorktreeInput", () => {
it("accepts omitted newBranch for existing-branch worktrees", () => {
const parsed = decodeCreateWorktreeInput({
cwd: "/repo",
branch: "feature/existing",
path: "/tmp/worktree",
});
expect(parsed.newBranch).toBeUndefined();
expect(parsed.branch).toBe("feature/existing");
});
});
describe("GitPreparePullRequestThreadInput", () => {
it("accepts pull request references and mode", () => {
const parsed = decodePreparePullRequestThreadInput({
cwd: "/repo",
reference: "#42",
mode: "worktree",
});
expect(parsed.reference).toBe("#42");
expect(parsed.mode).toBe("worktree");
});
});
describe("GitResolvePullRequestResult", () => {
it("decodes resolved pull request metadata", () => {
const parsed = decodeResolvePullRequestResult({
pullRequest: {
number: 42,
title: "PR threads",
url: "https://github.com/pingdotgg/codething-mvp/pull/42",
baseBranch: "main",
headBranch: "feature/pr-threads",
state: "open",
},
});
expect(parsed.pullRequest.number).toBe(42);
expect(parsed.pullRequest.headBranch).toBe("feature/pr-threads");
});
});