Open History to see the last commit
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: "deadlock-race-fix",
138 kind: "guard",
139 source: "#22094 run metrics read lineage inside the transaction so a writer cannot deadlock",
140 type: "real",
141 rev: "f8e4834861",
142 paths: ["apps/server/src/orchestration-v2/RunMetrics.test.ts"],
143 targets: [],
144 },
145 {
146 id: "clone-retry-fix",
147 kind: "guard",
148 source: "#23170 clones retry over HTTPS when the SSH key is refused",
149 type: "real",
150 rev: "a49d18cf3b",
151 paths: ["apps/server/src/sourceControl/SourceControlRepositoryService.test.ts"],
152 targets: [],
153 },
154 {
155 id: "deleted-tests",
156 kind: "guard",
157 source: "#22592 pruned low-value tests",
158 type: "real",
159 rev: "a2f4df0412",
160 paths: [
161 "apps/server/src/workspace/WorkspaceEntries.test.ts",
162 "apps/server/src/workspace/WorkspacePaths.test.ts",
163 ],
164 targets: [],
165 },
166 {
167 id: "new-table-row",
168 kind: "guard",
169 source: "Synthetic: the right way to add the Windows path case",
170 type: "synthetic",
171 rev: base,
172 path: "packages/shared/src/markdownLinks.test.ts",
173 after: ' ["file://localhost/home/me/notes.md", "/home/me/notes.md"],\n',
174 insert: ' ["C:/repo/src/app.ts", "C:/repo/src/app.ts"],\n',
175 targets: [],
176 },
177];