Skip to content

fix: rewrite comment-formatter tests against the ADF object contract - #9

Merged
four-bytes-robby merged 1 commit into
mainfrom
fix/8-comment-formatter-tests
Sep 4, 2026
Merged

fix: rewrite comment-formatter tests against the ADF object contract#9
four-bytes-robby merged 1 commit into
mainfrom
fix/8-comment-formatter-tests

Conversation

@four-bytes-robby

@four-bytes-robby four-bytes-robby commented Sep 4, 2026

Copy link
Copy Markdown
Member

Closes #8

All 7 tests in tests/comment-formatter.test.ts failed on main, so bun test
was 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 changed
the contract:

  • 3b750caformatComment() returns an ADF object for every template
    (markdown, plain, adf), because Jira Cloud v3 requires ADF for comment
    bodies. The tests called toContain() and JSON.parse() on it; both need a
    string.
  • 50b3434 — the ### 🤖 OpenCode Update header and the ⏱️ timestamp were
    deliberately stripped. The tests still asserted both were present.

Changing src/comment-formatter.ts to satisfy the old assertions would have
broken every comment the plugin posts: jira_add_comment, jira_sync_progress
and jira_create_issue all pass the result straight to
JiraClient.addComment(), which sends it as { body: <adf> }. So the tests
were rewritten against the real contract and the implementation is untouched.

Changes

  • tests/comment-formatter.test.ts — rewritten. An asDoc() helper narrows the
    string | object return type and asserts the ADF envelope; textOf() checks
    content 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-ADF
    passthrough, the buildADF fallback, 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 --noEmit clean
  • bun test55 pass / 0 fail (was 45 pass / 7 fail on main)
  • bun run build succeeds, dist/ current
  • Code review Soft Score 96%. Its one warning — a near-unfailable
    JSON.stringify().not.toThrow() assertion — was replaced with a round-trip
    equality check that actually catches non-serialisable fields.
  • src/comment-formatter.ts unchanged, as required by the issue

Summary 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.

  • Bumps the package version to 0.4.1 per the version-bump rule.

Written for commit 20b16e7. Summary will update on new commits.

Review in cubic

@four-bytes-robby four-bytes-robby self-assigned this Sep 4, 2026
@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 8eef0f68-90e3-448f-9b8f-920c39ffb033

📥 Commits

Reviewing files that changed from the base of the PR and between 9a8eba9 and 20b16e7.

📒 Files selected for processing (2)
  • package.json
  • tests/comment-formatter.test.ts

📝 Walkthrough

Walkthrough

The change updates comment formatter tests to validate ADF document objects for all templates and increments the package version from 0.4.0 to 0.4.1.

Changes

Comment formatter alignment

Layer / File(s) Summary
ADF assertion contract
tests/comment-formatter.test.ts
The tests define the expected ADF document shape and add helpers for validating document structure and text content.
Template coverage and release version
tests/comment-formatter.test.ts, package.json
Tests cover markdown, plain, adf, unknown-template fallback, ADF passthrough, paragraph splitting, status marks, JSON round trips, and the version update to 0.4.1.

Estimated code review effort: 2 (Simple) | ~10 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/8-comment-formatter-tests
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/8-comment-formatter-tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@four-bytes-robby
four-bytes-robby merged commit 0336b3b into main Sep 4, 2026
2 of 3 checks passed
@four-bytes-robby
four-bytes-robby deleted the fix/8-comment-formatter-tests branch September 4, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX] comment-formatter tests assert a contract replaced two commits ago — suite permanently red

1 participant