From 9e4d64b38313de5a51b39aa5bc238d2784553a80 Mon Sep 17 00:00:00 2001 From: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Sun, 1 Nov 2026 03:09:40 -0500 Subject: [PATCH] test: /approve cancel skips a review whose user is null and still dismisses the bot's own A review authored by a deleted account arrives with user: null. The loop in cancelApproval guards that before normalizeLogin, but no review list in the tests carried one, so dropping the guard (and crashing the cancel on a ghost review) left every test green; a local Stryker run over the v3.5.0 command files reports it as the one behavioural survivor of 1035 mutants. Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- __tests__/issueCommentTest/approve.test.ts | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/__tests__/issueCommentTest/approve.test.ts b/__tests__/issueCommentTest/approve.test.ts index fa8a46e..ae3c848 100644 --- a/__tests__/issueCommentTest/approve.test.ts +++ b/__tests__/issueCommentTest/approve.test.ts @@ -188,6 +188,47 @@ describe('/approve', () => { ) }) + it('skips a review whose user is null (deleted account) and still dismisses the bot\'s own approval', async () => { + const reviews = structuredClone(pullReqListReviews) as Array> + reviews.unshift({ ...reviews[0], id: 79, user: null }) + + server.use( + http.get( + `${utils.api}/repos/Codertocat/Hello-World/contents/OWNERS`, + utils.mockResponse(404), + ), + http.get( + `${utils.api}/orgs/Codertocat/members/some-user`, + utils.mockResponse(404), + ), + http.get( + `${utils.api}/repos/Codertocat/Hello-World/collaborators/some-user`, + utils.mockResponse(204), + ), + http.get( + `${utils.api}/repos/Codertocat/Hello-World/pulls/1/reviews`, + utils.mockResponse(200, reviews), + ), + ) + + const observeReq = new utils.ObserveRequest() + server.use( + http.put( + `${utils.api}/repos/Codertocat/Hello-World/pulls/1/reviews/80/dismissals`, + utils.mockResponse(200, null, observeReq), + ), + ) + + issueCommentEventAssign.comment.body = '/approve cancel' + issueCommentEventAssign.comment.user.login = 'some-user' + const commentContext = new utils.MockContext(issueCommentEventAssign) + + const setFailed = vi.spyOn(core, 'setFailed').mockImplementation(() => {}) + await handleIssueComment(commentContext) + await observeReq.called() + expect(setFailed).not.toHaveBeenCalled() + }) + it('removes approval with /remove-approve if commenter is collaborator', async () => { server.use( http.get(