Skip to content
Source
Sign inSign up

cases.ts

194 lines7.5 KB

1/**
2 * Pull request test diffs for the test-signal check. A `real` case replays test files from a
3 * merged PR. A `synthetic` case inserts one test into a real file at `rev`, for a pattern with no
4 * clean real example.
5 */
6export type Case = {
7 readonly id: string;
8 readonly kind: "bad" | "guard";
9 readonly source: string;
10 readonly rev: string;
11 /** Titles of the tests the check must flag. Guard cases expect no comment and `All clear`. */
12 readonly targets: ReadonlyArray<{ readonly path: string; readonly title: string }>;
13} & (
14 | { readonly type: "real"; readonly paths: ReadonlyArray<string> }
15 | {
16 readonly type: "synthetic";
17 readonly path: string;
18 readonly after: string;
19 readonly insert: string;
20 }
21);
22​
23const base = "cb7e3814d71c8fcdc5b803c660c29b7d7e39be96";
24​
25export const cases: ReadonlyArray<Case> = [
26 {
27 id: "copy-text-at-every-call-site",
28 kind: "bad",
29 source: "#23999 checks the PR or MR label in 11 files",
30 type: "real",
31 rev: "218e5c09df",
32 paths: [
33 "packages/client-runtime/src/state/gitActions.test.ts",
34 "apps/web/src/lib/composerContextRecords.test.ts",
35 "apps/mobile/src/lib/composerContext.test.ts",
36 ],
37 targets: [
38 {
39 path: "packages/client-runtime/src/state/gitActions.test.ts",
40 title: "says PR for a GitHub ref",
41 },
42 {
43 path: "packages/client-runtime/src/state/gitActions.test.ts",
44 title: "says MR for a GitLab ref",
45 },
46 {
47 path: "packages/client-runtime/src/state/gitActions.test.ts",
48 title: "names the host's change request in the default-branch dialog",
49 },
50 {
51 path: "apps/web/src/lib/composerContextRecords.test.ts",
52 title: "names the change request the way its host does",
53 },
54 {
55 path: "apps/mobile/src/lib/composerContext.test.ts",
56 title: "describes the change request with its host's term",
57 },
58 ],
59 },
60 {
61 id: "same-case-in-wrapper-test",
62 kind: "bad",
63 source: "#22452 added the same two cases to threadAccess and OrchestratorMcpService",
64 type: "real",
65 rev: "b260a7cf69",
66 paths: [
67 "apps/server/src/mcp/threadAccess.test.ts",
68 "apps/server/src/mcp/OrchestratorMcpService.test.ts",
69 ],
70 // Either copy counts: the check must notice the duplicate. Which copy it keeps is secondary.
71 targets: [
72 {
73 path: "apps/server/src/mcp/threadAccess.test.ts",
74 title: "points a bare uuid at the mcp: thread it belongs to",
75 },
76 {
77 path: "apps/server/src/mcp/threadAccess.test.ts",
78 title: "keeps the plain message for an id that matches nothing",
79 },
80 {
81 path: "apps/server/src/mcp/OrchestratorMcpService.test.ts",
82 title: "points a bare uuid at the mcp: thread it belongs to",
83 },
84 {
85 path: "apps/server/src/mcp/OrchestratorMcpService.test.ts",
86 title: "keeps the plain message for an id that matches nothing",
87 },
88 ],
89 },
90 {
91 id: "new-it-for-a-table-row",
92 kind: "bad",
93 source: "Synthetic: a new `it` next to the table that already covers it",
94 type: "synthetic",
95 rev: base,
96 path: "packages/shared/src/markdownLinks.test.ts",
97 after: " expect(parseMarkdownFileLink(href)?.path).toBe(path);\n });\n",
98 insert:
99 '\n it("recognizes a Windows path with forward slashes as a file", () => {\n expect(parseMarkdownFileLink("C:/repo/src/app.ts")?.path).toBe("C:/repo/src/app.ts");\n });\n',
100 targets: [
101 {
102 path: "packages/shared/src/markdownLinks.test.ts",
103 title: "recognizes a Windows path with forward slashes as a file",
104 },
105 ],
106 },
107 {
108 id: "mock-call-mirror",
109 kind: "bad",
110 source: "Synthetic: asserts the mock call the code makes, already covered above it",
111 type: "synthetic",
112 rev: base,
113 path: "packages/client-runtime/src/state/threadRequests.test.ts",
114 after: " expect(send).toHaveBeenCalledOnce();\n });\n",
115 insert:
116 '\n it("calls respond with decline", async () => {\n const respond = vi.fn<ApprovalResponder>(async () => AsyncResult.success(undefined));\n await declinePendingApprovals([approval], respond);\n expect(respond).toHaveBeenCalledWith(requestId, "decline");\n expect(respond).toHaveBeenCalledTimes(1);\n });\n',
117 targets: [
118 {
119 path: "packages/client-runtime/src/state/threadRequests.test.ts",
120 title: "calls respond with decline",
121 },
122 ],
123 },
124 {
125 id: "type-guaranteed",
126 kind: "bad",
127 source: "Synthetic: checks a return type the signature already declares",
128 type: "synthetic",
129 rev: base,
130 path: "packages/shared/src/markdownLinks.test.ts",
131 after: " expect(isMarkdownFileLinkLabel(label, href)).toBe(expected);\n });\n",
132 insert:
133 '\n it("returns a boolean", () => {\n expect(typeof isMarkdownFileLinkLabel("a.ts", "/repo/a.ts")).toBe("boolean");\n });\n',
134 targets: [{ path: "packages/shared/src/markdownLinks.test.ts", title: "returns a boolean" }],
135 },
136 {
137 id: "logic-in-browser-test",
138 kind: "bad",
139 source: "Synthetic: a browser test that never renders, for a pure function in a .logic.ts file",
140 type: "synthetic",
141 rev: base,
142 path: "apps/web/src/components/chat/OpenInPicker.browser.test.tsx",
143 after: ' expect(await spoken()).toBe("Opened in VS Code");\n });\n});\n',
144 insert:
145 '\ndescribe("open in picker visibility", () => {\n it("shows the picker for the primary environment or a remote that can open links", async () => {\n const { shouldShowOpenInPicker } = await import("./OpenInPicker.logic");\n const show = (overrides: Partial<Parameters<typeof shouldShowOpenInPicker>[0]>) =>\n shouldShowOpenInPicker({\n activeProjectName: "app",\n activeThreadEnvironmentId: selected,\n primaryEnvironmentId: primary,\n remoteOpenMode: "local-exec",\n ...overrides,\n });\n expect(show({ activeProjectName: undefined })).toBe(false);\n expect(show({ activeThreadEnvironmentId: primary })).toBe(true);\n expect(show({})).toBe(false);\n expect(show({ remoteOpenMode: "remote-links" })).toBe(true);\n });\n});\n',
146 targets: [
147 {
148 path: "apps/web/src/components/chat/OpenInPicker.browser.test.tsx",
149 title: "shows the picker for the primary environment or a remote that can open links",
150 },
151 ],
152 },
153 {
154 id: "deadlock-race-fix",
155 kind: "guard",
156 source: "#22094 run metrics read lineage inside the transaction so a writer cannot deadlock",
157 type: "real",
158 rev: "f8e4834861",
159 paths: ["apps/server/src/orchestration-v2/RunMetrics.test.ts"],
160 targets: [],
161 },
162 {
163 id: "clone-retry-fix",
164 kind: "guard",
165 source: "#23170 clones retry over HTTPS when the SSH key is refused",
166 type: "real",
167 rev: "a49d18cf3b",
168 paths: ["apps/server/src/sourceControl/SourceControlRepositoryService.test.ts"],
169 targets: [],
170 },
171 {
172 id: "deleted-tests",
173 kind: "guard",
174 source: "#22592 pruned low-value tests",
175 type: "real",
176 rev: "a2f4df0412",
177 paths: [
178 "apps/server/src/workspace/WorkspaceEntries.test.ts",
179 "apps/server/src/workspace/WorkspacePaths.test.ts",
180 ],
181 targets: [],
182 },
183 {
184 id: "new-table-row",
185 kind: "guard",
186 source: "Synthetic: the right way to add the Windows path case",
187 type: "synthetic",
188 rev: base,
189 path: "packages/shared/src/markdownLinks.test.ts",
190 after: ' ["file://localhost/home/me/notes.md", "/home/me/notes.md"],\n',
191 insert: ' ["C:/repo/src/app.ts", "C:/repo/src/app.ts"],\n',
192 targets: [],
193 },
194];