Skip to content

test(rendering): snapshot Markdown/HTML/plain surfaces (#1181) - #1192

Merged
Sinity merged 1 commit into
masterfrom
feature/test/rendering-snapshots-1181
May 17, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/test/rendering-snapshots-1181

Conversation

@Sinity

@Sinity Sinity commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

Adds syrupy snapshot coverage for the Markdown renderer, the in-process
HTML renderer, and the plain (--plain) CLI output surfaces so that any
user-visible drift in rendered conversation output triggers a snapshot
diff during local verification.

Problem

Per issue #1181, the 2026-05-11 acceptance matrix for #997 asked for
renderer/output stability snapshots, but no PR in the verifiability wave
delivered them. The existing rendering snapshot file pinned only four
HTML cases and tests/unit/cli/test_json_envelope_contract.py covers
only JSON envelopes. The Markdown renderer
(polylogue/rendering/core_markdown.py), the structured-block code
paths in the HTML renderer, and the rich --plain CLI surfaces were
unprotected against silent drift.

Solution

  • tests/unit/rendering/test_output_snapshots.py: extended in-place
    with a Markdown matrix (empty conversation, single user turn, single
    assistant turn, tool-use round-trip, thinking block, attachment,
    code-fence with embedded backticks, JSON payload) calling
    format_conversation_markdown() directly, plus a parallel HTML matrix
    exercising the same cases through render_conversation_html().
  • tests/unit/cli/test_plain_cli_snapshots.py (new): uses the
    corpus_seeded_db fixture (real synthetic pipeline output) and the
    Click CliRunner to pin the column layout, heading shape, and stats
    summary returned by polylogue --plain list, --plain count,
    --plain stats, and a provider-filtered list. Ephemeral content
    (timestamps, paths, durations, hex hashes) is stripped via a
    documented _redact() helper before snapshot comparison.
  • Both modules document the rejected "freeze noise" anti-pattern in
    their docstrings: snapshots pin contract-shaped output, not
    wall-clock fields or implementation noise. The fix for a snapshot
    diff caused by ephemeral content is to extend the redactor, not to
    regenerate the baseline.

Coverage matrix (closes the AC list in #1181):

AC item Where
Markdown: empty conv, single user/assistant turn, tool-use round-trip, thinking, attachments, code-fenced with backticks test_*_markdown_snapshot tests
HTML: same matrix + sanitizer extensions new HTML matrix in same file; sanitizer coverage extended in pre-existing test_html_sanitizer_security.py
Plain CLI surfaces tests/unit/cli/test_plain_cli_snapshots.py
Anti-pattern documented docstrings in both modules
corpus_seeded_db / builder fixtures builders for Markdown/HTML; corpus_seeded_db for CLI
<5s runtime combined 22 tests run in ~1.05s; full module-level run included in devtools verify --quick

Verification

$ nix develop -c pytest tests/unit/rendering/test_output_snapshots.py \
                       tests/unit/cli/test_plain_cli_snapshots.py \
                       -p no:randomly -n 0
22 passed in 1.05s
21 snapshots passed.

$ nix develop -c devtools verify --quick
"total_duration_s": 31.16,
"exit_code": 0

Closes #1181

Extend tests/unit/rendering/test_output_snapshots.py with a markdown
matrix (empty conv, single user/assistant turn, tool-use round-trip,
thinking block, attachment, code fence with embedded backticks, JSON
payload) and a parallel HTML matrix exercising the same cases through
render_conversation_html().

Add tests/unit/cli/test_plain_cli_snapshots.py to pin the contract-
shaped output of polylogue --plain list / count / stats and a
provider-filtered list, using the corpus_seeded_db fixture so any
user-visible drift in rendering of real synthetic conversations
triggers a snapshot diff. Ephemeral fields (timestamps, paths,
durations, hex hashes) are redacted before comparison via the
documented _redact() helper.

Both test modules document the "freeze noise" anti-pattern as a
rejected case (do not snapshot timestamps, hash prefixes, or process
timings).

Closes #1181

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 17, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 53 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 104d5ace-73b2-493b-9895-ba3669995d9c

📥 Commits

Reviewing files that changed from the base of the PR and between 5254179 and 75f3126.

📒 Files selected for processing (4)
  • tests/unit/cli/__snapshots__/test_plain_cli_snapshots.ambr
  • tests/unit/cli/test_plain_cli_snapshots.py
  • tests/unit/rendering/__snapshots__/test_output_snapshots.ambr
  • tests/unit/rendering/test_output_snapshots.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/test/rendering-snapshots-1181

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 and usage tips.

@Sinity
Sinity merged commit 49351d8 into master May 17, 2026
9 of 14 checks passed
@Sinity
Sinity deleted the feature/test/rendering-snapshots-1181 branch May 17, 2026 17:20
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.

test(rendering): pin user-facing output stability without freezing implementation noise

1 participant