-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrightPaneFormatters.test.ts
More file actions
244 lines (214 loc) · 7.66 KB
/
Copy pathrightPaneFormatters.test.ts
File metadata and controls
244 lines (214 loc) · 7.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
import { describe, expect, it } from "vitest";
import {
derivePrMergeReadiness,
formatLinearStatus,
formatPrChecks,
formatPrComments,
formatPrMergeState,
formatPrReview,
formatPrSummary,
formatSystemDetails,
} from "../rightPaneFormatters";
describe("rightPaneFormatters", () => {
it("formats system details as stable rows", () => {
const body = formatSystemDetails({
project: { projectRoot: "/repo", workspaceRoot: "/repo/.ade/worktrees/a" },
pid: 123,
mode: "ready",
});
expect(body).toContain("project");
expect(body).toContain("/repo");
expect(body).toContain("workspace");
expect(body).toContain("process 123");
expect(body).not.toContain("{");
});
it("formats a PR summary without dumping JSON", () => {
const body = formatPrSummary({
id: "pr-1",
number: 42,
title: "Tighten ADE Code panes",
state: "open",
isDraft: true,
headBranch: "feature/tui",
baseBranch: "main",
htmlUrl: "https://example.com/pr/42",
});
expect(body).toContain("#42 · open · draft");
expect(body).toContain("Tighten ADE Code panes");
expect(body).toContain("feature/tui -> main");
expect(body).not.toContain("\"title\"");
});
it("formats PR create links from the new action envelope", () => {
const body = formatPrSummary({
pr: {
id: "pr-42",
laneId: "lane-1",
repoOwner: "acme",
repoName: "ade",
githubPrNumber: 42,
githubUrl: "https://github.com/acme/ade/pull/42",
title: "Add PR deeplinks",
state: "open",
},
adeUrl: "https://ade-app.dev/open?type=pr&repo=acme%2Fade&number=42",
});
expect(body).toContain("#42 · open");
expect(body).toContain("github https://github.com/acme/ade/pull/42");
expect(body).toContain("ade https://ade-app.dev/open?type=pr&repo=acme%2Fade&number=42");
});
it("derives an ADE PR URL when repo metadata is present", () => {
const body = formatPrSummary({
repoOwner: "acme",
repoName: "ade",
githubPrNumber: 7,
title: "Review parity",
githubUrl: "https://github.com/acme/ade/pull/7",
});
expect(body).toContain("github https://github.com/acme/ade/pull/7");
expect(body).toContain("ade https://ade-app.dev/open?type=pr&repo=acme%2Fade&number=7");
});
it("renders a Ready merge block when GitHub merge state is clean", () => {
const body = formatPrMergeState({
mergeStateStatus: "clean",
reviewDecision: "approved",
isMergeable: true,
mergeConflicts: false,
behindBaseBy: 0,
});
expect(body).toContain("Merge · Ready");
expect(body).toContain("✓ all requirements met");
});
it("lists the GitHub merge blockers in priority order", () => {
const readiness = derivePrMergeReadiness({
mergeStateStatus: "blocked",
reviewDecision: "review_required",
approvalsCount: 0,
requiredApprovals: 1,
behindBaseBy: 3,
mergeConflicts: false,
canBypass: true,
});
expect(readiness.headline).toBe("Blocked");
expect(readiness.ready).toBe(false);
expect(readiness.canBypass).toBe(true);
expect(readiness.blockers).toEqual([
"review required (0/1 approved)",
"3 commits behind base",
]);
});
it("treats `unstable` as mergeable (non-required checks failing is not a blocker)", () => {
const readiness = derivePrMergeReadiness({
mergeStateStatus: "unstable",
reviewDecision: "approved",
approvalsCount: 1,
requiredApprovals: 1,
behindBaseBy: 0,
mergeConflicts: false,
canBypass: false,
});
expect(readiness.blockers).not.toContain("required checks failing");
expect(readiness.ready).toBe(true);
expect(readiness.headline).not.toBe("Blocked");
});
it("treats a mergeable PR that is behind base as Ready, not Blocked (info-only)", () => {
const readiness = derivePrMergeReadiness({
mergeStateStatus: "clean",
reviewDecision: "approved",
approvalsCount: 1,
requiredApprovals: 1,
behindBaseBy: 3,
mergeConflicts: false,
canBypass: false,
});
expect(readiness.blockers).not.toContain("3 commits behind base");
expect(readiness.headline).toBe("Ready");
expect(readiness.ready).toBe(true);
});
it("flags conflicts and surfaces the bypass hint when the viewer can override", () => {
const body = formatPrMergeState({
status: {
mergeStateStatus: "dirty",
mergeConflicts: true,
canBypass: true,
},
});
expect(body).toContain("Merge · Conflicts");
expect(body).toContain("✗ merge conflicts");
expect(body).toContain("/pr land confirm <method> bypass");
});
it("reports a Checking state while GitHub computes mergeability", () => {
const readiness = derivePrMergeReadiness({
mergeStateStatus: "unknown",
mergeabilityComputing: true,
});
expect(readiness.headline).toBe("Checking…");
expect(readiness.computing).toBe(true);
expect(readiness.ready).toBe(false);
});
it("falls back to legacy conflict/behind fields for older runtimes", () => {
const readiness = derivePrMergeReadiness({
mergeConflicts: true,
behindBaseBy: 2,
});
expect(readiness.headline).toBe("Conflicts");
expect(readiness.blockers).toContain("2 commits behind base");
expect(readiness.blockers).toContain("merge conflicts");
});
it("summarizes PR checks", () => {
const body = formatPrChecks([
{ name: "ci / unit", status: "completed", conclusion: "success", completedAt: "2026-05-20T12:34:00.000Z" },
{ name: "lint", status: "queued", conclusion: null },
]);
expect(body).toContain("PR checks");
expect(body).toContain("1 passing");
expect(body).toContain("1 pending");
expect(body).toContain("OK ci / unit");
expect(body).toContain("WAIT lint");
});
it("summarizes PR review comments and threads", () => {
const body = formatPrComments({
summary: { checksStatus: "passing", actionableComments: 2 },
reviewThreads: [
{
id: "thread-1",
isResolved: false,
path: "src/index.ts",
line: 12,
comments: [{ author: "reviewer", body: "Please handle the loading state." }],
},
],
comments: [{ author: "reviewer", body: "Please fix the loading state." }],
});
expect(body).toContain("PR comments · passing · 2 actionable");
expect(body).toContain("open src/index.ts:12");
expect(body).toContain("reviewer: Please handle the loading state.");
expect(body).not.toContain("\"reviewThreads\"");
});
it("summarizes full PR review data", () => {
const body = formatPrReview({
reviews: [{ reviewer: "maintainer", state: "changes_requested", body: "Needs a test." }],
threads: [{ path: "src/a.ts", line: 9, isResolved: true, body: "Nit." }],
comments: [],
});
expect(body).toContain("PR review · 1 review · 1 thread · 0 comments");
expect(body).toContain("FAIL maintainer: Needs a test.");
expect(body).toContain("resolved src/a.ts:9");
});
it("formats Linear status as stable rows", () => {
const body = formatLinearStatus({
tokenStored: true,
connected: false,
viewerName: null,
organizationName: null,
checkedAt: "2026-05-20T07:34:36.379Z",
authMode: "oauth",
oauthAvailable: true,
tokenExpiresAt: "2026-05-14T06:54:46.643Z",
});
expect(body).toContain("connected no");
expect(body).toContain("token stored");
expect(body).toContain("auth oauth");
expect(body).toContain("expires 2026-05-14 06:54");
expect(body).not.toContain("\"connected\"");
});
});