fix: rewrite comment-formatter tests against the ADF object contract - #9
Merged
Merged
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe change updates comment formatter tests to validate ADF document objects for all templates and increments the package version from ChangesComment formatter alignment
Estimated code review effort: 2 (Simple) | ~10 minutes ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Closes #8
All 7 tests in
tests/comment-formatter.test.tsfailed onmain, sobun testwas permanently red and the "nothing red is ever committed" gate could not be
honoured for any change in this repo.
The production code was never broken — the tests were stale. The file had not
been touched since the initial commit
df15a0a, while two later commits changedthe contract:
3b750ca—formatComment()returns an ADF object for every template(
markdown,plain,adf), because Jira Cloud v3 requires ADF for commentbodies. The tests called
toContain()andJSON.parse()on it; both need astring.
50b3434— the### 🤖 OpenCode Updateheader and the⏱️timestamp weredeliberately stripped. The tests still asserted both were present.
Changing
src/comment-formatter.tsto satisfy the old assertions would havebroken every comment the plugin posts:
jira_add_comment,jira_sync_progressand
jira_create_issueall pass the result straight toJiraClient.addComment(), which sends it as{ body: <adf> }. So the testswere rewritten against the real contract and the implementation is untouched.
Changes
tests/comment-formatter.test.ts— rewritten. AnasDoc()helper narrows thestring | objectreturn type and asserts the ADF envelope;textOf()checkscontent anywhere in the node tree. Now covers, per template: status hint
present and absent, the strong mark on the status node, the paragraph-only
shape of
plain, its line-splitting (blank lines dropped), the pre-built-ADFpassthrough, the
buildADFfallback, and the unknown-template default.7 tests → 10.
package.json— 0.4.0 → 0.4.1, per the mandatory version-bump-per-change rule.Gates
bunx tsc --noEmitcleanbun test— 55 pass / 0 fail (was 45 pass / 7 fail onmain)bun run buildsucceeds,dist/currentJSON.stringify().not.toThrow()assertion — was replaced with a round-tripequality check that actually catches non-serialisable fields.
src/comment-formatter.tsunchanged, as required by the issueSummary by cubic
Closes #8 by rewriting the comment-formatter tests that were stale against the production code, which now returns ADF objects instead of strings. This fixes the failing
bun test(55 pass / 0 fail) and unblocks commits.Written for commit 20b16e7. Summary will update on new commits.