Skip to content

feat: quick wins + disable_animations helper + driver contract tests#174

Merged
pftg merged 4 commits intomasterfrom
feat/quick-wins-and-animation-helper
Apr 12, 2026
Merged

feat: quick wins + disable_animations helper + driver contract tests#174
pftg merged 4 commits intomasterfrom
feat/quick-wins-and-animation-helper

Conversation

@pftg
Copy link
Copy Markdown
Collaborator

@pftg pftg commented Apr 12, 2026

Summary

7 tasks from the prioritized backlog:

Quick wins

  • T5 Remove dead code: TestPreprocessor, VipsDriver#region_covers_entire_image?, ScreenshotNamer#clear_current_group_directory (verified with SimpleCov)
  • T7 Fix TestDriver#class comment — explain WHY, not WHAT
  • T8 Delete unused TestPreprocessor class

Features

  • P3.2 HTML report path defaults to screenshot root ({root}/{save_path}/snap_diff_report.html) — convention over configuration, no new setting
  • P3.1 Document Screenshoter constructor contract (signatures already unified)
  • P2.3 Capybara::Screenshot.disable_animations = true — injects CSS to disable all animations/transitions before screenshot

Tests

  • T1 Shared DriverContractTests module — 5 contract assertions included in both ChunkyPNG and VIPS driver tests (+30 assertions)

Test plan

  • Unit tests pass (212 runs, 635 assertions, 0 failures)
  • Dead code verified with SimpleCov coverage report
  • New disable_animations follows hide_caret pattern exactly

Generated with Claude Code

Summary by Sourcery

Introduce animation-disabling support for screenshots, standardize HTML report output location, and add shared driver contract tests while removing unused code and helpers.

New Features:

  • Add BrowserHelpers.disable_animations and a corresponding Capybara::Screenshot.disable_animations setting to turn off animations and transitions before capturing screenshots.
  • Default HTML reporter output path to the Capybara screenshot root/save_path convention when no path is given.

Enhancements:

  • Document the Screenshoter constructor options to clarify capture and comparison configuration.
  • Clarify the TestDriver#class override comment to describe its purpose in decoupling tests from the driver class name.
  • Extract a shared DriverContractTests module and apply it to both ChunkyPNG and VIPS driver tests to enforce a common behavior contract.

Tests:

  • Add contract tests covering equality, difference detection, and annotated image generation across all image processing drivers.
  • Add tests ensuring the HTML reporter uses the default screenshot root path when no output_path is provided.

Chores:

  • Remove unused TestPreprocessor test double, VipsDriver#region_covers_entire_image? helper, and ScreenshotNamer#clear_current_group_directory API and its tests.
  • Update the sample report generation script to use the HTML reporter’s default_output_path helper.

Summary by CodeRabbit

  • New Features

    • Option to disable CSS animations/transitions before screenshots for more stable visual tests.
  • Refactor

    • HTML report generator now lazily resolves its output path from project configuration.
  • Tests

    • Added shared driver contract tests; updated reporter and setup tests to handle the new animation option and restore state between tests.
  • Documentation

    • README updated to document the new animation-disable option.
  • Chores

    • Added CI script to run linter and unit tests.
  • Removals

    • Removed legacy helpers and test doubles related to screenshot grouping and preprocessing.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 12, 2026

Reviewer's Guide

Implements a new disable_animations helper following the existing hide_caret pattern, changes the HTML reporter to default its output path under the configured screenshot root, introduces shared driver contract tests, and removes several pieces of dead code and outdated behavior while documenting the Screenshoter constructor contract and adjusting tests/scripts accordingly.

Sequence diagram for the new disable_animations helper in screenshot preparation

sequenceDiagram
  actor TestRunner
  participant Screenshoter as Screenshoter
  participant ScreenshotConfig as Screenshot
  participant BrowserHelpers as BrowserHelpers

  TestRunner->>Screenshoter: prepare_page_for_screenshot(timeout)
  Screenshoter->>ScreenshotConfig: read blur_active_element
  alt blur_active_element is true
    Screenshoter->>BrowserHelpers: blur_from_focused_element()
    BrowserHelpers-->>Screenshoter: blurred_input
  else blur_active_element is false
    Screenshoter-->>TestRunner: nil blurred_input
  end

  Screenshoter->>ScreenshotConfig: read hide_caret
  alt hide_caret is true
    Screenshoter->>BrowserHelpers: hide_caret()
  end

  Screenshoter->>ScreenshotConfig: read disable_animations
  alt disable_animations is true
    Screenshoter->>BrowserHelpers: disable_animations()
  end

  Screenshoter-->>TestRunner: prepared_page_with_optional_blur
