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

ProjectSettingsPanel.logic.test.ts

69 lines2.6 KB

1import { describe, expect, it } from "vite-plus/test";
2import { EnvironmentId, ProjectId } 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 it("limits a checkout's thread count to its environment and project", () => {
20 const plan = planProjectRemoval({
21 members: [local],
22 groupMemberCount: 2,
23 hasOtherMembers: false,
24 displayName: "Repo",
25 threads: [
26 { environmentId: local.environmentId, projectId: local.id },
27 { environmentId: remote.environmentId, projectId: remote.id },
28 ],
29 });
30 expect(plan.projectThreads).toHaveLength(1);
31 expect(plan.confirmationMessage).toBe(
32 '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.',
33 );
34 });
35​
36 it("keeps an environment-filtered group scoped to its selected checkout", () => {
37 const plan = planProjectRemoval({
38 members: [remote],
39 groupMemberCount: 1,
40 hasOtherMembers: true,
41 displayName: "Repo",
42 threads: [],
43 });
44 expect(plan.targetKind).toBe("checkout");
45 expect(plan.confirmationMessage).toContain("Environment: Remote");
46 expect(plan.confirmationMessage).toContain(
47 "Other entries in this grouped project are unaffected.",
48 );
49 expect(plan.confirmationMessage).toContain(
50 "Any archived threads are deleted from T3 Code. Provider sessions are kept.",
51 );
52 });
53​
54 // regression: #21409 project-wide removal must count every checkout's threads and keep files
55 it("states the full group count and preserves files when removing a project everywhere", () => {
56 const plan = planProjectRemoval({
57 members: [local, remote],
58 groupMemberCount: 2,
59 hasOtherMembers: false,
60 displayName: "Repo",
61 threads: [],
62 });
63 expect(plan.targetKind).toBe("project");
64 expect(plan.confirmationMessage).toContain("This removes 2 grouped project entries.");
65 expect(plan.confirmationMessage).toContain(
66 "This removes only the project entries, not the files on disk.",
67 );
68 });
69});