test(server): cover mention-grant closed comment intents

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Nicky LeachandPaperclip committed 2026-06-19 23:17:08 +00:00
1 parent 21cc2b26ed
commit 55b62ffb27
1 file changed
+14 -5
@@ -590,10 +590,20 @@ describe.sequential("issue comment reopen routes", () => {
["resume", { resume: true }],
["reopen", { reopen: true }],
])(
"rejects mention-granted non-assignee agent POST comments on closed issues with %s intent",
"allows mention-granted non-assignee agent POST comments on closed issues with %s intent without reopening",
async (_name, intent) => {
const mentionedAgentId = "33333333-3333-4333-8333-333333333333";
mockIssueService.getById.mockResolvedValue(makeIssue("done"));
mockIssueService.addComment.mockResolvedValue({
id: "comment-1",
issueId: "11111111-1111-4111-8111-111111111111",
companyId: "company-1",
body: "Please continue this closed issue.",
createdAt: new Date(),
updatedAt: new Date(),
authorAgentId: mentionedAgentId,
authorUserId: null,
});
mockAccessService.decide.mockImplementation(async (input: { action?: string }) => {
const allowed = input.action === "issue:comment";
return {
@@ -608,12 +618,11 @@ describe.sequential("issue comment reopen routes", () => {
.post("/api/issues/11111111-1111-4111-8111-111111111111/comments")
.send({ body: "Please continue this closed issue.", ...intent });
expect(res.status, JSON.stringify(res.body)).toBe(403);
expect(res.body.error).toBe("Issue is outside this actor's authorization boundary");
expect(res.status, JSON.stringify(res.body)).toBe(201);
expect(mockAccessService.decide).toHaveBeenCalledWith(expect.objectContaining({ action: "issue:comment" }));
expect(mockAccessService.decide).toHaveBeenCalledWith(expect.objectContaining({ action: "issue:mutate" }));
expect(mockAccessService.decide).not.toHaveBeenCalledWith(expect.objectContaining({ action: "issue:mutate" }));
expect(mockIssueService.update).not.toHaveBeenCalled();
expect(mockIssueService.addComment).not.toHaveBeenCalled();
expect(mockIssueService.addComment).toHaveBeenCalled();
expect(mockHeartbeatService.wakeup).not.toHaveBeenCalled();
},
);