Repository navigation
test(mergeQueue): pin errorMessage's null-rejection guards, the once-per-run warning's initial state and the [bot] suffix anchor - #581
Conversation
…per-run warning's initial state and the [bot] suffix anchor
Adds __tests__/utils/mergeQueueGuards.test.ts. Every line and branch of
src/utils/mergeQueue.ts is already covered, but five of its mutants survive
the Stryker harness: `npx stryker run --mutate src/utils/mergeQueue.ts`
(main@e3119ad) kills 106 of 111 (score 95.50%). The survivors, each
re-applied by hand at its reported span and confirmed to pass the existing
mergeQueue.test.ts:
- mergeQueue.ts:184 `e !== null` -> `true`, the whole
`typeof e === 'object' && e !== null && 'errors' in e` conjunction -> `true`,
and the final `&&` -> `||`: a null or undefined rejection of octokit.graphql
would throw a TypeError out of errorMessage, so queueState would reject
instead of warning and falling back to the REST merge, and enqueue would
throw instead of returning `{ ok: false }`.
- mergeQueue.ts:64 `let warnedUnavailable = false` -> `true`: every existing
test calls resetMergeQueueWarnings() (directly or via setupActionsEnv), so
the first real run of a job never warning went unnoticed. Pinned on a fresh
module instance (vi.resetModules) that nothing has reset.
- mergeQueue.ts:153 `/^github-actions$|\[bot\]$/i` -> `/^github-actions$|\[bot\]/i`:
a login merely containing `[bot]` would count as an automation whose queue
entry the gate may undo.
With this file all five are killed (manual re-application of each mutant
fails 1-3 of the new cases; 111/111 killed).
No production code changes.
Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Agent PRs are held at ACMM L3–L5; an Hive will keep the |
|
Please add a kind label with |
There was a problem hiding this comment.
Read the new file against src/utils/mergeQueue.ts at the PR head; all three guard pins match the code and the mutant-kill claims hold. Looks correct to me.
Verified:
errorMessagenull/undefined/non-array-errors arms (src/utils/mergeQueue.ts:184-191):typeof null === 'object'makes thee !== nullcheck load-bearing — mutating it totruemakes'errors' in nullthrow out ofqueueState's catch, which the first test'sresolves.toBeUndefined()catches. The{ errors: 'not an array' }case likewise kills the&& → ||mutant, since'not an array'.mapwould throw out ofenqueue. Messages"null","undefined","[object Object]"are exactly whatString(e)produces.- Once-per-run warning initial state (
src/utils/mergeQueue.ts:63,:89-93): the test'svi.resetModules()+ fresh dynamic import of both@actions/coreand the module in onePromise.allgives a module instance withwarnedUnavailable = falsethat nothing reset — the gap the PR body describes (every case inmergeQueue.test.tsgoes throughresetMergeQueueWarnings()). The globalvi.mock('@actions/core', { spy: true })in__tests__/setup.ts:4re-applies on the fresh registry, so the spy assertions are sound. [bot]suffix anchor (src/utils/mergeQueue.ts:153):/^github-actions$|\[bot\]$/irejectsdependabot[bot]-fanand[bot]renovateand acceptsgithub-actions[bot]; dropping the$anchor flips the first two, so the mutant is killed.
Disjointness also checks out: new file only; #571's harness edit touches __tests__/utils/mergeQueue.test.ts, not this file. All checks green. No findings.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
Test Improvement
Adds
__tests__/utils/mergeQueueGuards.test.ts: seven cases pinning guards ofsrc/utils/mergeQueue.tsthat line coverage already reaches but no existing test would notice changing. No production code changes.Evidence:
npx stryker run --mutate src/utils/mergeQueue.tson the harness of #572 (main@e3119ad) left 5 of 111 mutants alive (score 95.50%). Each survivor was re-applied by hand at its reported span: the existingmergeQueue.test.tspasses under all five; with this file every one fails 1–3 cases (111/111 killed).Guards pinned (file / function):
errorMessage(mergeQueue.ts:184): anullorundefinedrejection ofoctokit.graphqlis reported as"null"/"undefined"instead of throwing aTypeErrorout of the guard — soqueueStatestill warns and falls back to the REST merge, andenqueuestill returns{ ok: false, kind: 'other' }; anerrorsproperty that is not an array is not read as GraphQL errors (mutants:e !== null → true, the object/null/inconjunction→ true, the last&& → ||)queueState(mergeQueue.ts:64): the once-per-run warning fires on the first failure of a fresh module instance that nothing has reset — every existing test resets it viaresetMergeQueueWarnings()/setupActionsEnv(), which maskedwarnedUnavailable = trueenqueuedByBot(mergeQueue.ts:153):[bot]counts only as a suffix —dependabot[bot]-fanand[bot]renovateare humans (mutant: dropped$anchor)Disjoint from the open hold-gated PRs: new file only. #571's harness change edits
__tests__/utils/mergeQueue.test.ts, not this file; #557/#578 covertide.ts; #575/#579/#580/#573 cover owners/auth/approve/cron-lgtm.Validation:
npx eslint __tests__/utils/mergeQueueGuards.test.ts,npx vitest run(168 files, 2337 passed, 75 skipped).Related Issue
No tracking issue; this continues the per-module mutation triage of #575, #578, #579 and #580 (harness: #572).
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88