Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ProjectSettingsPanel.logic.test.ts

83 lines3.2 KB

1import { describe, expect, it } from "vite-plus/test";
2import { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts";
3import { planProjectRemoval } from "@t3tools/client-runtime/state/projects";
4​
5describe("project removal confirmation", () => {
6 const local = {
7 id: ProjectId.make("shared-id"),
8 environmentId: EnvironmentId.make("local"),
9 title: "Repo",
10 workspaceRoot: "/work/repo",
11 environmentLabel: "Local",
12 };
13 const remote = {
14 ...local,
15 environmentId: EnvironmentId.make("remote"),
16 environmentLabel: "Remote",
17 };
18​
19 const parentId = ThreadId.make("parent");
20 const listed = { rootThreadId: parentId, parentThreadId: null, relationshipToParent: null };
21 const child = { rootThreadId: parentId, parentThreadId: parentId };
22​
23 it("limits a checkout's thread count to its listed threads in that environment and project", () => {
24 const plan = planProjectRemoval({
25 members: [local],
26 groupMemberCount: 2,
27 hasOtherMembers: false,
28 displayName: "Repo",
29 threads: [
30 { environmentId: local.environmentId, projectId: local.id, lineage: listed },
31 {
32 environmentId: local.environmentId,
33 projectId: local.id,
34 lineage: { ...child, relationshipToParent: "subagent" },
35 },
36 {
37 environmentId: local.environmentId,
38 projectId: local.id,
39 lineage: { ...child, relationshipToParent: "fork", sideChat: true },
40 },
41 { environmentId: remote.environmentId, projectId: remote.id, lineage: listed },
42 ],
43 });
44 expect(plan.projectThreads).toHaveLength(3);
45 expect(plan.confirmationMessage).toBe(
46 'Remove checkout "Repo" and delete its 1 thread?\nPath: /work/repo\nEnvironment: Local\nThose threads and any archived threads are deleted from T3 Code. Provider sessions are kept.\nOther entries in this grouped project are unaffected.\nThis action cannot be undone.',
47 );
48 });
49​
50 it("keeps an environment-filtered group scoped to its selected checkout", () => {
51 const plan = planProjectRemoval({
52 members: [remote],
53 groupMemberCount: 1,
54 hasOtherMembers: true,
55 displayName: "Repo",
56 threads: [],
57 });
58 expect(plan.targetKind).toBe("checkout");
59 expect(plan.confirmationMessage).toContain("Environment: Remote");
60 expect(plan.confirmationMessage).toContain(
61 "Other entries in this grouped project are unaffected.",
62 );
63 expect(plan.confirmationMessage).toContain(
64 "Any archived threads are deleted from T3 Code. Provider sessions are kept.",
65 );
66 });
67​
68 // regression: #21409 project-wide removal must count every checkout's threads and keep files
69 it("states the full group count and preserves files when removing a project everywhere", () => {
70 const plan = planProjectRemoval({
71 members: [local, remote],
72 groupMemberCount: 2,
73 hasOtherMembers: false,
74 displayName: "Repo",
75 threads: [],
76 });
77 expect(plan.targetKind).toBe("project");
78 expect(plan.confirmationMessage).toContain("This removes 2 grouped project entries.");
79 expect(plan.confirmationMessage).toContain(
80 "This removes only the project entries, not the files on disk.",
81 );
82 });
83});