返回 DeepSeek-Reasonix
delivery-worktree.test.ts
根目录 / desktop / frontend / src / __tests__ / delivery-worktree.test.ts
1 // Run: tsx src/__tests__/delivery-worktree.test.ts
2 import { readFileSync } from "node:fs";
3 import { dirname, resolve } from "node:path";
4 import { fileURLToPath } from "node:url";
5
6 const dir = dirname(fileURLToPath(import.meta.url));
7 const source = (path: string) => readFileSync(resolve(dir, path), "utf8");
8 const bridge = source("../lib/bridge.ts");
9 const tree = source("../components/ProjectTree.tsx");
10 const tabs = source("../components/TabBar.tsx");
11 const app = source("../App.tsx");
12 const badge = source("../components/WorktreeBadge.tsx");
13
14 let failed = 0;
15 function ok(value: unknown, label: string) {
16 if (value) process.stdout.write(` PASS ${label}\n`);
17 else {
18 failed += 1;
19 process.stdout.write(` FAIL ${label}\n`);
20 }
21 }
22
23 console.log("\ndelivery worktree");
24 ok(/DeliveryWorktreeAvailability\(workspaceRoot: string\)/.test(bridge), "bridge exposes non-mutating availability probe");
25 ok(/CreateDeliveryWorktree\(workspaceRoot: string\)/.test(bridge), "bridge exposes isolated workspace creation");
26 ok(/app\.DeliveryWorktreeAvailability\(projectRoot\)/.test(tree), "project menu probes Git before enabling isolation");
27 ok(/disabled: isolatingProject !== null \|\| isolationAvailability\?\.available === false/.test(tree), "menu disables unavailable or duplicate creation");
28 ok(/onCreateDeliveryWorktree\?\.\(workspaceRoot\)/.test(tree), "project menu delegates isolated workspace creation");
29 ok(/kind: "delivery-worktree"/.test(app) && /enqueueNavigation\(\{ kind: "delivery-worktree"/.test(app), "creation shares the last-click-wins navigation queue");
30 ok(/sourceDirty[\s\S]*worktreeCreatedDirty/.test(app), "dirty source checkout receives an explicit warning");
31 ok(/isolatedWorktree && <WorktreeBadge/.test(tabs), "tab strip identifies isolated worktrees");
32 ok(/activeTab\?\.isolatedWorktree && <WorktreeBadge/.test(app), "topic bar identifies isolated worktrees");
33 ok(/node\.isolatedWorktree && <WorktreeBadge/.test(tree), "project tree identifies isolated worktrees");
34 ok(/GitBranch/.test(badge) && /#6119/.test(badge), "shared badge preserves the credited #6119 design contribution");
35
36 if (failed) process.exit(1);
37 console.log("delivery worktree tests passed");
38
38 lines TYPESCRIPT