fix: merge .percy.yml config options with snapshot options for serializeDOM#31
fix: merge .percy.yml config options with snapshot options for serializeDOM#31rishigupta1599 wants to merge 5 commits into
Conversation
…izeDOM Config options from .percy.yml (like widths, minHeight, enableJavaScript, etc.) were not being passed to PercyDOM.serialize(). Only per-snapshot options were used. Now merges both, with per-snapshot options taking priority. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…onfig-with-serialize-dom
rishigupta1599
left a comment
There was a problem hiding this comment.
Claude Code Review (automated) — 1 inline finding(s). Full report in the PR comment below. Verdict: Failed - see PR comment.
Claude Code PR ReviewPR: #31 • Head: 493b715 • Reviewers: stack:code-review SummaryMerges the global Review Table
Findings
Verdict: FAIL — the string-vs-symbol key collision breaks the per-call-priority merge that is the entire point of the PR; fix key normalisation and add merge-priority tests before merging. |
rishigupta1599
left a comment
There was a problem hiding this comment.
Claude Code Review (automated) — 1 inline finding(s). Full report in the PR comment below. Verdict: Passed.
| # do downstream consumers (responsive_snapshot_capture?, capture_responsive_dom). | ||
| # Symbolize config keys so per-call options override matching config keys | ||
| # instead of producing duplicate logical keys (per-call options take priority). | ||
| merged_options = config_options.transform_keys(&:to_sym).merge(options) |
There was a problem hiding this comment.
[Medium] Merge/key-override fix has no test coverage
The core behavior of this fix — symbolizing config keys so per-call options override matching config keys — is not asserted by any spec. Existing serialize specs pass {} and never combine @cli_config['snapshot'] with overlapping per-call options.
Suggestion: Add a unit test around Percy.snapshot that sets @cli_config = {'snapshot' => {'percyCSS' => 'a', 'minHeight' => 700}}, calls with percyCSS: 'b', and asserts the serialized options contain :percyCSS => 'b' (per-call override) and :minHeight => 700 (config inherited), with no duplicate string keys.
Reviewer: stack:code-review
Claude Code PR ReviewPR: #31 • Head: 3a32b11 • Reviewers: stack:code-review SummaryMerges Review Table
Findings
Verdict: PASS — the key-normalization fix is correct (per-call overrides config, single symbol key per option, downstream symbol-key consumers work); the only gap is missing tests for the new merge behavior (Medium, non-blocking). |
rishigupta1599
left a comment
There was a problem hiding this comment.
Claude Code Review (automated) — 2 inline finding(s). Full report in the PR comment below. Verdict: Passed.
| expect(data).to eq('sync_data') | ||
| end | ||
|
|
||
| it 'merges .percy.yml config with per-snapshot options (per-call wins)' do |
There was a problem hiding this comment.
[Medium] Test gap: config-only path and POST body unverified
This test covers "config sets two keys, per-call overrides one" but not the motivating case where options come solely from .percy.yml (per-call options = {}). It also does not assert the POST /percy/snapshot body. The POST is built from raw options (post_options = options.reject {...}), not merged_options, so config-only keys reach PercyDOM.serialize but are not re-sent on POST. That asymmetry matches the existing healthcheck pattern but is currently untested.
Suggestion: Add a test with empty per-call options and a populated config snapshot block, asserting config keys reach serialize; optionally add a have_requested(:post, ...) assertion documenting the POST-body contract for config-derived keys.
Reviewer: stack:code-review
| # do downstream consumers (responsive_snapshot_capture?, capture_responsive_dom). | ||
| # Symbolize config keys so per-call options override matching config keys | ||
| # instead of producing duplicate logical keys (per-call options take priority). | ||
| merged_options = config_options.transform_keys(&:to_sym).merge(options) |
There was a problem hiding this comment.
[Low] Shallow symbolize + now-redundant downstream config fallbacks
transform_keys(&:to_sym) is shallow, so nested config hashes (e.g. a future readiness object) keep string keys. Current consumers re-normalize, so this is safe today — a forward-compat note, not a bug. Separately, responsive_snapshot_capture? and the minHeight read in capture_responsive_dom still keep their own @cli_config&.dig(...) fallbacks, now redundant given this upstream merge (harmless but a maintainability hazard).
Suggestion: Note in the comment that only top-level keys are symbolized; optionally drop the redundant downstream @cli_config fallbacks in a follow-up with a test confirming the merged hash is the single source of truth.
Reviewer: stack:code-review
Claude Code PR ReviewPR: #31 • Head: 93e11f7 • Reviewers: stack:code-review SummaryMerges Review Table
Findings
Verdict: PASS — Core merge logic is correct and tested; remaining items are a Medium test-coverage gap and Low maintainability/forward-compat notes, none blocking. |
Claude Code PR ReviewPR: #31 • Head: 49a19d1 • Reviewers: stack:code-review SummaryReplaces the previous shallow top-level merge of Review Table
FindingsNo blocking findings. Non-blocking observations (do not affect verdict):
Verification performed:
Verdict: PASS — deep merge and symbolization are correct, non-mutating, and strengthen config reachability; only a non-blocking test gap and a pre-existing (adjudicated false-positive) POST-body note remain. |
Summary
.percy.ymlwere not being passed toPercyDOM.serialize()@cli_config['snapshot']with user options, with per-snapshot options taking priorityTest plan
.percy.ymlconfig options are applied during DOM serialization🤖 Generated with Claude Code