fix(test): defuse the suite's landmines, and cover the dossier's untested modules - #1436
Merged
Conversation
β¦ and un-strand two flags
Four review-side findings, the last of the sweep's low tier:
- reviewPullRequest now reads the ReviewSubmissionResult every provider
already returned: a review that failed to post says so instead of
claiming success (and records no state, so the next run does not skip
a review nobody can see), and inline comments the platform dropped
are counted in the status and warned about.
- prepareReview/renderFinding take the provider's reviewSuggestions
capability: Bitbucket declares it false and was receiving literal
suggestion fences promising a one-click apply it does not have; it
now gets a plain code fence labelled as a suggested replacement.
- buddy review --auto passes skipIfReviewed, so the workflow that fires
on every edited event stops re-reviewing the same head commit; a
person at a terminal still always gets their review.
- buddy review --light --fix applies suggestions: the light branch
returned before the fix block, so the flag worked everywhere except
the one mode fast enough for a pre-commit hook.
The review-parity stub answered createReview with { id: 1 } β encoding
the defect that the result was ignored; it now returns what the
interface declares.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- The node:fs module mock in dependency-file-parser leaked into every file that ran after it: mock.module is process-global and permanent, so once afterEach reset the mocks, existsSync returned undefined suite-wide β which is exactly how #1434's decline test failed on CI while passing alone. The mock now delegates to the real fs except while this suite has armed it. - preload.ts gains a repair-only cwd net: a suite that chdirs into a temp directory and deletes it leaves process.cwd() dead, and every later filesystem-touching test fails with an unrelated ENOENT. A live cwd is never moved. - test/composer-constraint-updates.test.ts was a 0-byte file that ran and asserted nothing β coverage in every listing, a test of nothing. It now holds the suite its name promises: caret, tilde, exact and compound constraints keep their shape, require-dev updates, and an unknown package leaves the file untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
β¦s not optional - src/ai/providers/anthropic.ts was the one AI provider without a direct test (google and openai have them) β and it is the default when several keys are present. The SDK is faked at the module seam so complete() runs its real mapping: block collection, the stop-reason table (refusal preserved β it arrives as a successful response with empty content), usage with cache reads, schema-constrained JSON parsing, request passthrough, and the lazily built, reused client. - src/utils/lock-file.ts: 188 lines, publicly re-exported, no direct test. The pure parts are asserted directly; regenerateLockFile is exercised through its non-fatal contract β a machine without the package manager gets a result object naming the failure, not an unhandled rejection (which channel reports it is platform-dependent: node fires 'error', Bun closes with a negative code). - README: bun install is a hard prerequisite on a fresh clone (bun test otherwise fails with phantom module errors), and the declared git hooks do not install themselves β bunx bun-git-hooks activates them. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
β¦h a second module mock The new anthropic-provider file owned its own mock.module of the SDK β process-global, so under CI's file order it clobbered ai-provider's fetch-stubbed anthropic tests, which started receiving the fake's canned response. The same landmine class this branch exists to defuse. The genuinely new cases move into ai-provider.test.ts through the real SDK: the remaining stop reasons (stop_sequence, max_tokens, unknown), schema-constrained JSON parsing and its malformed-JSON failure, and the wire shape (system, tools mapped to input_schema, output_config, max_tokens default) captured from the request body. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three commits of test-suite health, all off the dossier's shortlist β the third one forced by the second stepping on the very landmine the first defuses.
Commit 1 β the three landmines
The
node:fsmock that outlives its suite.test/dependency-file-parser.test.tscallsmock.module('node:fs', β¦)with bare mock functions.mock.moduleis process-global and permanent, so every file that runs afterwards inherits the mocks β and onceafterEachresets them,existsSyncreturnsundefinedeverywhere. That is precisely how #1434's decline test failed on CI while passing alone. The replacement functions now delegate to the realfsexcept while the suite has explicitly armed them.The dead working directory. A suite that
chdirs into a temp dir and deletes it leavesprocess.cwd()pointing at nothing; the next filesystem-touching suite fails with an ENOENT that looks like its own bug.test/preload.tsnow carries the net: a globalbeforeEachthat repairscwdto the repo root only when it is dead.The 0-byte test file.
test/composer-constraint-updates.test.tsran, passed, and asserted nothing. It now holds the suite its name promises:^/~/exact constraints keep their shape,>=6.0,<7.0moves only its floor,require-devfollows the same rules, an unknown package leaves the file untouched.Commits 2+3 β the untested modules, and the README gap
src/utils/lock-file.tsβ 188 lines, publicly re-exported, zero direct tests. Pure parts asserted directly;regenerateLockFilethrough its non-fatal contract: a machine without the manager gets a result object naming the failure, not an unhandled rejection (node fireserror, Bun closes with a negative code β the test pins the contract, not the channel).src/ai/providers/anthropic.tsβ the gaps in its coverage are closed insidetest/ai-provider.test.ts, at the fetch layer, through the real SDK: the remaining stop reasons (stop_sequence,max_tokens, unknown βother), schema-constrained JSON parsing and its malformed-JSONAiProviderError, and the wire shape (system, tools mapped toinput_schema,output_config, the 16000max_tokensdefault) captured from the request body. The first attempt was a separate file owning its ownmock.module('@anthropic-ai/sdk')β process-global, so under CI's file order it clobbered the existing fetch-stubbed tests, which began receiving the fake's canned response. Same landmine class commit 1 defuses; commit 3 removes it in favour of stubbing at the seam this suite already owns.README β
bun installis a hard prerequisite on a fresh clone (bun testotherwise fails with a hundred-plus phantomCannot find packageerrors), and the git hooks declared inpackage.jsondo not install themselves βbunx bun-git-hooksactivates them.Tests
bun test: 2213 pass / 0 fail (up 19 net). The leak-order pair (dependency-file-parserβcli-surface) run explicitly to confirm the delegation holds. Typecheck, pickier, check-docs green.π€ Generated with Claude Code