diff --git a/__tests__/plugins/blunderbuss.test.ts b/__tests__/plugins/blunderbuss.test.ts index 2372ddff..2995f845 100644 --- a/__tests__/plugins/blunderbuss.test.ts +++ b/__tests__/plugins/blunderbuss.test.ts @@ -386,12 +386,20 @@ describe('blunderbuss handler', () => { await expect(observePull.notCalled()).resolves.toBe('not called') }) - it('fails when the review request is refused', async () => { + it('fails when the review request is refused, without retrying each reviewer alone', async () => { serveConfig() servePr(owners, ['sdk/x.go']) - observeRequestReviewers(500) + const calls: string[][] = [] + server.use(http.post(`${repo}/pulls/1/requested_reviewers`, async ({ request }) => { + calls.push((await request.json() as { reviewers: string[] }).reviewers) + return new Response(JSON.stringify({ message: 'boom' }), { status: 500, headers: { 'Content-Type': 'application/json' } }) + })) + const warning = vi.spyOn(core, 'warning').mockImplementation(() => {}) - await expect(blunderbuss(prEvent('opened'))).rejects.toThrow(/could not request reviewers: .*boom/) + await expect(blunderbuss(prEvent('opened'), first)).rejects.toThrow(/could not request reviewers: .*boom/) + // only a 422 means one login spoiled the batch; any other status is reported as is + expect(calls).toEqual([['alice', 'bob']]) + expect(warning).not.toHaveBeenCalled() }) it('when GitHub refuses the batch with a 422, requests each reviewer alone and keeps the ones it accepts', async () => { diff --git a/__tests__/plugins/requireMatchingLabel.test.ts b/__tests__/plugins/requireMatchingLabel.test.ts index a52e2216..8ebf2702 100644 --- a/__tests__/plugins/requireMatchingLabel.test.ts +++ b/__tests__/plugins/requireMatchingLabel.test.ts @@ -73,7 +73,7 @@ interface Writes { deleteComment: utils.ObserveRequest } -function serveIssue(labels: string[], comments: { id: number, body: string, user: { login: string, type: string } }[] = []): Writes { +function serveIssue(labels: string[], comments: { id: number, body: string, user: { login: string, type: string } | null }[] = []): Writes { const writes: Writes = { addLabels: new utils.ObserveRequest(), removeLabel: new utils.ObserveRequest(), @@ -116,6 +116,8 @@ const botComment = { id: 11, body: `Please add a kind label.\n\n${marker}`, user const humanComment = { id: 12, body: `I pasted the marker by hand ${marker}`, user: { login: 'Codertocat', type: 'User' } } // another GitHub App's bot: `type: 'Bot'` without the github-actions login const appBotComment = { id: 13, body: `Please add a kind label.\n\n${marker}`, user: { login: 'other-app[bot]', type: 'Bot' } } +// a comment whose author deleted their account: GitHub answers `user: null` +const ghostComment = { id: 14, body: `Please add a kind label.\n\n${marker}`, user: null } describe('evaluate', () => { it.each([ @@ -264,9 +266,9 @@ describe('requireMatchingLabel handler', () => { expect(setFailed).not.toHaveBeenCalled() }) - it('deletes the marker comment of another app bot but not the human copy of the marker', async () => { + it('deletes the marker comment of another app bot but not the human or authorless copies of the marker', async () => { serveRules([kindRule]) - serveIssue(['kind/bug', 'needs-kind'], [humanComment, appBotComment]) + serveIssue(['kind/bug', 'needs-kind'], [humanComment, appBotComment, ghostComment]) const deleted: string[] = [] server.use(http.delete(`${repo}/issues/comments/:id`, ({ params }) => { deleted.push(String(params.id))