Loading

Updated class diagram for Screenshoter, BrowserHelpers, Screenshot config, and HTML reporter

classDiagram
  class CapybaraScreenshotDiffScreenshot {
    <<module>>
    +Boolean blur_active_element
    +Boolean enabled
    +Boolean hide_caret
    +Boolean disable_animations
    +Pathname root
    +Integer stability_time_limit
    +Array window_size
  }

  class CapybaraScreenshotDiffBrowserHelpers {
    <<module>>
    +hide_caret()
    +disable_animations()
    +blur_from_focused_element()
  }

  class CapybaraScreenshotDiffScreenshotScreenshoter {
    +Hash capture_options
    +Object driver
    +Screenshoter(capture_options, comparison_options)
    +prepare_page_for_screenshot(timeout)
  }

  class CapybaraScreenshotDiffReportersHTML {
    +Pathname output_path
    +Boolean embed_images
    +Array failures
    +Integer total
    +HTML(output_path, embed_images)
    +add_failure(name, compare)
    +save()
    +self.template_path()
    +self.default_output_path()
  }

  CapybaraScreenshotDiffScreenshotScreenshoter ..> CapybaraScreenshotDiffBrowserHelpers : uses
  CapybaraScreenshotDiffScreenshotScreenshoter ..> CapybaraScreenshotDiffScreenshot : reads_flags
  CapybaraScreenshotDiffReportersHTML ..> CapybaraScreenshotDiffScreenshot : uses_root_and_save_path
Loading

File-Level Changes

Change Details Files
Add browser helper and configuration flag to disable animations during screenshot capture.
  • Introduce a JavaScript snippet that injects a style tag disabling CSS animations and transitions.
  • Expose a disable_animations helper on the browser helpers that runs the script via the Capybara session.
  • Add a disable_animations configuration option alongside existing screenshot options and integrate it into the screenshot preparation flow.
  • Update test setup/teardown to capture and restore the new disable_animations flag.
lib/capybara/screenshot/diff/browser_helpers.rb
lib/capybara/screenshot/diff/screenshoter.rb
lib/capybara_screenshot_diff.rb
test/test_helper.rb
Change HTML report to default its output path under the screenshot root, and reuse this in scripts and tests.
  • Alter HTML reporter initialization to accept a nil output_path and resolve to a default path when omitted.
  • Add a class-level default_output_path helper based on Capybara::Screenshot.root and save_path.
  • Update the sample report generation script to use the new default_output_path instead of a hard-coded path.
  • Add a unit test ensuring the reporter defaults to the screenshot root path.
lib/capybara_screenshot_diff/reporters/html.rb
scripts/generate_sample_report.rb
test/unit/reporters/html_reporter_test.rb
Introduce shared driver contract tests and apply them to both ChunkyPNG and VIPS drivers.
  • Create a DriverContractTests concern that defines core behavior tests around quick_equal?, different?, and annotated image generation.
  • Require and include the shared contract tests in ChunkyPNG driver tests.
  • Require and include the shared contract tests in VIPS driver tests.
test/support/driver_contract_tests.rb
test/unit/drivers/chunky_png_driver_test.rb
test/unit/drivers/vips_driver_test.rb
Improve documentation and cleanup for the Screenshoter and test doubles, and remove dead code.
  • Add YARD-style documentation to the Screenshoter constructor clarifying capture and comparison options.
  • Clarify the TestDriver#class override comment to describe the rationale instead of the mechanics.
  • Remove the unused TestPreprocessor test double and associated dead code.
  • Remove the clear_current_group_directory API and its tests from ScreenshotNamer as unused functionality.
  • Delete an unused private helper from the Vips driver that checked whether a region covered the entire image.
