Open History to see the last commit
1import {
2 PullRequestAction,
3 type PullRequestCheck,
4 type PullRequestComment,
5 type PullRequestDetailView,
6 type PullRequestReviewThread,
7} from "@t3tools/contracts";
8import { describe, expect, it } from "vite-plus/test";
9
10import {
11 buildAddSelectionToAgentHandoff,
12 classifyPullRequestChecks,
13 describePullRequestChecks,
14 resolveThreadPanelPullRequestAction,
15 buildAskAboutPullRequestHandoff,
16 buildExplainPullRequestHandoff,
17 buildFixFindingHandoff,
18 buildFixFindingsHandoff,
19 groupPullRequestTimelineConversations,
20 handoffPrompt,
21 handoffReviewComments,
22 isPullRequestVerdictStale,
23 isStackedPullRequestBase,
24 isThreadOwnPullRequest,
25 latestPullRequestReviewOutcomes,
26 newestPullRequestCommitAt,
27 mergePullRequestThreadComments,
28 orderPullRequestComments,
29 pullRequestActionMenuHasGroup,
30 pullRequestActionNeedsHostRefresh,
31 pullRequestComposerTarget,
32 pullRequestFindingKey,
33 pullRequestHandoffLabels,
34 pullRequestReviewOutcome,
35 readableFailure,
36 shouldRefreshPullRequestActivity,
37 resolveBaseFreshness,
38 buildPullRequestTimeline,
39 describePullRequestState,
40 editPullRequestThreadComment,
41} from "./pullRequestDetail.logic";
42import type { ReviewCommentContext } from "~/reviewCommentContext";
43
44const TIMELINE_SOURCE: Pick<
45 PullRequestDetailView,
46 "createdAt" | "author" | "commits" | "comments" | "mergedAt" | "closedAt"
47> = {
48 createdAt: "2026-07-01T00:00:00Z",
49 author: { login: "octocat", name: null, avatarUrl: null },
50 commits: [
51 { oid: "1baf7bdcafe", messageHeadline: "add the page", committedDate: "2026-07-02T00:00:00Z" },
52 ],
53 comments: [
54 {
55 id: "c1",
56 kind: "issue-comment",
57 author: { login: "bilal", name: null, avatarUrl: null },
58 body: "looks good",
59 createdAt: "2026-07-03T00:00:00Z",
60 url: null,
61 path: null,
62 reviewState: null,
63 },
64 ],
65 mergedAt: null,
66 closedAt: null,
67};
68
69describe("pull request activity refresh", () => {
70 const first = {
71 key: "project:acme/web#7",
72 updatedAt: "2026-08-13T13:00:00Z",
73 };
74
75 it("refreshes activity only after the same pull request changes", () => {
76 expect(
77 shouldRefreshPullRequestActivity(first, {
78 ...first,
79 updatedAt: "2026-08-13T13:01:00Z",
80 }),
81 ).toBe(true);
82 });
83
84 it("does not duplicate the first activity read or carry a revision across pull requests", () => {
85 expect(shouldRefreshPullRequestActivity(null, first)).toBe(false);
86 expect(shouldRefreshPullRequestActivity(first, first)).toBe(false);
87 expect(
88 shouldRefreshPullRequestActivity(first, {
89 key: "project:acme/web#8",
90 updatedAt: "2026-08-13T13:01:00Z",
91 }),
92 ).toBe(false);
93 });
94});
95describe("review thread comment pages", () => {
96 it("appends new comments once and keeps refreshed base comments", () => {
97 expect(
98 mergePullRequestThreadComments(
99 [
100 { id: "c1", body: "refreshed" },
101 { id: "c2", body: "already in base" },
102 ],
103 [
104 { id: "c2", body: "stale page copy" },
105 { id: "c3", body: "next page" },
106 ],
107 ),
108 ).toEqual([
109 { id: "c1", body: "refreshed" },
110 { id: "c2", body: "already in base" },
111 { id: "c3", body: "next page" },
112 ]);
113 });
114
115 it("keeps a loaded comment after its body is edited", () => {
116 const loaded = [
117 { id: "c2", body: "old body" },
118 { id: "c3", body: "another loaded comment" },
119 ];
120
121 expect(editPullRequestThreadComment(loaded, "c2", "saved body")).toEqual([
122 { id: "c2", body: "saved body" },
123 { id: "c3", body: "another loaded comment" },
124 ]);
125 });
126});
127
128describe("pull request action menu", () => {
129 it("keeps the group divider when auto-merge is the only action", () => {
130 expect(pullRequestActionMenuHasGroup(false, true, false)).toBe(true);
131 });
132});
133
134describe("pull request state description", () => {
135 it("keeps draft and conflicts orthogonal to the terminal states", () => {
136 expect(describePullRequestState("open", true)).toBe("Draft");
137 expect(describePullRequestState("open", false)).toBe("Ready for review");
138 expect(describePullRequestState("merged", true)).toBe("Merged");
139 expect(describePullRequestState("closed", false)).toBe("Closed");
140 });
141});
142
143describe("pull request handoff labels", () => {
144 it("names the open thread when actions write to its composer", () => {
145 expect(pullRequestHandoffLabels(true)).toEqual({
146 fixFinding: "Fix in this thread",
147 fixCheck: "Fix in this thread",
148 fixFindings: "Fix findings in this thread",
149 });
150 });
151
152 it("keeps the standalone pull request page labels", () => {
153 expect(pullRequestHandoffLabels(false)).toEqual({
154 fixFinding: "Fix in a thread",
155 fixCheck: "Fix",
156 fixFindings: "Fix findings in a thread",
157 });
158 });
159});
160
161describe("pull request composer target", () => {
162 it("rejects a page composer so agent comments cannot open another thread", () => {
163 const target = { environmentId: "env-1", threadId: "thread-1" };
164
165 expect(pullRequestComposerTarget("page", target)).toBeNull();
166 expect(pullRequestComposerTarget("thread", target)).toBe(target);
167 });
168});
169
170describe("stacked pull request classification", () => {
171 it("requires a known default branch", () => {
172 expect(isStackedPullRequestBase("main", [{ name: "main", isDefault: false }])).toBe(false);
173 });
174
175 it("recognizes local and remote forms of the default branch", () => {
176 expect(
177 isStackedPullRequestBase("main", [{ name: "main", isDefault: true, isRemote: false }]),
178 ).toBe(false);
179 expect(
180 isStackedPullRequestBase("main", [
181 { name: "origin/main", isDefault: true, isRemote: true, remoteName: "origin" },
182 ]),
183 ).toBe(false);
184 });
185
186 it("classifies a non-default base as stacked once the default is known", () => {
187 expect(
188 isStackedPullRequestBase("feature-base", [
189 { name: "origin/main", isDefault: true, isRemote: true, remoteName: "origin" },
190 ]),
191 ).toBe(true);
192 });
193
194 it("does not mistake a nested branch suffix for the default branch", () => {
195 expect(
196 isStackedPullRequestBase("main", [
197 {
198 name: "origin/feature/main",
199 isDefault: true,
200 isRemote: true,
201 remoteName: "origin",
202 },
203 ]),
204 ).toBe(true);
205 expect(
206 isStackedPullRequestBase("1.0", [{ name: "release/1.0", isDefault: true, isRemote: false }]),
207 ).toBe(true);
208 });
209});
210
211describe("ordering comments", () => {
212 it("reverses the chronological list for newest first, and leaves oldest first alone", () => {
213 const comments = [{ createdAt: "a" }, { createdAt: "b" }, { createdAt: "c" }];
214 expect(orderPullRequestComments(comments, "newest")).toEqual([
215 { createdAt: "c" },
216 { createdAt: "b" },
217 { createdAt: "a" },
218 ]);
219 expect(orderPullRequestComments(comments, "oldest")).toEqual(comments);
220 // The source array is chronological input, not a mutation target.
221 expect(comments).toEqual([{ createdAt: "a" }, { createdAt: "b" }, { createdAt: "c" }]);
222 });
223});
224
225describe("review verdicts", () => {
226 it("reads the same three verdicts however a host spells them", () => {
227 expect(pullRequestReviewOutcome("APPROVED")).toBe("approved");
228 expect(pullRequestReviewOutcome("approved")).toBe("approved");
229 expect(pullRequestReviewOutcome("CHANGES_REQUESTED")).toBe("changes-requested");
230 expect(pullRequestReviewOutcome("changes_requested")).toBe("changes-requested");
231 expect(pullRequestReviewOutcome("DISMISSED")).toBe("dismissed");
232 });
233
234 it("is not a verdict where the review only carried remarks", () => {
235 expect(pullRequestReviewOutcome("COMMENTED")).toBeNull();
236 expect(pullRequestReviewOutcome("PENDING")).toBeNull();
237 expect(pullRequestReviewOutcome(null)).toBeNull();
238 });
239
240 it("keeps each reviewer's last word, whatever order the host returned them in", () => {
241 const review = (
242 id: string,
243 login: string,
244 reviewState: string,
245 createdAt: string,
246 ): PullRequestComment => ({
247 id,
248 kind: "review",
249 author: { login, name: null, avatarUrl: null },
250 body: "",
251 createdAt,
252 url: null,
253 path: null,
254 reviewState,
255 });
256
257 expect(
258 latestPullRequestReviewOutcomes([
259 review("r3", "bilal", "APPROVED", "2026-07-03T00:00:00Z"),
260 review("r1", "bilal", "CHANGES_REQUESTED", "2026-07-01T00:00:00Z"),
261 review("r2", "octocat", "CHANGES_REQUESTED", "2026-07-02T00:00:00Z"),
262 // Not a verdict, so it neither adds a reviewer nor overwrites one.
263 review("r4", "octocat", "COMMENTED", "2026-07-04T00:00:00Z"),
264 ]).map((entry) => [entry.actor?.login, entry.outcome]),
265 ).toEqual([
266 ["bilal", "approved"],
267 ["octocat", "changes-requested"],
268 ]);
269 });
270
271 it("keeps two deleted accounts apart rather than counting them as one reviewer", () => {
272 expect(
273 latestPullRequestReviewOutcomes([
274 {
275 ...TIMELINE_SOURCE.comments[0]!,
276 id: "r1",
277 kind: "review",
278 author: null,
279 reviewState: "APPROVED",
280 createdAt: "2026-07-01T00:00:00Z",
281 },
282 {
283 ...TIMELINE_SOURCE.comments[0]!,
284 id: "r2",
285 kind: "review",
286 author: null,
287 reviewState: "APPROVED",
288 createdAt: "2026-07-02T00:00:00Z",
289 },
290 ]),
291 ).toHaveLength(2);
292 });
293
294 it("gives every entry a key that separates the reviewers it kept apart", () => {
295 const entries = latestPullRequestReviewOutcomes([
296 {
297 ...TIMELINE_SOURCE.comments[0]!,
298 id: "r1",
299 kind: "review",
300 author: null,
301 reviewState: "APPROVED",
302 createdAt: "2026-07-01T00:00:00Z",
303 },
304 {
305 ...TIMELINE_SOURCE.comments[0]!,
306 id: "r2",
307 kind: "review",
308 author: null,
309 reviewState: "APPROVED",
310 createdAt: "2026-07-01T00:00:00Z",
311 },
312 ]);
313 // Same author (none) and the same instant, so only the review's own id tells them apart.
314 expect(new Set(entries.map((entry) => entry.key)).size).toBe(2);
315 });
316
317 it("calls a verdict stale once commits land after it, and current before that", () => {
318 const commits = [
319 { oid: "c0ffee", messageHeadline: "later work", committedDate: "2026-07-05T00:00:00Z" },
320 ];
321 const review = (createdAt: string): PullRequestComment => ({
322 ...TIMELINE_SOURCE.comments[0]!,
323 kind: "review",
324 reviewState: "APPROVED",
325 createdAt,
326 });
327
328 expect(
329 latestPullRequestReviewOutcomes([review("2026-07-01T00:00:00Z")], commits)[0]?.stale,
330 ).toBe(true);
331 expect(
332 latestPullRequestReviewOutcomes([review("2026-07-06T00:00:00Z")], commits)[0]?.stale,
333 ).toBe(false);
334 // Nothing to be overtaken by, so nothing is stale.
335 expect(latestPullRequestReviewOutcomes([review("2026-07-01T00:00:00Z")], [])[0]?.stale).toBe(
336 false,
337 );
338 });
339
340 it("measures staleness against the newest commit, not the last one listed", () => {
341 expect(
342 newestPullRequestCommitAt([
343 { oid: "a", messageHeadline: "", committedDate: "2026-07-09T00:00:00Z" },
344 { oid: "b", messageHeadline: "", committedDate: "2026-07-02T00:00:00Z" },
345 ]),
346 ).toBe("2026-07-09T00:00:00Z");
347 expect(newestPullRequestCommitAt([])).toBeNull();
348 });
349
350 it("orders instants rather than their text, so a UTC offset cannot invert them", () => {
351 // 01:00+02:00 is 23:00 the previous day, so as text it sorts after the Z stamp and in time
352 // it falls well before it.
353 expect(
354 newestPullRequestCommitAt([
355 { oid: "a", messageHeadline: "", committedDate: "2026-07-05T00:30:00Z" },
356 { oid: "b", messageHeadline: "", committedDate: "2026-07-05T01:00:00+02:00" },
357 ]),
358 ).toBe("2026-07-05T00:30:00Z");
359 expect(isPullRequestVerdictStale("2026-07-05T00:30:00Z", "2026-07-05T01:00:00+02:00")).toBe(
360 false,
361 );
362 // A timestamp nothing can parse is not a position, so it settles nothing either way.
363 expect(isPullRequestVerdictStale("2026-07-01T00:00:00Z", "not a date")).toBe(false);
364 expect(
365 newestPullRequestCommitAt([{ oid: "a", messageHeadline: "", committedDate: "not a date" }]),
366 ).toBeNull();
367 });
368
369 it("shows nothing for a reviewer whose verdict was dismissed", () => {
370 expect(
371 latestPullRequestReviewOutcomes([
372 {
373 ...TIMELINE_SOURCE.comments[0]!,
374 kind: "review",
375 reviewState: "APPROVED",
376 createdAt: "2026-07-01T00:00:00Z",
377 },
378 {
379 ...TIMELINE_SOURCE.comments[0]!,
380 id: "c2",
381 kind: "review",
382 reviewState: "DISMISSED",
383 createdAt: "2026-07-02T00:00:00Z",
384 },
385 ]),
386 ).toEqual([]);
387 });
388});
389
390describe("pull request timeline", () => {
391 it("orders creation, commits and comments newest first", () => {
392 // What happened last is what the reader opening the tab is asking about.
393 expect(buildPullRequestTimeline(TIMELINE_SOURCE).map((event) => event.id)).toEqual([
394 "c1",
395 "1baf7bdcafe",
396 "created",
397 ]);
398 });
399
400 it("carries the comment url, and leaves the events the host cannot address without one", () => {
401 const events = buildPullRequestTimeline({
402 ...TIMELINE_SOURCE,
403 comments: [{ ...TIMELINE_SOURCE.comments[0]!, url: "https://example.test/pull/1#c1" }],
404 });
405 expect(events.map((event) => event.url)).toEqual([
406 "https://example.test/pull/1#c1",
407 null,
408 null,
409 ]);
410 });
411
412 it("carries actors and review context into the presentation model", () => {
413 const commitAuthors = [
414 { login: "octocat", name: null, avatarUrl: "https://example.test/octocat.png" },
415 { login: "pair", name: "Pair Author", avatarUrl: null },
416 ];
417 const events = buildPullRequestTimeline({
418 ...TIMELINE_SOURCE,
419 commits: [{ ...TIMELINE_SOURCE.commits[0]!, authors: commitAuthors }],
420 comments: [
421 {
422 ...TIMELINE_SOURCE.comments[0]!,
423 kind: "review",
424 path: "src/app.ts",
425 reviewState: "APPROVED",
426 },
427 ],
428 });
429
430 expect(events.find((event) => event.kind === "commit")?.commitAuthors).toEqual(commitAuthors);
431 expect(events.find((event) => event.kind === "review")).toMatchObject({
432 actor: TIMELINE_SOURCE.comments[0]?.author,
433 path: "src/app.ts",
434 reviewState: "APPROVED",
435 });
436 });
437
438 it("carries each commit's line counts into its timeline event", () => {
439 const events = buildPullRequestTimeline({
440 ...TIMELINE_SOURCE,
441 commits: [{ ...TIMELINE_SOURCE.commits[0]!, additions: 12, deletions: 4 }],
442 });
443
444 expect(events.find((event) => event.kind === "commit")).toMatchObject({
445 additions: 12,
446 deletions: 4,
447 });
448 });
449
450 it("drops a body that is nothing but a bot's HTML comment, and keeps one that says more", () => {
451 const events = buildPullRequestTimeline({
452 ...TIMELINE_SOURCE,
453 comments: [
454 { ...TIMELINE_SOURCE.comments[0]!, body: "<!-- MURMUR_IGNORE -->" },
455 {
456 ...TIMELINE_SOURCE.comments[0]!,
457 id: "c2",
458 body: "<!-- summarize by coderabbit.ai -->\nNeeds a test.",
459 createdAt: "2026-07-04T00:00:00Z",
460 },
461 ],
462 });
463 expect(events.find((event) => event.id === "c1")?.body).toBeNull();
464 // Kept whole: the renderer drops the marker itself, and stripping it here would also
465 // strip an HTML comment a reviewer quoted inside a code fence.
466 expect(events.find((event) => event.id === "c2")?.body).toBe(
467 "<!-- summarize by coderabbit.ai -->\nNeeds a test.",
468 );
469 });
470
471 it("calls a comment markdown and a commit headline plain text", () => {
472 const events = buildPullRequestTimeline(TIMELINE_SOURCE);
473 // A headline reading `fix: drop *legacy* path` is not asking for emphasis.
474 expect(events.map((event) => [event.title.startsWith("Commit"), event.markdown])).toEqual(
475 expect.arrayContaining([[true, false]]),
476 );
477 expect(events.find((event) => event.id === "c1")?.markdown).toBe(true);
478 });
479
480 it("reports a merge rather than the close GitHub records alongside it", () => {
481 const events = buildPullRequestTimeline({
482 ...TIMELINE_SOURCE,
483 mergedAt: "2026-07-04T00:00:00Z",
484 closedAt: "2026-07-04T00:00:00Z",
485 });
486 // Newest first, so the terminal event opens the list rather than ending it.
487 expect(events[0]?.id).toBe("merged");
488 expect(events.some((event) => event.id === "closed")).toBe(false);
489 });
490
491 it("groups conversation sections without crossing commits or PR updates", () => {
492 const events = buildPullRequestTimeline({
493 ...TIMELINE_SOURCE,
494 comments: [
495 {
496 ...TIMELINE_SOURCE.comments[0]!,
497 id: "new-comment-1",
498 createdAt: "2026-07-04T00:00:00Z",
499 },
500 {
501 ...TIMELINE_SOURCE.comments[0]!,
502 id: "new-comment-2",
503 createdAt: "2026-07-03T00:00:00Z",
504 },
505 {
506 ...TIMELINE_SOURCE.comments[0]!,
507 id: "old-comment-1",
508 createdAt: "2026-07-01T12:00:00Z",
509 },
510 {
511 ...TIMELINE_SOURCE.comments[0]!,
512 id: "old-comment-2",
513 createdAt: "2026-07-01T06:00:00Z",
514 },
515 ],
516 mergedAt: "2026-07-05T00:00:00Z",
517 });
518
519 const rows = groupPullRequestTimelineConversations(events);
520 expect(
521 rows.map((row) =>
522 row.kind === "comments"
523 ? [row.kind, ...row.events.map((event) => event.id)]
524 : [row.kind, row.event.id],
525 ),
526 ).toEqual([
527 ["event", "merged"],
528 ["comments", "new-comment-1", "new-comment-2"],
529 ["event", "1baf7bdcafe"],
530 ["comments", "old-comment-1", "old-comment-2"],
531 ["event", "created"],
532 ]);
533 });
534
535 it("keeps a verdict out of the collapsed conversation it was submitted in", () => {
536 const events = buildPullRequestTimeline({
537 ...TIMELINE_SOURCE,
538 comments: [
539 { ...TIMELINE_SOURCE.comments[0]!, id: "chatter-1", createdAt: "2026-07-05T00:00:00Z" },
540 {
541 ...TIMELINE_SOURCE.comments[0]!,
542 id: "approval",
543 kind: "review",
544 body: "",
545 reviewState: "APPROVED",
546 createdAt: "2026-07-04T00:00:00Z",
547 },
548 { ...TIMELINE_SOURCE.comments[0]!, id: "chatter-2", createdAt: "2026-07-03T00:00:00Z" },
549 // A review without a verdict is ordinary conversation and still groups.
550 {
551 ...TIMELINE_SOURCE.comments[0]!,
552 id: "remark",
553 kind: "review",
554 reviewState: "COMMENTED",
555 createdAt: "2026-07-02T12:00:00Z",
556 },
557 ],
558 });
559
560 const rows = groupPullRequestTimelineConversations(events);
561 expect(
562 rows.map((row) =>
563 row.kind === "comments"
564 ? [row.kind, ...row.events.map((event) => event.id)]
565 : [row.kind, row.event.id],
566 ),
567 ).toEqual([
568 ["comments", "chatter-1"],
569 ["event", "approval"],
570 ["comments", "chatter-2", "remark"],
571 ["event", "1baf7bdcafe"],
572 ["event", "created"],
573 ]);
574 });
575});
576
577describe("fix findings handoff", () => {
578 const base = {
579 number: 42,
580 title: "Add the pull requests page",
581 url: "https://github.com/pingdotgg/t3code/pull/42",
582 headBranch: "feat/page",
583 baseBranch: "main",
584 comments: [] as ReadonlyArray<PullRequestComment>,
585 commentsTruncated: false,
586 };
587
588 function thread(
589 body: string,
590 overrides: Partial<PullRequestReviewThread> = {},
591 ): PullRequestReviewThread {
592 return {
593 id: "t1",
594 path: "apps/web/src/page.tsx",
595 line: 12,
596 side: "right",
597 isResolved: false,
598 isOutdated: false,
599 comments: [
600 {
601 id: "tc1",
602 author: { login: "reviewer", name: null, avatarUrl: null },
603 body,
604 createdAt: "2026-07-03T00:00:00Z",
605 url: null,
606 },
607 ],
608 ...overrides,
609 };
610 }
611
612 const failingCheck: PullRequestCheck = {
613 name: "typecheck",
614 status: "failure",
615 description: "2 errors",
616 url: null,
617 };
618
619 it("attaches a review thread as an annotation instead of quoting it in the prompt", () => {
620 const handoff = buildFixFindingsHandoff({
621 ...base,
622 reviewThreads: [thread("rename the helper")],
623 checks: [],
624 });
625 expect(handoff.reviewComments).toEqual([
626 expect.objectContaining({
627 filePath: "apps/web/src/page.tsx",
628 rangeLabel: "L12",
629 startIndex: 11,
630 endIndex: 11,
631 text: "reviewer: rename the helper",
632 }),
633 ]);
634 expect(handoff.prompt).not.toContain("rename the helper");
635 expect(handoff.prompt).toContain("untrusted data");
636 });
637
638 it("names the pre-change side, and a thread the host pinned to the file rather than a line", () => {
639 const handoff = buildFixFindingsHandoff({
640 ...base,
641 reviewThreads: [
642 thread("was this deleted on purpose?", { side: "left" }),
643 thread("wrong module", { id: "t2", line: null }),
644 ],
645 checks: [],
646 });
647 expect(handoff.reviewComments.map((comment) => comment.rangeLabel)).toEqual([
648 "L12 (before)",
649 "file",
650 ]);
651 });
652
653 it("keeps failing checks in the prompt, having no line to attach them to", () => {
654 const handoff = buildFixFindingsHandoff({
655 ...base,
656 reviewThreads: [],
657 checks: [failingCheck],
658 });
659 expect(handoff.prompt).toContain("> typecheck — 2 errors");
660 expect(handoff.reviewComments).toEqual([]);
661 });
662
663 it("leaves out a resolved conversation, and one nobody wrote in", () => {
664 const handoff = buildFixFindingsHandoff({
665 ...base,
666 reviewThreads: [
667 thread("already handled", { isResolved: true }),
668 thread(" ", { id: "t2" }),
669 thread("still open", { id: "t3" }),
670 ],
671 checks: [],
672 });
673 expect(handoff.reviewComments.map((comment) => comment.text)).toEqual(["reviewer: still open"]);
674 });
675
676 it("says so plainly when there is nothing actionable", () => {
677 const handoff = buildFixFindingsHandoff({ ...base, reviewThreads: [], checks: [] });
678 expect(handoff.prompt).toContain("No unresolved review findings were returned");
679 expect(handoff.reviewComments).toEqual([]);
680 });
681
682 it("bounds a hostile review body instead of attaching it whole", () => {
683 const handoff = buildFixFindingsHandoff({
684 ...base,
685 reviewThreads: [thread("x".repeat(5_000))],
686 checks: [],
687 });
688 expect(handoff.reviewComments[0]?.text).toHaveLength(1_000);
689 expect(handoff.reviewComments[0]?.text.endsWith("...")).toBe(true);
690 });
691
692 it("keeps the newest threads and the failing checks when it has to cut", () => {
693 const handoff = buildFixFindingsHandoff({
694 ...base,
695 reviewThreads: Array.from({ length: 25 }, (_, index) =>
696 thread(`finding ${index}`, { id: `t${index}` }),
697 ),
698 checks: [failingCheck],
699 });
700 // Oldest threads are dropped rather than the current failure and the recent feedback.
701 const texts = handoff.reviewComments.map((comment) => comment.text);
702 expect(texts).toHaveLength(19);
703 expect(texts.at(-1)).toBe("reviewer: finding 24");
704 expect(texts).not.toContain("reviewer: finding 0");
705 expect(handoff.prompt).toContain("typecheck");
706 expect(handoff.prompt).toContain("6 further findings were omitted");
707 });
708});
709
710describe("findings that cannot be attached", () => {
711 const base = {
712 number: 42,
713 title: "Add the pull requests page",
714 url: "https://github.com/pingdotgg/t3code/pull/42",
715 headBranch: "feat/page",
716 baseBranch: "main",
717 reviewThreads: [] as ReadonlyArray<PullRequestReviewThread>,
718 checks: [] as ReadonlyArray<PullRequestCheck>,
719 commentsTruncated: false,
720 };
721
722 const review: PullRequestComment = {
723 id: "r1",
724 kind: "review",
725 author: { login: "julius", name: null, avatarUrl: null },
726 body: "This breaks SSO auth, revert the middleware change.",
727 createdAt: "2026-07-01T00:00:00Z",
728 url: null,
729 path: null,
730 reviewState: "CHANGES_REQUESTED",
731 };
732
733 it("carries a review submitted with words but no line, which has nothing to attach to", () => {
734 const handoff = buildFixFindingsHandoff({ ...base, comments: [review] });
735
736 // It has no file and no line, so it travels the way a failing check does rather than
737 // being dropped for lacking somewhere to point.
738 expect(handoff.reviewComments).toEqual([]);
739 expect(handoff.prompt).toContain("revert the middleware change");
740 expect(handoff.prompt).not.toContain("No unresolved review findings");
741 });
742
743 it("carries a host's line comments when it reports no threads at all", () => {
744 // Azure DevOps has no diff to pin a conversation to, so every remark arrives this way.
745 const handoff = buildFixFindingsHandoff({
746 ...base,
747 comments: [{ ...review, id: "a1", kind: "review-comment", path: "src/app.ts" }],
748 });
749
750 expect(handoff.prompt).toContain("src/app.ts");
751 expect(handoff.prompt).toContain("revert the middleware change");
752 });
753
754 it("does not repeat a remark that was already attached as a thread", () => {
755 const attachedId = "t1c1";
756 const handoff = buildFixFindingsHandoff({
757 ...base,
758 reviewThreads: [
759 {
760 id: "t1",
761 path: "src/app.ts",
762 line: 12,
763 side: "right",
764 isResolved: false,
765 isOutdated: false,
766 comments: [
767 {
768 id: attachedId,
769 author: { login: "julius", name: null, avatarUrl: null },
770 body: "rename the helper",
771 createdAt: "2026-07-01T00:00:00Z",
772 url: null,
773 },
774 ],
775 },
776 ],
777 comments: [{ ...review, id: attachedId, kind: "review-comment", body: "rename the helper" }],
778 });
779
780 expect(handoff.reviewComments).toHaveLength(1);
781 expect(handoff.prompt).not.toContain("rename the helper");
782 });
783});
784
785describe("one finding handed over on its own", () => {
786 const base = {
787 number: 42,
788 title: "Add the pull requests page",
789 url: "https://github.com/pingdotgg/t3code/pull/42",
790 headBranch: "feat/page",
791 baseBranch: "main",
792 };
793
794 const reviewThread: PullRequestReviewThread = {
795 id: "t1",
796 path: "apps/web/src/page.tsx",
797 line: 12,
798 side: "right",
799 isResolved: true,
800 isOutdated: false,
801 comments: [
802 {
803 id: "tc1",
804 author: { login: "reviewer", name: null, avatarUrl: null },
805 body: "rename the helper",
806 createdAt: "2026-07-03T00:00:00Z",
807 url: null,
808 },
809 ],
810 };
811
812 it("attaches a thread as its own annotation, resolved or not", () => {
813 // The bulk handoff skips resolved threads as finished work. Pressing the button on one is
814 // an explicit request for that thread, so it is not second-guessed.
815 const handoff = buildFixFindingHandoff({
816 ...base,
817 finding: { kind: "thread", thread: reviewThread },
818 });
819 expect(handoff.reviewComments).toEqual([
820 expect.objectContaining({ filePath: "apps/web/src/page.tsx", rangeLabel: "L12" }),
821 ]);
822 expect(handoff.prompt).toContain("attached to this message");
823 expect(handoff.prompt).not.toContain("rename the helper");
824 });
825
826 it("quotes a review remark, which has no line to attach it to", () => {
827 const handoff = buildFixFindingHandoff({
828 ...base,
829 finding: {
830 kind: "comment",
831 comment: {
832 id: "c1",
833 kind: "review",
834 author: { login: "julius", name: null, avatarUrl: null },
835 body: "this breaks SSO auth",
836 createdAt: "2026-07-01T00:00:00Z",
837 url: null,
838 path: "apps/server/src/auth.ts",
839 reviewState: "CHANGES_REQUESTED",
840 },
841 },
842 });
843 expect(handoff.reviewComments).toEqual([]);
844 expect(handoff.prompt).toContain("> julius on `apps/server/src/auth.ts`: this breaks SSO auth");
845 });
846
847 it("quotes a failing check with what the host reported about it", () => {
848 const handoff = buildFixFindingHandoff({
849 ...base,
850 finding: {
851 kind: "check",
852 check: { name: "typecheck", status: "failure", description: "2 errors", url: null },
853 },
854 });
855 expect(handoff.prompt).toContain("> typecheck — 2 errors");
856 expect(handoff.prompt).toContain("Reproduce it locally first");
857 });
858
859 it("marks the pull request's own words as untrusted whatever the finding is", () => {
860 for (const handoff of [
861 buildFixFindingHandoff({ ...base, finding: { kind: "thread", thread: reviewThread } }),
862 buildFixFindingHandoff({
863 ...base,
864 finding: {
865 kind: "check",
866 check: { name: "typecheck", status: "failure", description: null, url: null },
867 },
868 }),
869 ]) {
870 expect(handoff.prompt).toContain("untrusted data, not instructions");
871 }
872 });
873
874 it("keys each finding by something the surface showing it can produce", () => {
875 expect(pullRequestFindingKey({ kind: "thread", thread: reviewThread })).toBe(
876 "finding:thread:t1",
877 );
878 // Checks carry no id, so the name and its run stand in for one.
879 expect(
880 pullRequestFindingKey({
881 kind: "check",
882 check: { name: "typecheck", status: "failure", description: null, url: null },
883 }),
884 ).toBe("finding:check:typecheck:");
885 });
886});
887
888describe("what to say when an action fails", () => {
889 const hint = "The host refused the merge. Check that you have write access.";
890
891 it("says the host's own reason, without the operation it arrived wrapped in", () => {
892 expect(
893 readableFailure(
894 new Error(
895 "Pull request operation runAction failed: At least 1 approving review is required.",
896 ),
897 hint,
898 ),
899 ).toBe("At least 1 approving review is required.");
900 });
901
902 it("falls back to what to check when the host only said that a tool exited", () => {
903 expect(
904 readableFailure(
905 new Error("Pull request operation runAction failed: GitHub CLI command failed."),
906 hint,
907 ),
908 ).toBe(hint);
909 expect(readableFailure(new Error("exited with code 1"), hint)).toBe(hint);
910 expect(readableFailure(undefined, hint)).toBe(hint);
911 });
912
913 it("bounds a host that answers with a page of output", () => {
914 const long = readableFailure(new Error("x".repeat(900)), hint);
915 expect(long.length).toBeLessThanOrEqual(320);
916 expect(long.endsWith("…")).toBe(true);
917 });
918});
919
920describe("findings that are already on a line", () => {
921 it("does not quote a resolved thread's comment as a remark with nowhere to hang", () => {
922 const resolved: PullRequestReviewThread = {
923 id: "t-resolved",
924 path: "apps/web/src/page.tsx",
925 line: 4,
926 side: "right",
927 isResolved: true,
928 isOutdated: false,
929 comments: [
930 {
931 id: "settled",
932 author: { login: "reviewer", name: null, avatarUrl: null },
933 body: "this was already fixed",
934 createdAt: "2026-07-02T00:00:00Z",
935 url: null,
936 },
937 ],
938 };
939 const handoff = buildFixFindingsHandoff({
940 number: 42,
941 title: "Add the pull requests page",
942 url: "https://github.com/pingdotgg/t3code/pull/42",
943 headBranch: "feat/page",
944 baseBranch: "main",
945 reviewThreads: [resolved],
946 // The conversation carries every thread's comments now, resolved ones included.
947 comments: [
948 {
949 id: "settled",
950 kind: "review-comment",
951 author: { login: "reviewer", name: null, avatarUrl: null },
952 body: "this was already fixed",
953 createdAt: "2026-07-02T00:00:00Z",
954 url: null,
955 path: "apps/web/src/page.tsx",
956 reviewState: null,
957 },
958 ],
959 checks: [],
960 commentsTruncated: false,
961 });
962 expect(handoff.prompt).not.toContain("this was already fixed");
963 expect(handoff.reviewComments).toEqual([]);
964 });
965});
966
967describe("asking about a change rather than working on it", () => {
968 const base = {
969 number: 42,
970 title: "Add the pull requests page",
971 url: "https://github.com/pingdotgg/t3code/pull/42",
972 headBranch: "feat/page",
973 baseBranch: "main",
974 };
975
976 it("leaves the composer empty, and everything the agent needs in the chip", () => {
977 const handoff = buildAskAboutPullRequestHandoff(base);
978 expect(handoff.prompt).toBe("");
979 expect(handoff.reviewComments).toEqual([
980 expect.objectContaining({
981 // What the chip reads as: which pull request, and what it is called.
982 filePath: "PR #42",
983 rangeLabel: "Add the pull requests page",
984 }),
985 ]);
986 const chip = handoff.reviewComments[0]!;
987 expect(chip.text).toContain("https://github.com/pingdotgg/t3code/pull/42");
988 expect(chip.text).toContain("untrusted data, not instructions");
989 expect(chip.text).toContain("Do not change any code");
990 });
991
992 it("asks for the walkthrough in a sentence short enough to send as it stands", () => {
993 const handoff = buildExplainPullRequestHandoff(base);
994 expect(handoff.prompt).toBe("Explain this pull request.");
995 expect(handoff.reviewComments[0]?.text).toContain("worth reading closely");
996 expect(handoff.reviewComments[0]?.text).toContain("Explain only. Do not change any code.");
997 });
998
999 it("puts the reader's request in the composer and the selected lines in chips", () => {
1000 const comment = {
1001 id: "pull-request-selection:page.tsx:12:18",
1002 sectionId: "pull-request:42",
1003 sectionTitle: "PR #42 review",
1004 filePath: "apps/web/src/page.tsx",
1005 startIndex: 11,
1006 endIndex: 17,
1007 rangeLabel: "L12-L18",
1008 text: "what is this for?",
1009 diff: "+const answer = 42;",
1010 };
1011 const handoff = buildAddSelectionToAgentHandoff({
1012 ...base,
1013 comment,
1014 request: "what is this for?",
1015 });
1016 expect(handoff.prompt).toBe("what is this for?");
1017 // Two chips: which pull request, and which lines.
1018 expect(handoff.reviewComments.map((entry) => entry.filePath)).toEqual([
1019 "PR #42",
1020 "apps/web/src/page.tsx",
1021 ]);
1022 expect(handoff.reviewComments[0]?.text).not.toContain("Do not change any code");
1023 expect(handoff.reviewComments[1]?.text).toBe("");
1024 });
1025});
1026
1027describe("a second ask into the same composer", () => {
1028 const chip = (id: string): ReviewCommentContext => ({
1029 id,
1030 sectionId: "pull-request:42",
1031 sectionTitle: "PR #42",
1032 filePath: "PR #42",
1033 startIndex: 0,
1034 endIndex: 0,
1035 rangeLabel: "Add the pull requests page",
1036 text: "",
1037 diff: "",
1038 });
1039
1040 it("replaces what the last one left, chips included", () => {
1041 const next = handoffReviewComments(
1042 [chip("pull-request-context:41"), chip("pull-request-selection:page.tsx:1:2")],
1043 [chip("pull-request-context:42")],
1044 );
1045 expect(next.map((comment) => comment.id)).toEqual(["pull-request-context:42"]);
1046 });
1047
1048 it("empties what the last ask left, so the two are never sent as one question", () => {
1049 const handed = "Explain this pull request.";
1050 expect(handoffPrompt({ prompt: handed, lastHandoffPrompt: handed }, "")).toBe("");
1051 });
1052
1053 it("replaces the last ask's prompt with this one's", () => {
1054 const handed = "Explain this pull request.";
1055 expect(handoffPrompt({ prompt: handed, lastHandoffPrompt: handed }, "Why the cache key?")).toBe(
1056 "Why the cache key?",
1057 );
1058 });
1059
1060 it("leaves a sentence the reader typed themselves where it is", () => {
1061 expect(
1062 handoffPrompt({ prompt: "check the migration first", lastHandoffPrompt: undefined }, ""),
1063 ).toBe("check the migration first");
1064 });
1065
1066 it("keeps what the reader wrote next to the chip an earlier ask left", () => {
1067 // The chip is still there, but these words are not the ones the hand-off wrote.
1068 expect(
1069 handoffPrompt({ prompt: "why is the cache keyed on the branch?", lastHandoffPrompt: "" }, ""),
1070 ).toBe("why is the cache keyed on the branch?");
1071 });
1072
1073 it("keeps an edit the reader made to the sentence they were handed", () => {
1074 expect(
1075 handoffPrompt(
1076 {
1077 prompt: "Explain this pull request, the caching especially.",
1078 lastHandoffPrompt: "Explain this pull request.",
1079 },
1080 "",
1081 ),
1082 ).toBe("Explain this pull request, the caching especially.");
1083 });
1084
1085 it("puts an ask under what the reader typed rather than over it", () => {
1086 expect(
1087 handoffPrompt(
1088 { prompt: "check the migration first", lastHandoffPrompt: undefined },
1089 "Explain this pull request.",
1090 ),
1091 ).toBe("check the migration first\n\nExplain this pull request.");
1092 });
1093
1094 it("replaces only its own sentence under text the reader typed", () => {
1095 expect(
1096 handoffPrompt(
1097 {
1098 prompt: "check the migration first\n\nExplain this pull request.",
1099 lastHandoffPrompt: "Explain this pull request.",
1100 },
1101 "Why the cache key?",
1102 ),
1103 ).toBe("check the migration first\n\nWhy the cache key?");
1104 });
1105
1106 it("takes back only its own sentence when the next ask is empty", () => {
1107 expect(
1108 handoffPrompt(
1109 {
1110 prompt: "check the migration first\n\nExplain this pull request.",
1111 lastHandoffPrompt: "Explain this pull request.",
1112 },
1113 "",
1114 ),
1115 ).toBe("check the migration first");
1116 });
1117
1118 it("keeps the lines the reader marked up in the thread themselves", () => {
1119 const own = chip("file-comment:3");
1120 const next = handoffReviewComments(
1121 [own, chip("pull-request-finding:t1")],
1122 [chip("pull-request-context:42")],
1123 );
1124 expect(next.map((comment) => comment.id)).toEqual([
1125 "file-comment:3",
1126 "pull-request-context:42",
1127 ]);
1128 });
1129});
1130
1131describe("how the branch stands against its base", () => {
1132 const detail = (overrides: Record<string, unknown> = {}) =>
1133 ({
1134 state: "open",
1135 mergeability: "mergeable",
1136 baseComparison: "behind",
1137 behindBy: 12,
1138 capabilities: { updateMethods: ["merge", "rebase"] },
1139 viewerPermissions: { updateMethods: ["merge", "rebase"] },
1140 ...overrides,
1141 }) as Parameters<typeof resolveBaseFreshness>[0];
1142
1143 it("offers both ways where the host and the reader both allow them", () => {
1144 expect(resolveBaseFreshness(detail())).toEqual({ behindBy: 12, methods: ["merge", "rebase"] });
1145 });
1146
1147 it("says nothing about a branch that is already current", () => {
1148 expect(resolveBaseFreshness(detail({ baseComparison: "up-to-date" }))).toBeNull();
1149 });
1150
1151 it("says nothing where the host could not compare, rather than claiming it is current", () => {
1152 expect(resolveBaseFreshness(detail({ baseComparison: "unknown" }))).toBeNull();
1153 expect(resolveBaseFreshness(detail({ baseComparison: undefined }))).toBeNull();
1154 });
1155
1156 it("leaves a conflicting branch to the conflicts row", () => {
1157 expect(resolveBaseFreshness(detail({ mergeability: "conflicting" }))).toBeNull();
1158 });
1159
1160 it("says nothing where the host has no merge verdict yet", () => {
1161 expect(resolveBaseFreshness(detail({ mergeability: "unknown" }))).toBeNull();
1162 });
1163
1164 it("says nothing about a merged or closed pull request", () => {
1165 expect(resolveBaseFreshness(detail({ state: "merged" }))).toBeNull();
1166 expect(resolveBaseFreshness(detail({ state: "closed" }))).toBeNull();
1167 });
1168
1169 it("narrows to what this reader may actually take", () => {
1170 expect(
1171 resolveBaseFreshness(detail({ viewerPermissions: { updateMethods: ["merge"] } }))?.methods,
1172 ).toEqual(["merge"]);
1173 });
1174
1175 it("still reports the news where the reader may take none of it", () => {
1176 // Somebody reading another account's pull request is told why it is blocked without being
1177 // offered a button the host would refuse.
1178 expect(resolveBaseFreshness(detail({ viewerPermissions: {} }))).toEqual({
1179 behindBy: 12,
1180 methods: [],
1181 });
1182 });
1183
1184 it("reports a count only where the host counted", () => {
1185 expect(resolveBaseFreshness(detail({ behindBy: undefined }))?.behindBy).toBeNull();
1186 });
1187});
1188
1189describe("whether the panel is showing the thread's own pull request", () => {
1190 const surface = { projectId: "proj-a", repository: "acme/app", number: 7 };
1191
1192 it("matches on project, repository and number together", () => {
1193 expect(
1194 isThreadOwnPullRequest({ projectId: "proj-a", repository: "acme/app", number: 7 }, surface),
1195 ).toBe(true);
1196 });
1197
1198 it("rejects a second checkout of the same repository under another project", () => {
1199 expect(
1200 isThreadOwnPullRequest({ projectId: "proj-b", repository: "acme/app", number: 7 }, surface),
1201 ).toBe(false);
1202 });
1203
1204 it("rejects another repository or another number", () => {
1205 expect(
1206 isThreadOwnPullRequest({ projectId: "proj-a", repository: "acme/web", number: 7 }, surface),
1207 ).toBe(false);
1208 expect(
1209 isThreadOwnPullRequest({ projectId: "proj-a", repository: "acme/app", number: 8 }, surface),
1210 ).toBe(false);
1211 });
1212
1213 it("rejects a thread with no project or no pull request of its own", () => {
1214 expect(
1215 isThreadOwnPullRequest({ projectId: null, repository: "acme/app", number: 7 }, surface),
1216 ).toBe(false);
1217 expect(
1218 isThreadOwnPullRequest(
1219 { projectId: "proj-a", repository: "acme/app", number: null },
1220 surface,
1221 ),
1222 ).toBe(false);
1223 });
1224});
1225
1226describe("which actions need the host read again after they run", () => {
1227 it("classifies every action the contract knows about", () => {
1228 // Imported from the contract rather than hand-listed, so a new PullRequestAction fails this
1229 // test until somebody decides which side of the diff it belongs on.
1230 expect(PullRequestAction.literals.map(pullRequestActionNeedsHostRefresh)).toEqual(
1231 PullRequestAction.literals.map((action) => action === "update-branch"),
1232 );
1233 });
1234
1235 it("sends update-branch back to the host, having moved the head commit", () => {
1236 expect(pullRequestActionNeedsHostRefresh("update-branch")).toBe(true);
1237 });
1238
1239 it("leaves every action that only changes metadata to the cheaper detail refresh", () => {
1240 for (const action of [
1241 "ready",
1242 "draft",
1243 "close",
1244 "reopen",
1245 "enable-auto-merge",
1246 "disable-auto-merge",
1247 "merge",
1248 ] as const) {
1249 expect(pullRequestActionNeedsHostRefresh(action)).toBe(false);
1250 }
1251 });
1252});
1253
1254describe("the compact row's single action slot", () => {
1255 const check = (status: PullRequestCheck["status"]): PullRequestCheck => ({
1256 name: "ci",
1257 status,
1258 description: null,
1259 url: null,
1260 });
1261 const openDetail = (
1262 overrides: Partial<Parameters<typeof resolveThreadPanelPullRequestAction>[0] & object> = {},
1263 ) =>
1264 ({
1265 state: "open",
1266 isDraft: false,
1267 mergeability: "mergeable",
1268 capabilities: {
1269 actions: ["merge", "ready", "draft", "close", "reopen"],
1270 mergeMethods: ["merge", "squash"],
1271 } as unknown as PullRequestDetailView["capabilities"],
1272 viewerPermissions: {
1273 actions: ["merge", "ready", "draft", "close", "reopen"],
1274 } as unknown as PullRequestDetailView["viewerPermissions"],
1275 mergeCapabilities: { merge: true, squash: true, rebase: false },
1276 checks: [check("success")],
1277 ...overrides,
1278 }) as NonNullable<Parameters<typeof resolveThreadPanelPullRequestAction>[0]>;
1279
1280 it("offers Merge only for a clean pull request whose checks pass", () => {
1281 expect(resolveThreadPanelPullRequestAction(openDetail())).toBe("merge");
1282 expect(resolveThreadPanelPullRequestAction(openDetail({ checks: [] }))).toBe("merge");
1283 });
1284
1285 it("holds the slot while checks run rather than offering a merge that races them", () => {
1286 expect(
1287 resolveThreadPanelPullRequestAction(
1288 openDetail({ checks: [check("success"), check("pending")] }),
1289 ),
1290 ).toBeNull();
1291 });
1292
1293 it("ranks conflicts above everything, then draft, then failing checks", () => {
1294 expect(
1295 resolveThreadPanelPullRequestAction(
1296 openDetail({ mergeability: "conflicting", isDraft: true, checks: [check("failure")] }),
1297 ),
1298 ).toBe("resolve");
1299 expect(
1300 resolveThreadPanelPullRequestAction(
1301 openDetail({ isDraft: true, checks: [check("failure")] }),
1302 ),
1303 ).toBe("ready");
1304 expect(
1305 resolveThreadPanelPullRequestAction(
1306 openDetail({ checks: [check("failure"), check("pending")] }),
1307 ),
1308 ).toBe("fix");
1309 });
1310
1311 it("offers nothing the viewer may not do, and nothing on settled pull requests", () => {
1312 expect(
1313 resolveThreadPanelPullRequestAction(
1314 openDetail({
1315 viewerPermissions: {
1316 actions: [],
1317 } as unknown as PullRequestDetailView["viewerPermissions"],
1318 }),
1319 ),
1320 ).toBeNull();
1321 expect(resolveThreadPanelPullRequestAction(openDetail({ state: "merged" }))).toBeNull();
1322 expect(resolveThreadPanelPullRequestAction(null)).toBeNull();
1323 });
1324
1325 it("describes every live facet of the checks at once", () => {
1326 expect(describePullRequestChecks([])).toBe("No checks reported");
1327 expect(describePullRequestChecks([check("success"), check("success")])).toBe(
1328 "All checks passed",
1329 );
1330 expect(describePullRequestChecks([check("success"), check("skipped")])).toBe("1 of 2 passing");
1331 expect(
1332 describePullRequestChecks([
1333 ...Array.from({ length: 7 }, () => check("pending")),
1334 ...Array.from({ length: 8 }, () => check("success")),
1335 check("failure"),
1336 ]),
1337 ).toBe("7 of 16 running · 1 failed");
1338 expect(describePullRequestChecks([check("failure"), check("success")])).toBe("1 of 2 failing");
1339 });
1340
1341 it("reads the checks as one word, failing outranking running", () => {
1342 expect(classifyPullRequestChecks([])).toBe("none");
1343 expect(classifyPullRequestChecks([check("success"), check("skipped")])).toBe("passing");
1344 expect(classifyPullRequestChecks([check("success"), check("pending")])).toBe("pending");
1345 expect(classifyPullRequestChecks([check("pending"), check("cancelled")])).toBe("failing");
1346 });
1347});