fix: refresh reviews after new commits

This commit is contained in:
lezi-fun committed 2026-08-14 09:16:07 +08:00
1 parent ed3e1bd72c
commit 4d73d1f30c
12 files changed
+565 -29

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
import assert from "node:assert/strict";
import test from "node:test";
import type { Octokit } from "@octokit/rest";
import {
formatPermissionDeniedMessage,
postPermissionDeniedComment
} from "../src/github/commandFeedback.js";
test("permission denied feedback is friendly and actionable", () => {
const body = formatPermissionDeniedMessage("contributor", "/recheck");
assert.match(body, /^Hi! @contributor, we're sorry/);
assert.match(body, /permission to run `\/recheck`/);
assert.match(body, /write.*maintain.*admin/i);
assert.match(body, /ask a repository maintainer/i);
});
test("permission denied feedback is deduplicated by source comment", async () => {
const created: string[] = [];
const comments: Array<{ body: string }> = [];
const octokit = {
paginate: async () => comments,
rest: {
issues: {
listComments: async () => ({ data: comments }),
createComment: async ({ body }: { body: string }) => {
created.push(body);
comments.push({ body });
return { data: { id: 1, body } };
}
}
}
} as unknown as Octokit;
const params = {
owner: "forumlify",
repo: "public",
pullNumber: 17,
sourceCommentId: 123,
commenterLogin: "contributor",
command: "/conflict" as const
};
await postPermissionDeniedComment(octokit, params);
await postPermissionDeniedComment(octokit, params);
assert.equal(created.length, 1);
assert.match(created[0]!, /comment=123/);
assert.match(created[0]!, /permission to run `\/conflict`/);
});