lib/capybara/screenshot/diff/screenshoter.rb
test/support/test_doubles.rb
lib/capybara_screenshot_diff/screenshot_namer.rb
test/unit/screenshot_namer_test.rb
lib/capybara/screenshot/diff/drivers/vips_driver.rb

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 12, 2026

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 1 minutes and 20 seconds.

⌛ 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c41b3d3-4459-4552-a53a-eaa5fcccc2d1

📥 Commits

Reviewing files that changed from the base of the PR and between 12b70b5 and 60222d2.

📒 Files selected for processing (19)
  • README.md
  • bin/ci
  • lib/capybara/screenshot/diff/browser_helpers.rb
  • lib/capybara/screenshot/diff/drivers/vips_driver.rb
  • lib/capybara/screenshot/diff/screenshoter.rb
  • lib/capybara/screenshot/diff/vcs.rb
  • lib/capybara_screenshot_diff.rb
  • lib/capybara_screenshot_diff/reporters/html.rb
  • lib/capybara_screenshot_diff/screenshot_namer.rb
  • scripts/generate_sample_report.rb
  • test/support/driver_contract_tests.rb
  • test/support/test_doubles.rb
  • test/test_helper.rb
  • test/unit/drivers/chunky_png_driver_test.rb
  • test/unit/drivers/vips_driver_test.rb
  • test/unit/reporters/html_reporter_test.rb
  • test/unit/screenshot_namer_test.rb
  • test/unit/static_test.rb
  • test/unit/vcs_test.rb
📝 Walkthrough

Walkthrough

Added a configurable animation-disabling hook that injects a guarded global CSS style before screenshots; refactored HTML reporter to lazily compute its default output path; removed unused helpers/test artifacts; added shared driver contract tests; small test harness and CI/script updates.

Changes

Cohort / File(s) Summary
Animation disabling
lib/capybara_screenshot_diff.rb, lib/capybara/screenshot/diff/browser_helpers.rb, lib/capybara/screenshot/diff/screenshoter.rb, test/test_helper.rb
Added Capybara::Screenshot.disable_animations mattr_accessor and BrowserHelpers::DISABLE_ANIMATIONS_SCRIPT plus BrowserHelpers.disable_animations which injects a guarded <style> to zero animations/transitions; Screenshoter.prepare_page_for_screenshot calls it when enabled; tests snapshot/restore the setting.
HTML reporter output path
lib/capybara_screenshot_diff/reporters/html.rb, scripts/generate_sample_report.rb, test/unit/reporters/html_reporter_test.rb
Changed HTML#initialize(output_path:) to accept nil, introduced HTML#output_path and HTML.default_output_path computing `<Capybara::Screenshot.root
Driver contract tests
test/support/driver_contract_tests.rb, test/unit/drivers/chunky_png_driver_test.rb, test/unit/drivers/vips_driver_test.rb
Added DriverContractTests ActiveSupport::Concern with shared comparison tests; included into ChunkyPNG and VIPS driver tests.
Removed unused helpers & test artifacts
lib/capybara/screenshot/diff/drivers/vips_driver.rb, lib/capybara_screenshot_diff/screenshot_namer.rb, test/unit/screenshot_namer_test.rb, test/support/test_doubles.rb
Deleted unused region_covers_entire_image? from VIPS driver, removed clear_current_group_directory and its tests from ScreenshotNamer, and removed TestPreprocessor test double; minor inline comment update.
VCS command robustness
lib/capybara/screenshot/diff/vcs.rb, test/unit/vcs_test.rb
Made git invocations explicit with git -C <root> and adjusted a test assertion message.
State handling in tests
test/unit/static_test.rb, test/test_helper.rb
Added setup/teardown to snapshot/restore Capybara::Screenshot.root and Capybara::Screenshot.disable_animations to avoid test leakage.
CI & scripts
bin/ci, scripts/generate_sample_report.rb
Added bin/ci linter+unit-test wrapper that auto-fixes then fails to force review; sample report script now uses reporter default output path.
Misc cleanup
lib/capybara/screenshot/diff/drivers/vips_driver.rb, lib/capybara_screenshot_diff/screenshot_namer.rb
Removed small unused methods and related tests referenced above.

Sequence Diagram(s)

