From d420b9ff543466c009eb93a03643d2e5f634d9de Mon Sep 17 00:00:00 2001 From: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Sun, 18 Oct 2026 19:58:48 -0400 Subject: [PATCH] test(remove): assert every DELETE the /remove happy paths issue; enable test/expect-expect remove.test.ts 'removes the specified label' and 'removes multiple labels' registered the DELETE handlers but asserted nothing, so a /remove that dropped all labels but the first passed the file. Each DELETE now carries an ObserveRequest whose called() is awaited, and setFailed is asserted silent. eslint.config.mjs turns on @vitest/eslint-plugin's test/expect-expect for __tests__/**/*.test.ts with this suite's assertion helpers whitelisted (expect*, *.called, *.notCalled); on main it flags exactly these two tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- __tests__/label/remove.test.ts | 17 ++++++++++++++--- eslint.config.mjs | 12 ++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/__tests__/label/remove.test.ts b/__tests__/label/remove.test.ts index dfcb3ec5..da171956 100644 --- a/__tests__/label/remove.test.ts +++ b/__tests__/label/remove.test.ts @@ -27,10 +27,11 @@ describe('remove', () => { issueCommentEvent.comment.body = '/remove some-label' const commentContext = new utils.MockContext(issueCommentEvent) + const removeSomeLabel = new utils.ObserveRequest() server.use( http.delete( `${utils.api}/repos/Codertocat/Hello-World/issues/1/labels/some-label`, - utils.mockResponse(200), + utils.mockResponse(200, null, removeSomeLabel), ), http.get( `${utils.api}/repos/Codertocat/Hello-World/issues/1`, @@ -42,21 +43,26 @@ describe('remove', () => { ), ) + const setFailed = vi.spyOn(core, 'setFailed').mockImplementation(() => {}) await handleIssueComment(commentContext) + await expect(removeSomeLabel.called()).resolves.toBe('called') + expect(setFailed).not.toHaveBeenCalled() }) it('removes multiple labels', async () => { issueCommentEvent.comment.body = '/remove some-label some-other-label' const commentContext = new utils.MockContext(issueCommentEvent) + const removeSomeLabel = new utils.ObserveRequest() + const removeSomeOtherLabel = new utils.ObserveRequest() server.use( http.delete( `${utils.api}/repos/Codertocat/Hello-World/issues/1/labels/some-label`, - utils.mockResponse(200), + utils.mockResponse(200, null, removeSomeLabel), ), http.delete( `${utils.api}/repos/Codertocat/Hello-World/issues/1/labels/some-other-label`, - utils.mockResponse(200), + utils.mockResponse(200, null, removeSomeOtherLabel), ), http.get( `${utils.api}/repos/Codertocat/Hello-World/issues/1`, @@ -68,7 +74,12 @@ describe('remove', () => { ), ) + const setFailed = vi.spyOn(core, 'setFailed').mockImplementation(() => {}) await handleIssueComment(commentContext) + // every requested label is removed, not just the first + await expect(removeSomeLabel.called()).resolves.toBe('called') + await expect(removeSomeOtherLabel.called()).resolves.toBe('called') + expect(setFailed).not.toHaveBeenCalled() }) it('fails if commenter is not collaborator', async () => { diff --git a/eslint.config.mjs b/eslint.config.mjs index 55c6c300..e9f0b099 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -9,4 +9,16 @@ export default antfu({ 'node_modules/', '**/node_modules/**/', ], +}, { + files: ['__tests__/**/*.test.ts'], + rules: { + // A test that drives the code but checks nothing passes whatever the code + // does. The extra names are this suite's own assertion helpers: the + // expectRequests/expectWindow family in __tests__/bundle and + // ObserveRequest.called()/notCalled() in __tests__/testUtils.ts, which + // reject on their own when the observed request is missing or present. + 'test/expect-expect': ['error', { + assertFunctionNames: ['expect', 'expect*', '*.called', '*.notCalled'], + }], + }, })