Skip to content
25 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { mayChangeComment } from "./comments.ts";
5
6const ana = { id: "usr_1" };
7
8test("its author edits and deletes their own comment", () => {
9 const comment = { kind: "comment" as const, verdict: null, author: ana };
10 assert.deepEqual(mayChangeComment(comment, "usr_1", false), { edit: true, delete: true });
11 assert.deepEqual(mayChangeComment(comment, "usr_2", false), { edit: false, delete: false });
12 assert.deepEqual(mayChangeComment(comment, null, true), { edit: false, delete: false });
13});
14
15test("a maintainer edits and deletes anyone's", () => {
16 const comment = { kind: "comment" as const, verdict: null, author: ana };
17 assert.deepEqual(mayChangeComment(comment, "usr_2", true), { edit: true, delete: true });
18});
19
20test("a review is edited but never deleted, and a note is never changed", () => {
21 const review = { kind: "comment" as const, verdict: "approve" as const, author: ana };
22 assert.deepEqual(mayChangeComment(review, "usr_1", true), { edit: true, delete: false });
23 const note = { kind: "event" as const, verdict: null, author: ana };
24 assert.deepEqual(mayChangeComment(note, "usr_1", true), { edit: false, delete: false });
25});

This file's history is long; its oldest lines are credited to the oldest commit read.