(Skipped — changes are localized and do not introduce multi-component sequential flows that benefit from a diagram.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • donv

Poem

🐰
I nudge the styles so pixels rest,
Still frames align for their best test.
Paths settle true, drivers agree,
Tests hop steady — calm as can be.
A snapshot paused, neat victory.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately reflects the main changes: removing dead code, adding the disable_animations helper, and introducing driver contract tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/quick-wins-and-animation-helper

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 12, 2026

Screenshot diffs resolved

All screenshots match their baselines. Previous diffs have been fixed.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In Reporters::HTML.default_output_path, consider returning a Pathname instead of a String so callers (including #initialize) don’t need to re-wrap it and the type stays consistent throughout.
  • The DISABLE_ANIMATIONS_SCRIPT relies on style.sheet.insertRule, which can be null in some environments right after appending the <style>; using style.textContent = '...css...' (or style.appendChild(document.createTextNode(...))) would make the helper more robust across browsers/drivers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `Reporters::HTML.default_output_path`, consider returning a `Pathname` instead of a `String` so callers (including `#initialize`) don’t need to re-wrap it and the type stays consistent throughout.
- The `DISABLE_ANIMATIONS_SCRIPT` relies on `style.sheet.insertRule`, which can be `null` in some environments right after appending the `<style>`; using `style.textContent = '...css...'` (or `style.appendChild(document.createTextNode(...))`) would make the helper more robust across browsers/drivers.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@pftg pftg force-pushed the feat/quick-wins-and-animation-helper branch from 55e7992 to 5df6b00 Compare April 12, 2026 17:51
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/support/driver_contract_tests.rb (1)

24-30: Make the “annotated images for different images” test self-contained.

Add an explicit assertion on comp.different? in this test to keep failure signals local and easier to diagnose.

✅ Optional refinement
     test "[contract] different? generates annotated images for different images" do
       comp = make_comparison(:a, :c)
-      comp.different?
+      assert comp.different?
 
       assert File.exist?(comp.reporter.annotated_base_image_path)
       assert File.exist?(comp.reporter.annotated_image_path)
     end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/support/driver_contract_tests.rb` around lines 24 - 30, The test should
assert that the comparison reports a difference before checking annotated files:
add an explicit assertion such as assert comp.different? (or assert_equal true,
comp.different?) immediately after calling comp.different? in the "[contract]
different? generates annotated images for different images" test so failure of
the comparison itself is reported locally; keep the existing File.exist?
assertions for comp.reporter.annotated_base_image_path and
comp.reporter.annotated_image_path unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/support/test_doubles.rb`:
- Around line 99-101: There is an extra blank line between class definitions in
test/support/test_doubles.rb causing standardrb to fail; remove the extra empty
line so there is only a single blank line separating the previous class and the
TestDifference class (class TestDifference) to satisfy the linter.

---

Nitpick comments:
In `@test/support/driver_contract_tests.rb`:
- Around line 24-30: The test should assert that the comparison reports a
difference before checking annotated files: add an explicit assertion such as
assert comp.different? (or assert_equal true, comp.different?) immediately after
calling comp.different? in the "[contract] different? generates annotated images
for different images" test so failure of the comparison itself is reported
locally; keep the existing File.exist? assertions for
comp.reporter.annotated_base_image_path and comp.reporter.annotated_image_path
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a9288cb5-9a35-48ab-91f5-d0e5262a9432

📥 Commits

Reviewing files that changed from the base of the PR and between b4f043c and 1bc1145.

📒 Files selected for processing (14)
  • lib/capybara/screenshot/diff/browser_helpers.rb
  • lib/capybara/screenshot/diff/drivers/vips_driver.rb
  • lib/capybara/screenshot/diff/screenshoter.rb
  • lib/capybara_screenshot_diff.rb
  • lib/capybara_screenshot_diff/reporters/html.rb
  • lib/capybara_screenshot_diff/screenshot_namer.rb
  • scripts/generate_sample_report.rb
  • test/support/driver_contract_tests.rb
  • test/support/test_doubles.rb
  • test/test_helper.rb
  • test/unit/drivers/chunky_png_driver_test.rb
  • test/unit/drivers/vips_driver_test.rb
  • test/unit/reporters/html_reporter_test.rb
  • test/unit/screenshot_namer_test.rb
💤 Files with no reviewable changes (3)
  • test/unit/screenshot_namer_test.rb
  • lib/capybara/screenshot/diff/drivers/vips_driver.rb
  • lib/capybara_screenshot_diff/screenshot_namer.rb

Comment thread test/support/test_doubles.rb Outdated
@pftg pftg force-pushed the feat/quick-wins-and-animation-helper branch 4 times, most recently from 967c6c3 to d140fda Compare April 12, 2026 18:23
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
bin/ci (1)

5-13: Make script path resolution independent of the caller’s working directory.

bin/standardrb and bin/rake rely on running from repo root. Resolving the repo root from the script location makes this CI entrypoint more reliable across runners and local usage.

Proposed diff
-#!/bin/bash
+#!/bin/bash
 set -e
+
+ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
 
 echo "Running linter..."
-if ! bin/standardrb; then
+if ! "$ROOT_DIR/bin/standardrb"; then
   echo "Lint errors found. Auto-fixing..."
-  bin/standardrb -a
+  "$ROOT_DIR/bin/standardrb" -a
   echo "Lint errors were auto-fixed. Please review and re-commit."
   exit 1
 fi
 
 echo "Running unit tests..."
-bin/rake test:unit
+"$ROOT_DIR/bin/rake" test:unit
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/ci` around lines 5 - 13, The CI script currently invokes bin/standardrb
and bin/rake relative to the caller’s cwd; make path resolution independent by
resolving the script directory at runtime (use the script’s directory via "$(cd
"$(dirname "$0")" && pwd)" or equivalent) and prepend that directory when
invoking the tools so calls to bin/standardrb -a and bin/rake test:unit use the
repo’s bin directory; update the invocations in the bin/ci script (references:
bin/standardrb and bin/rake) to use the resolved script-dir-prefixed paths and
keep behavior (auto-fix, messages, exit codes) unchanged.
test/unit/drivers/vips_driver_test.rb (1)

19-19: Consider removing now-redundant local assertions.

After including DriverContractTests on Line 19, a few existing VIPS tests in this class overlap with the same contract behaviors. Pruning duplicates would reduce maintenance and test runtime without losing coverage.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/unit/drivers/vips_driver_test.rb` at line 19, The test class now
includes the shared suite via include DriverContractTests; remove redundant
local assertions and duplicate test methods in the VIPS driver test class that
replicate behaviors provided by DriverContractTests (identify methods/assertions
referencing the same contracts and delete them), keeping only any VIPS-specific
or additional edge-case assertions; ensure any remaining unique tests reference
the VIPS driver helper/setup used in this file and run the test suite to confirm
coverage is preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@bin/ci`:
- Around line 5-13: The CI script currently invokes bin/standardrb and bin/rake
relative to the caller’s cwd; make path resolution independent by resolving the
script directory at runtime (use the script’s directory via "$(cd "$(dirname
"$0")" && pwd)" or equivalent) and prepend that directory when invoking the
tools so calls to bin/standardrb -a and bin/rake test:unit use the repo’s bin
directory; update the invocations in the bin/ci script (references:
bin/standardrb and bin/rake) to use the resolved script-dir-prefixed paths and
keep behavior (auto-fix, messages, exit codes) unchanged.

In `@test/unit/drivers/vips_driver_test.rb`:
- Line 19: The test class now includes the shared suite via include
DriverContractTests; remove redundant local assertions and duplicate test
methods in the VIPS driver test class that replicate behaviors provided by
DriverContractTests (identify methods/assertions referencing the same contracts
and delete them), keeping only any VIPS-specific or additional edge-case
assertions; ensure any remaining unique tests reference the VIPS driver
helper/setup used in this file and run the test suite to confirm coverage is
preserved.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3668474d-e6e6-4244-a4a3-148aa413fea5

📥 Commits

Reviewing files that changed from the base of the PR and between 24fe3c1 and d140fda.

📒 Files selected for processing (16)
  • README.md
  • bin/ci
  • lib/capybara/screenshot/diff/browser_helpers.rb
  • lib/capybara/screenshot/diff/drivers/vips_driver.rb
  • lib/capybara/screenshot/diff/screenshoter.rb
  • lib/capybara_screenshot_diff.rb
  • lib/capybara_screenshot_diff/reporters/html.rb
  • lib/capybara_screenshot_diff/screenshot_namer.rb
  • scripts/generate_sample_report.rb
  • test/support/driver_contract_tests.rb
  • test/support/test_doubles.rb
  • test/test_helper.rb
  • test/unit/drivers/chunky_png_driver_test.rb
  • test/unit/drivers/vips_driver_test.rb
  • test/unit/reporters/html_reporter_test.rb
  • test/unit/screenshot_namer_test.rb
💤 Files with no reviewable changes (3)
  • test/unit/screenshot_namer_test.rb
  • lib/capybara/screenshot/diff/drivers/vips_driver.rb
  • lib/capybara_screenshot_diff/screenshot_namer.rb
✅ Files skipped from review due to trivial changes (5)
  • test/unit/drivers/chunky_png_driver_test.rb
  • test/test_helper.rb
  • test/unit/reporters/html_reporter_test.rb
  • scripts/generate_sample_report.rb
  • lib/capybara_screenshot_diff.rb
🚧 Files skipped from review as they are similar to previous changes (3)
  • lib/capybara/screenshot/diff/screenshoter.rb
  • lib/capybara/screenshot/diff/browser_helpers.rb
  • lib/capybara_screenshot_diff/reporters/html.rb

@pftg pftg force-pushed the feat/quick-wins-and-animation-helper branch 3 times, most recently from 12b70b5 to d34a625 Compare April 12, 2026 18:59
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/capybara/screenshot/diff/vcs.rb`:
- Around line 12-16: The code resolves screenshot_path with
Pathname.new(screenshot_path).expand_path which uses the process CWD; change it
to expand relative to the repository root (use git_root or root_path as the
base) before calling relative_path_from so resolution is independent of the
process CWD. Locate the vcs_file_path assignment and update the expand_path call
to use the git_root/root_path as the second argument (keeping the subsequent
relative_path_from(Pathname.new(git_root))) so vcs_file_path is computed from
the repo root rather than the current working directory.
- Line 13: Replace all backtick and interpolated string shell invocations that
use root_path, checkout_path, and vcs_file_path (e.g., the git_root assignment
and subsequent system(...) calls) with argv-style execution to avoid shell
interpolation: use Open3.capture3 (or Kernel.system/spawn with the array-form)
and pass the command and each argument as separate parameters (e.g., ['git',
'-C', root_path, 'rev-parse', '--show-toplevel']) so paths are not interpreted
by the shell; update the git_root assignment and every system(...) call that
currently interpolates root_path/checkout_path/vcs_file_path to use this safe
form and handle stdout/stderr/exit status accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 428ab84d-2ed3-45b3-9569-b236652e6b80

📥 Commits

Reviewing files that changed from the base of the PR and between d140fda and 12b70b5.

📒 Files selected for processing (3)
  • lib/capybara/screenshot/diff/vcs.rb
  • test/unit/static_test.rb
  • test/unit/vcs_test.rb
✅ Files skipped from review due to trivial changes (1)
  • test/unit/vcs_test.rb

Comment thread lib/capybara/screenshot/diff/vcs.rb Outdated
Comment thread lib/capybara/screenshot/diff/vcs.rb Outdated
@pftg pftg force-pushed the feat/quick-wins-and-animation-helper branch from d34a625 to 5261dc3 Compare April 12, 2026 19:11
pftg and others added 4 commits April 12, 2026 21:17
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- VCS uses Open3/array-form system (no Dir.chdir, no shell interpolation)
- Global state guard: snapshot/restore all mattr_accessors per test
- static_test.rb restores Screenshot.root in teardown
- bin/ci: lint + unit tests with auto-fix for pre-push hook

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pftg pftg force-pushed the feat/quick-wins-and-animation-helper branch from 5261dc3 to 60222d2 Compare April 12, 2026 19:18
@pftg pftg merged commit 331b5c3 into master Apr 12, 2026
8 checks passed
@pftg pftg deleted the feat/quick-wins-and-animation-helper branch April 12, 2026 20:15
pftg added a commit that referenced this pull request Apr 12, 2026
…t.html

Default output path changed from tmp/snap_diff/index.html to
{root}/{save_path}/snap_diff_report.html in PR #174. Updated all
docs and CI action to match.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant