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

GitHubPullRequestProvider.test.ts

772 lines24.3 KB

1import { describe, expect, it } from "@effect/vitest";
2import * as Effect from "effect/Effect";
3import * as Layer from "effect/Layer";
4import * as Redacted from "effect/Redacted";
5import type { PullRequestReaction } from "@t3tools/contracts";
6​
7import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
8import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
9import * as GitHubPullRequestApi from "./GitHubPullRequestApi.ts";
10import type { GitHubPullRequestCore } from "./gitHubPullRequestJson.ts";
11import { gitHubViewerPermissions, loginAvatarUrl, make } from "./GitHubPullRequestProvider.ts";
12import type { GitHubReviewThreadComments } from "./gitHubPullRequestJson.ts";
13​
14const coreFields = {
15 reviewRequestTeams: [],
16 checksTruncated: false,
17 comparison: { behindBy: 0, viewerCanUpdate: true },
18 viewerAccess: {
19 canWrite: true,
20 canTriage: true,
21 canUpdate: true,
22 didAuthor: false,
23 mergeCapabilities: { merge: true, squash: true, rebase: true },
24 autoMergeAllowed: true,
25 },
26};
27​
28it.effect("maps credential verification failures without relabeling operation failures", () =>
29 Effect.gen(function* () {
30 let verificationFails = true;
31 let operations = 0;
32 const provider = yield* make.pipe(
33 Effect.provide(
34 Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
35 revalidateChecks: (_input, read) => read,
36 withVerifiedCredential: (_input, use) =>
37 verificationFails
38 ? Effect.fail(
39 new GitHubPullRequestApi.GitHubViewerLoginUnavailableError({
40 cwd: "/w",
41 }),
42 )
43 : use({ accountId: "123", viewer: "viewer", credentialFingerprint: "fingerprint" }),
44 }),
45 ),
46 );
47 const verify = provider.withVerifiedCredential;
48 if (verify === undefined)
49 return yield* Effect.die("credential verification was not implemented");
50 const input = { cwd: "/w", host: "github.com" };
51 const operation = () =>
52 Effect.sync(() => {
53 operations++;
54 }).pipe(Effect.andThen(Effect.fail("operation-failed")));
55 expect(yield* verify(input, operation).pipe(Effect.flip)).toMatchObject({
56 _tag: "PullRequestProviderError",
57 operation: "routeIdentity",
58 });
59 expect(operations).toBe(0);
60 verificationFails = false;
61 expect(yield* verify(input, operation).pipe(Effect.flip)).toBe("operation-failed");
62 expect(operations).toBe(1);
63 }),
64);
65​
66it.effect("advertises standalone branch deletion for source repository writers", () =>
67 Effect.gen(function* () {
68 let action: string | undefined;
69 const provider = yield* make.pipe(
70 Effect.provide(
71 Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
72 runPullRequestAction: (input) =>
73 Effect.sync(() => {
74 action = input.action;
75 }),
76 }),
77 ),
78 );
79 expect(provider.capabilities.deleteBranch).toBe(true);
80 expect(provider.capabilities.actions).toContain("delete-branch");
81 yield* provider.runAction({
82 cwd: "/w",
83 repository: "acme/web",
84 host: "github.com",
85 number: 7,
86 action: "delete-branch",
87 });
88 expect(action).toBe("delete-branch");
89 const access = {
90 canWrite: false,
91 canTriage: false,
92 canUpdate: false,
93 didAuthor: false,
94 canDeleteBranch: true,
95 autoMergeAllowed: true,
96 };
97 expect(gitHubViewerPermissions(access).actions).toContain("delete-branch");
98 expect(
99 gitHubViewerPermissions({
100 ...access,
101 canWrite: true,
102 didAuthor: true,
103 canDeleteBranch: false,
104 }).actions,
105 ).not.toContain("delete-branch");
106 }),
107);
108​
109describe("gitHubViewerPermissions", () => {
110 it("offers everything to a viewer who can write to the repository", () => {
111 expect(
112 gitHubViewerPermissions({
113 canWrite: true,
114 canDeleteBranch: true,
115 canTriage: true,
116 canUpdate: true,
117 didAuthor: false,
118 autoMergeAllowed: true,
119 }),
120 ).toEqual({
121 actions: [
122 "delete-branch",
123 "merge",
124 "enable-auto-merge",
125 "disable-auto-merge",
126 "revert",
127 "approve-workflows",
128 "ready",
129 "draft",
130 "close",
131 "reopen",
132 ],
133 comment: true,
134 resolve: true,
135 stackRebase: true,
136 verdicts: ["comment", "approve", "request-changes"],
137 requestReviewers: true,
138 labels: true,
139 });
140 });
141​
142 it("leaves a passer-by on a repository they can only read nothing but the review", () => {
143 expect(
144 gitHubViewerPermissions({
145 canWrite: false,
146 canTriage: false,
147 canUpdate: false,
148 didAuthor: false,
149 autoMergeAllowed: true,
150 }),
151 ).toEqual({
152 actions: [],
153 comment: true,
154 resolve: false,
155 verdicts: ["comment", "approve", "request-changes"],
156 requestReviewers: false,
157 labels: false,
158 });
159 });
160​
161 it("lets a triager label without letting them merge or ask for a review", () => {
162 const permissions = gitHubViewerPermissions({
163 canWrite: false,
164 canTriage: true,
165 canUpdate: false,
166 didAuthor: false,
167 autoMergeAllowed: true,
168 });
169 expect(permissions.labels).toBe(true);
170 expect(permissions.requestReviewers).toBe(false);
171 expect(permissions.actions).toEqual([]);
172 });
173​
174 it("keeps an author's own pull request theirs to close, with read access and no more", () => {
175 expect(
176 gitHubViewerPermissions({
177 canWrite: false,
178 canTriage: false,
179 canUpdate: true,
180 didAuthor: true,
181 autoMergeAllowed: true,
182 }),
183 ).toEqual({
184 actions: ["ready", "draft", "close", "reopen"],
185 comment: true,
186 resolve: true,
187 verdicts: ["comment"],
188 requestReviewers: false,
189 labels: false,
190 });
191 });
192​
193 it.effect("uses the permissions carried by the core read without a second request", () =>
194 Effect.gen(function* () {
195 const provider = yield* make;
196 const detail = yield* provider.getChangeRequest({
197 cwd: "/w",
198 repository: "acme/web",
199 host: "github.com",
200 number: 7,
201 });
202​
203 expect(detail.viewerPermissions).toEqual({
204 actions: ["ready", "draft", "close", "reopen"],
205 comment: true,
206 resolve: false,
207 verdicts: ["comment", "approve", "request-changes"],
208 requestReviewers: false,
209 labels: false,
210 });
211 expect(detail.workflowApprovalsRequired).toBeUndefined();
212 expect(detail.checks).toContainEqual({
213 name: "Workflow approval status",
214 status: "action-required",
215 description: "GitHub could not determine whether workflows are awaiting approval.",
216 url: null,
217 });
218 for (const fingerprint of ["broad", "restricted", "broad"]) {
219 const scoped = yield* provider
220 .getChangeRequest({
221 cwd: "/w",
222 repository: "acme/web",
223 host: "github.com",
224 number: 7,
225 })
226 .pipe(
227 Effect.provideService(GitHubRequestPolicy.PinnedGitHubCredential, {
228 host: "github.com",
229 token: Redacted.make("credential"),
230 credentialFingerprint: fingerprint,
231 }),
232 );
233 expect(scoped.mergeCapabilities.squash).toBe(fingerprint !== "restricted");
234 }
235 }).pipe(
236 Effect.provide(
237 Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
238 revalidateChecks: (_input, read) => read,
239 getPullRequestDetail: () =>
240 Effect.succeed({
241 ...coreFields,
242 comparison: null,
243 viewerAccess: { ...coreFields.viewerAccess, canWrite: false, canTriage: false },
244 authorId: null,
245 number: 7,
246 title: "Pull request 7",
247 url: "https://github.com/acme/web/pull/7",
248 author: null,
249 isCrossRepository: true,
250 headRepositoryOwner: null,
251 headBranch: "feat/page",
252 baseBranch: "main",
253 state: "open" as const,
254 isDraft: false,
255 mergeability: "mergeable" as const,
256 reviewDecision: null,
257 additions: 1,
258 deletions: 1,
259 createdAt: "2026-07-01T00:00:00Z",
260 updatedAt: "2026-07-02T00:00:00Z",
261 reviewRequestLogins: [],
262 hasTeamReviewRequest: false,
263 checksState: null,
264 labels: [],
265 body: "",
266 changedFiles: 1,
267 mergedAt: null,
268 closedAt: null,
269 checks: [],
270 comments: [],
271 commits: [],
272 }).pipe(
273 Effect.flatMap((detail) =>
274 GitHubRequestPolicy.PinnedGitHubCredential.pipe(
275 Effect.map((credential) => ({
276 ...detail,
277 viewerAccess: {
278 ...detail.viewerAccess,
279 mergeCapabilities: {
280 ...detail.viewerAccess.mergeCapabilities,
281 squash: credential?.credentialFingerprint !== "restricted",
282 },
283 },
284 })),
285 ),
286 ),
287 ),
288 }),
289 ),
290 ),
291 );
292​
293 it.effect("keeps fork workflows awaiting approval out of the passing state", () =>
294 Effect.gen(function* () {
295 const provider = yield* make;
296 const detail = yield* provider.getChangeRequest({
297 cwd: "/w",
298 repository: "acme/web",
299 host: "github.com",
300 number: 7,
301 });
302​
303 const readChecks = provider.getChangeRequestChecks;
304 if (readChecks === undefined) return yield* Effect.die("checks read missing");
305 expect(
306 yield* readChecks({ cwd: "/w", repository: "acme/web", host: "github.com", number: 7 }),
307 ).toEqual({ state: detail.state, checks: detail.checks });
308 expect(detail.workflowApprovalsRequired).toBe(1);
309 expect(detail.checks).toEqual([
310 {
311 name: "manual gate",
312 status: "action-required",
313 description: null,
314 url: "https://example.com/manual-gate",
315 },
316 {
317 name: "build",
318 status: "success",
319 description: null,
320 url: null,
321 },
322 {
323 name: "contributor tests",
324 status: "action-required",
325 description: "A maintainer must approve this workflow before it can run.",
326 url: "https://github.com/acme/web/actions/runs/123",
327 },
328 ]);
329 }).pipe(
330 Effect.provide(
331 Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
332 revalidateChecks: (_input, read) => read,
333 getPullRequestDetail: () =>
334 Effect.succeed({
335 ...coreFields,
336 authorId: null,
337 number: 7,
338 title: "Pull request 7",
339 url: "https://github.com/acme/web/pull/7",
340 author: null,
341 isCrossRepository: true,
342 headRepositoryOwner: "octocat",
343 headSha: "abc123",
344 headBranch: "feat/page",
345 baseBranch: "main",
346 state: "open",
347 isDraft: false,
348 mergeability: "mergeable",
349 reviewDecision: null,
350 additions: 1,
351 deletions: 1,
352 createdAt: "2026-07-01T00:00:00Z",
353 updatedAt: "2026-07-02T00:00:00Z",
354 reviewRequestLogins: [],
355 hasTeamReviewRequest: false,
356 checksState: "passing",
357 labels: [],
358 body: "",
359 changedFiles: 1,
360 mergedAt: null,
361 closedAt: null,
362 checks: [
363 {
364 name: "manual gate",
365 status: "action-required",
366 description: null,
367 url: "https://example.com/manual-gate",
368 },
369 { name: "build", status: "success", description: null, url: null },
370 ],
371 comments: [],
372 commits: [],
373 }),
374 listWorkflowRunsRequiringApproval: () =>
375 Effect.succeed([
376 {
377 id: 123,
378 name: "contributor tests",
379 url: "https://github.com/acme/web/actions/runs/123",
380 },
381 ]),
382 getViewerAccess: () =>
383 Effect.succeed({
384 canWrite: true,
385 canTriage: true,
386 canUpdate: true,
387 didAuthor: false,
388 mergeCapabilities: { merge: true, squash: true, rebase: true },
389 autoMergeAllowed: true,
390 }),
391 }),
392 ),
393 ),
394 );
395});
396​
397const openDetail = {
398 ...coreFields,
399 authorId: null,
400 number: 7,
401 title: "Pull request 7",
402 url: "https://github.com/acme/web/pull/7",
403 author: null,
404 isCrossRepository: true,
405 headRepositoryOwner: "acme",
406 headSha: "abc123",
407 headBranch: "feat/page",
408 baseBranch: "main",
409 state: "open" as const,
410 isDraft: false,
411 mergeability: "mergeable" as const,
412 reviewDecision: null,
413 additions: 1,
414 deletions: 1,
415 createdAt: "2026-07-01T00:00:00Z",
416 updatedAt: "2026-07-02T00:00:00Z",
417 reviewRequestLogins: [],
418 hasTeamReviewRequest: false,
419 checksState: null,
420 labels: [],
421 body: "",
422 changedFiles: 1,
423 mergedAt: null,
424 closedAt: null,
425 checks: [],
426 comments: [],
427 commits: [],
428};
429​
430it.effect("does not classify same-repository gates as fork workflow approvals", () =>
431 Effect.gen(function* () {
432 const provider = yield* make;
433 const detail = yield* provider.getChangeRequest({
434 cwd: "/w",
435 repository: "acme/web",
436 host: "github.com",
437 number: 7,
438 });
439​
440 expect(detail.workflowApprovalsRequired).toBe(0);
441 expect(detail.checks).toEqual([]);
442 }).pipe(
443 Effect.provide(
444 Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
445 revalidateChecks: (_input, read) => read,
446 getPullRequestDetail: () => Effect.succeed({ ...openDetail, isCrossRepository: false }),
447 listWorkflowRunsRequiringApproval: () =>
448 Effect.die("same-repository pull requests must not probe fork workflow approvals"),
449 getViewerAccess: () =>
450 Effect.succeed({
451 canWrite: true,
452 canTriage: true,
453 canUpdate: true,
454 didAuthor: false,
455 mergeCapabilities: { merge: true, squash: true, rebase: true },
456 autoMergeAllowed: true,
457 }),
458 }),
459 ),
460 ),
461);
462​
463it.effect("keeps an unsafe workflow approval scope visible as unknown", () =>
464 Effect.gen(function* () {
465 const provider = yield* make;
466 const detail = yield* provider.getChangeRequest({
467 cwd: "/w",
468 repository: "acme/web",
469 host: "github.com",
470 number: 7,
471 });
472​
473 expect(detail.workflowApprovalsRequired).toBeUndefined();
474 expect(detail.checks).toEqual([
475 {
476 name: "Workflow approval status",
477 status: "action-required",
478 description: "GitHub could not determine whether workflows are awaiting approval.",
479 url: null,
480 },
481 ]);
482 }).pipe(
483 Effect.provide(
484 Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
485 revalidateChecks: (_input, read) => read,
486 getPullRequestDetail: () => Effect.succeed(openDetail),
487 listWorkflowRunsRequiringApproval: () =>
488 Effect.fail(
489 new GitHubPullRequestApi.GitHubWorkflowApprovalRefusedError({
490 cwd: "/w",
491 number: 7,
492 reason: "head-not-unique",
493 observedCount: 2,
494 limit: 1_000,
495 }),
496 ),
497 getViewerAccess: () =>
498 Effect.succeed({
499 canWrite: true,
500 canTriage: true,
501 canUpdate: true,
502 didAuthor: false,
503 mergeCapabilities: { merge: true, squash: true, rebase: true },
504 autoMergeAllowed: true,
505 }),
506 }),
507 ),
508 ),
509);
510​
511describe("getViewerPermissions", () => {
512 const access = {
513 canWrite: true,
514 canTriage: true,
515 canUpdate: true,
516 didAuthor: false,
517 mergeCapabilities: { merge: true, squash: true, rebase: true },
518 autoMergeAllowed: true,
519 };
520​
521 const layerWithDetail = (
522 detail: Effect.Effect<GitHubPullRequestCore, GitHubPullRequestApi.GitHubPullRequestApiError>,
523 onDetail: (allowReserve: boolean) => void = () => {},
524 ) =>
525 Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
526 revalidateChecks: (_input, read) => read,
527 getPullRequestDetail: () =>
528 SourceControlRateLimit.Interactive.pipe(
529 Effect.tap((allowReserve) => Effect.sync(() => onDetail(allowReserve))),
530 Effect.flatMap(() => detail),
531 ),
532 getViewerAccess: () => Effect.die("Unexpected access read"),
533 });
534​
535 it.effect("answers access and update-branch from the one detail read", () =>
536 Effect.gen(function* () {
537 const provider = yield* make;
538 const permissions = yield* provider.getViewerPermissions({
539 cwd: "/w",
540 repository: "acme/web",
541 host: "github.com",
542 number: 7,
543 });
544​
545 expect(permissions.actions).toContain("merge");
546 expect(permissions.actions).toContain("update-branch");
547 expect(permissions.updateMethods).toEqual(["merge", "rebase"]);
548 }).pipe(
549 Effect.provide(
550 layerWithDetail(
551 Effect.succeed({ ...openDetail, comparison: { behindBy: 3, viewerCanUpdate: true } }),
552 ),
553 ),
554 ),
555 );
556​
557 it.effect("still answers from the light access read when the detail read fails", () =>
558 Effect.gen(function* () {
559 const provider = yield* make;
560 const permissions = yield* provider.getViewerPermissions({
561 cwd: "/w",
562 repository: "acme/web",
563 host: "github.com",
564 number: 7,
565 });
566 expect(permissions.actions).toContain("merge");
567 expect(permissions.actions).not.toContain("update-branch");
568 }).pipe(
569 Effect.provide(
570 Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
571 revalidateChecks: (_input, read) => read,
572 getPullRequestDetail: () =>
573 Effect.fail(
574 new GitHubPullRequestApi.GitHubPullRequestReadError({
575 cwd: "/w",
576 operation: "getPullRequestDetail",
577 cause: new Error("head changed"),
578 }),
579 ),
580 getViewerAccess: () => Effect.succeed(access),
581 }),
582 ),
583 ),
584 );
585​
586 it.effect("withholds update-branch where GitHub could not compare the branch", () =>
587 Effect.gen(function* () {
588 const provider = yield* make;
589 const permissions = yield* provider.getViewerPermissions({
590 cwd: "/w",
591 repository: "acme/web",
592 host: "github.com",
593 number: 7,
594 });
595​
596 expect(permissions.actions).not.toContain("update-branch");
597 expect(permissions.updateMethods).toBeUndefined();
598 expect(permissions.actions).toContain("merge");
599 }).pipe(Effect.provide(layerWithDetail(Effect.succeed({ ...openDetail, comparison: null })))),
600 );
601});
602​
603describe("getChangeRequest commits", () => {
604 const baseDetail = {
605 authorId: null,
606 number: 7,
607 title: "Pull request 7",
608 url: "https://github.com/acme/web/pull/7",
609 author: null,
610 headBranch: "feat/page",
611 baseBranch: "main",
612 state: "open" as const,
613 isDraft: false,
614 mergeability: "mergeable" as const,
615 additions: 1,
616 deletions: 1,
617 createdAt: "2026-07-01T00:00:00Z",
618 updatedAt: "2026-07-02T00:00:00Z",
619 reviewRequestLogins: [],
620 hasTeamReviewRequest: false,
621 checksState: null,
622 labels: [],
623 body: "",
624 changedFiles: 1,
625 mergedAt: null,
626 closedAt: null,
627 checks: [],
628 comments: [],
629 };
630​
631 const baseThreadComments = {
632 comments: [],
633 dismissalsByReviewId: new Map<string, string>(),
634 reviewThreads: [],
635 commentCount: 0,
636 truncated: false,
637 reviewThreadsTruncated: false,
638 reactions: [],
639 reactionsById: new Map<string, ReadonlyArray<PullRequestReaction>>(),
640 editedAtById: new Map<string, string>(),
641 reviewers: [],
642 avatarsByLogin: new Map<string, string>(),
643 botLogins: new Set<string>(),
644 commitStats: new Map<string, { readonly additions: number; readonly deletions: number }>(),
645 viewer: { canUpdate: true, didAuthor: false },
646 };
647​
648 const layerWith = (commits: GitHubReviewThreadComments["commits"]) =>
649 Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
650 revalidateChecks: (_input, read) => read,
651 getPullRequestActivity: () =>
652 Effect.succeed({
653 author: baseDetail.author,
654 comments: baseDetail.comments,
655 commits: [
656 {
657 oid: "view-oldest",
658 messageHeadline: "gh pr view's oldest commit",
659 committedDate: "2026-01-01T00:00:00Z",
660 authors: [],
661 },
662 ],
663 }),
664 listReviewThreadComments: () => Effect.succeed({ ...baseThreadComments, commits }),
665 });
666​
667 it.effect("prefers the GraphQL commits, which are the newest, over the gh view list", () =>
668 Effect.gen(function* () {
669 const provider = yield* make;
670 const detail = yield* provider.getChangeRequestActivity({
671 cwd: "/w",
672 repository: "acme/web",
673 host: "github.com",
674 number: 7,
675 });
676​
677 expect(detail.commits.map((commit) => commit.oid)).toEqual(["graphql-newest"]);
678 }).pipe(
679 Effect.provide(
680 layerWith([
681 {
682 oid: "graphql-newest",
683 messageHeadline: "the newest commit gh pr view drops",
684 committedDate: "2026-07-06T00:00:00Z",
685 authors: [],
686 },
687 ]),
688 ),
689 ),
690 );
691​
692 it.effect("falls back to the gh view list when the GraphQL read has no commits", () =>
693 Effect.gen(function* () {
694 const provider = yield* make;
695 const detail = yield* provider.getChangeRequestActivity({
696 cwd: "/w",
697 repository: "acme/web",
698 host: "github.com",
699 number: 7,
700 });
701​
702 expect(detail.commits.map((commit) => commit.oid)).toEqual(["view-oldest"]);
703 }).pipe(Effect.provide(layerWith([]))),
704 );
705});
706​
707describe("getChangeRequestActivity dismissed reviews", () => {
708 const dismissedReview = (body: string) => ({
709 id: "PRR_1",
710 kind: "review" as const,
711 author: { login: "macroscopeapp", name: null, avatarUrl: null },
712 body,
713 createdAt: "2026-07-03T00:00:00Z",
714 url: null,
715 path: null,
716 reviewState: "DISMISSED",
717 });
718 const threadComments: GitHubReviewThreadComments = {
719 comments: [],
720 dismissalsByReviewId: new Map([["PRR_1", "Dismissing prior approval to re-evaluate 9b66581"]]),
721 reviewThreads: [],
722 commentCount: 0,
723 truncated: false,
724 reviewThreadsTruncated: false,
725 reactions: [],
726 reactionsById: new Map(),
727 editedAtById: new Map([["PRR_1", "2026-07-04T00:00:00Z"]]),
728 reviewers: [],
729 avatarsByLogin: new Map(),
730 botLogins: new Set(["macroscopeapp"]),
731 commitStats: new Map(),
732 commits: [],
733 viewer: { canUpdate: true, didAuthor: false },
734 };
735 const layerFor = (body: string) =>
736 Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
737 revalidateChecks: (_input, read) => read,
738 getPullRequestActivity: () =>
739 Effect.succeed({ author: null, comments: [dismissedReview(body)], commits: [] }),
740 listReviewThreadComments: () => Effect.succeed(threadComments),
741 });
742 const readActivity = Effect.gen(function* () {
743 const provider = yield* make;
744 return yield* provider.getChangeRequestActivity({
745 cwd: "/w",
746 repository: "acme/web",
747 host: "github.com",
748 number: 7,
749 });
750 });
751​
752 it.effect("fills a marker-only dismissed review with the timeline's reason", () =>
753 // Macroscope's approvals carry only an HTML comment, which markdown renders as nothing —
754 // an empty-string check misses them and the card opens onto nothing.
755 readActivity.pipe(
756 Effect.map((activity) => {
757 expect(activity.comments[0]?.body).toBe("Dismissing prior approval to re-evaluate 9b66581");
758 expect(activity.comments[0]?.author?.isBot).toBe(true);
759 expect(activity.comments[0]?.editedAt).toBe("2026-07-04T00:00:00Z");
760 }),
761 Effect.provide(layerFor("<!-- Macroscope (Approvability) review body marker -->")),
762 ),
763 );
764});
765​
766describe("loginAvatarUrl", () => {
767 it("refuses anything that is not a login, rather than building a URL out of it", () => {
768 for (const login of ["../../etc", "a b", "-leading", "x".repeat(40), ""]) {
769 expect(loginAvatarUrl(login, "github.com")).toBeNull();
770 }
771 });
772});