-
Notifications
You must be signed in to change notification settings - Fork 0
chore: upgrade capybara-screenshot-diff to v1.12.0 #279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| --- | ||
| name: 'Setup Hugo with caches' | ||
| description: 'Install Hugo + Bun, cache dependencies and build artifacts' | ||
| inputs: | ||
| hugo-version: | ||
| description: 'Hugo version' | ||
| default: '0.149.1' | ||
| environment: | ||
| description: 'Hugo build environment' | ||
| default: 'development' | ||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - uses: peaceiris/actions-hugo@v3 | ||
| with: | ||
| hugo-version: ${{ inputs.hugo-version }} | ||
| extended: true | ||
|
|
||
| - uses: oven-sh/setup-bun@v2 | ||
|
|
||
| - name: Cache Bun dependencies | ||
| uses: actions/cache@v5 | ||
| with: | ||
| path: | | ||
| ~/.bun/install/cache | ||
| node_modules | ||
| key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb', '**/package.json') }} | ||
| restore-keys: ${{ runner.os }}-bun- | ||
|
|
||
| - run: bun install --frozen-lockfile | ||
| shell: bash | ||
|
|
||
| - name: Cache Hugo build | ||
| uses: actions/cache@v5 | ||
| with: | ||
| path: | | ||
| /tmp/hugo_cache | ||
| resources/_gen | ||
| _dest | ||
| key: ${{ runner.os }}-hugo-${{ inputs.environment }}-${{ hashFiles('hugo.toml', 'hugo.dev.toml', 'postcss.config.js', 'package.json', '**/bun.lockb', 'themes/**', 'layouts/**', 'content/**') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-hugo-${{ inputs.environment }}- | ||
| ${{ runner.os }}-hugo- | ||
|
|
||
| - name: Build Hugo site | ||
| run: PATH="./node_modules/.bin:$PATH" bin/hugo-build | ||
| shell: bash | ||
| env: | ||
| HUGO_CACHEDIR: /tmp/hugo_cache | ||
| ENVIRONMENT: ${{ inputs.environment }} |
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
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| --- | ||
| name: Tests | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| workflow_dispatch: | ||
| inputs: | ||
| screenshots: | ||
| description: 'Run screenshot tests (slow, requires Hugo build)' | ||
| type: boolean | ||
| default: false | ||
| update-baselines: | ||
| description: 'Re-record screenshot baselines and commit' | ||
| type: boolean | ||
| default: false | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: tests-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| unit: | ||
| name: Unit Tests | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '4.0' | ||
| bundler-cache: true | ||
|
|
||
| - uses: ./.github/actions/setup-hugo | ||
|
|
||
| - run: bundle exec rake test:unit | ||
|
|
||
| screenshots: | ||
| name: Screenshot Tests | ||
| if: ${{ inputs.screenshots || inputs.update-baselines }} | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ github.head_ref || github.ref }} | ||
|
|
||
| - uses: snap-diff/snap_diff-capybara/.github/actions/setup-ruby-and-dependencies@master | ||
| with: | ||
| ruby-version: '4.0' | ||
| cache-apt-packages: true | ||
|
|
||
| - uses: ./.github/actions/setup-hugo | ||
|
|
||
| - name: Run screenshot tests | ||
| if: ${{ !inputs.update-baselines }} | ||
| run: bundle exec rake test | ||
| env: | ||
| SCREENSHOT_DRIVER: vips | ||
|
|
||
| - name: Record baselines | ||
| if: ${{ inputs.update-baselines }} | ||
| run: FORCE_SCREENSHOT_UPDATE=true bundle exec rake test | ||
| env: | ||
| SCREENSHOT_DRIVER: vips | ||
|
|
||
| - name: Commit updated baselines | ||
| if: ${{ inputs.update-baselines }} | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add test/fixtures/screenshots/ | ||
| git diff --staged --quiet || git commit -m "chore: update screenshot baselines [ci skip]" | ||
| git push | ||
|
|
||
| - name: Upload screenshot report | ||
| if: failure() | ||
| uses: snap-diff/snap_diff-capybara/.github/actions/upload-screenshots@master | ||
| with: | ||
| name: screenshots | ||
| report-path: test/fixtures/screenshots | ||
| pr-comment: 'true' | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ hugo.linux | |
| *.diff.png | ||
| *.base.png | ||
| *.attempt_*.png | ||
| snap_diff_report.html | ||
|
|
||
| # Capybara | ||
| capybara-*.png | ||
|
|
||
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-43.9 KB
(45%)
test/fixtures/screenshots/linux/desktop/about_page/_achievements.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-46.2 KB
(41%)
test/fixtures/screenshots/linux/desktop/about_page/_cta-contact_us.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-52.7 KB
(40%)
test/fixtures/screenshots/linux/desktop/about_page/_footer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-97.1 KB
(31%)
test/fixtures/screenshots/linux/desktop/about_page/_missions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-51 KB
(61%)
test/fixtures/screenshots/linux/desktop/about_page/_testimonials-header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-51.7 KB
(40%)
test/fixtures/screenshots/linux/desktop/about_page/_values.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-99.8 KB
(38%)
test/fixtures/screenshots/linux/desktop/blog/index/_pagination.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-74.6 KB
(36%)
test/fixtures/screenshots/linux/desktop/careers/junior-ruby-on-rails-developer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-90.7 KB
(32%)
...res/screenshots/linux/desktop/careers/junior-ruby-on-rails-developer/_apply.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-60.4 KB
(35%)
...es/screenshots/linux/desktop/careers/junior-ruby-on-rails-developer/_footer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-44.8 KB
(41%)
test/fixtures/screenshots/linux/desktop/clients/_cta-contact_us.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-87.1 KB
(50%)
test/fixtures/screenshots/linux/desktop/clients/_real-clients.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-48.4 KB
(44%)
test/fixtures/screenshots/linux/desktop/clients/_technologies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-51.5 KB
(59%)
test/fixtures/screenshots/linux/desktop/clients/_testimonials-header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-46.3 KB
(57%)
test/fixtures/screenshots/linux/desktop/clients/_testimonials.png
Oops, something went wrong.
Binary file modified
BIN
-46.3 KB
(41%)
test/fixtures/screenshots/linux/desktop/clients/agent-inbox/_cta-contact_us.png
Oops, something went wrong.
Binary file modified
BIN
-52.6 KB
(40%)
test/fixtures/screenshots/linux/desktop/clients/agent-inbox/_footer.png
Oops, something went wrong.
Binary file modified
BIN
-56.6 KB
(48%)
test/fixtures/screenshots/linux/desktop/clients/agent-inbox/_more-cases.png
Oops, something went wrong.
Binary file modified
BIN
+7.43 KB
(100%)
test/fixtures/screenshots/linux/desktop/clients/agent-inbox/_overview.png
Oops, something went wrong.
Binary file modified
BIN
-102 KB
(26%)
test/fixtures/screenshots/linux/desktop/clients/agent-inbox/_solution.png
Oops, something went wrong.
Binary file modified
BIN
-34.8 KB
(86%)
test/fixtures/screenshots/linux/desktop/clients/agent-inbox/_testimonial.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
-58.2 KB
(47%)
test/fixtures/screenshots/linux/desktop/homepage/_clients.png
Oops, something went wrong.
Binary file modified
BIN
-45.6 KB
(42%)
test/fixtures/screenshots/linux/desktop/homepage/_cta-contact_us.png
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
-87.6 KB
(35%)
test/fixtures/screenshots/linux/desktop/homepage/_services.png
Oops, something went wrong.
Binary file modified
BIN
-51.6 KB
(44%)
test/fixtures/screenshots/linux/desktop/homepage/_technologies.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
-45.9 KB
(41%)
test/fixtures/screenshots/linux/desktop/services/_cta-contact_us.png
Oops, something went wrong.
Binary file modified
BIN
-52.4 KB
(40%)
test/fixtures/screenshots/linux/desktop/services/_footer.png
Oops, something went wrong.
Binary file modified
BIN
-83.2 KB
(34%)
test/fixtures/screenshots/linux/desktop/services/_overview.png
Oops, something went wrong.
Binary file modified
BIN
-75.1 KB
(37%)
test/fixtures/screenshots/linux/desktop/services/_services.png
Oops, something went wrong.
Binary file modified
BIN
-31.8 KB
(53%)
test/fixtures/screenshots/linux/desktop/services/_technologies.png
Oops, something went wrong.
Binary file modified
BIN
-51.8 KB
(59%)
test/fixtures/screenshots/linux/desktop/services/_testimonials-header.png
Oops, something went wrong.
Binary file modified
BIN
-98.9 KB
(29%)
test/fixtures/screenshots/linux/desktop/services/_use-cases.png
Oops, something went wrong.
Binary file modified
BIN
+10.5 KB
(100%)
test/fixtures/screenshots/linux/desktop/services/app_web_development.png
Oops, something went wrong.
Binary file modified
BIN
+10.5 KB
(100%)
test/fixtures/screenshots/linux/desktop/services/app_web_development_hero.png
Oops, something went wrong.
Binary file modified
BIN
-74.6 KB
(44%)
...res/screenshots/linux/desktop/services/fractional-cto/_clients-case-studies.png
Oops, something went wrong.
Binary file modified
BIN
-48 KB
(40%)
.../fixtures/screenshots/linux/desktop/services/fractional-cto/_cta-contact_us.png
Oops, something went wrong.
Binary file modified
BIN
-54.4 KB
(39%)
test/fixtures/screenshots/linux/desktop/services/fractional-cto/_footer.png
Oops, something went wrong.
Binary file modified
BIN
-85.2 KB
(31%)
test/fixtures/screenshots/linux/desktop/services/fractional-cto/_overview.png
Oops, something went wrong.
Binary file modified
BIN
-51.3 KB
(59%)
...ures/screenshots/linux/desktop/services/fractional-cto/_testimonials-header.png
Oops, something went wrong.
Binary file modified
BIN
-46.9 KB
(56%)
test/fixtures/screenshots/linux/desktop/services/fractional-cto/_testimonials.png
Oops, something went wrong.
Binary file modified
BIN
+38.1 KB
(110%)
test/fixtures/screenshots/linux/desktop/services/fractional_cto.png
Oops, something went wrong.
Binary file modified
BIN
-46.2 KB
(41%)
test/fixtures/screenshots/linux/desktop/use-cases/_cta-contact_us.png
Oops, something went wrong.
Binary file modified
BIN
-52.7 KB
(40%)
test/fixtures/screenshots/linux/desktop/use-cases/_footer.png
Oops, something went wrong.
Binary file modified
BIN
-89.3 KB
(34%)
test/fixtures/screenshots/linux/desktop/use-cases/_overview.png
Oops, something went wrong.
Binary file modified
BIN
-32.2 KB
(53%)
test/fixtures/screenshots/linux/desktop/use-cases/_technologies.png
Oops, something went wrong.
Binary file modified
BIN
-50.9 KB
(61%)
test/fixtures/screenshots/linux/desktop/use-cases/_testimonials-header.png
Oops, something went wrong.
Binary file modified
BIN
-68.4 KB
(44%)
...desktop/use-cases/startup-mvp-prototyping-development/_clients-case-studies.png
Oops, something went wrong.
Binary file modified
BIN
-46.2 KB
(41%)
...linux/desktop/use-cases/startup-mvp-prototyping-development/_cta-contact_us.png
Oops, something went wrong.
Binary file modified
BIN
-52.6 KB
(40%)
...enshots/linux/desktop/use-cases/startup-mvp-prototyping-development/_footer.png
Oops, something went wrong.
Binary file modified
BIN
-26.2 KB
(97%)
...shots/linux/desktop/use-cases/startup-mvp-prototyping-development/_overview.png
Oops, something went wrong.
Binary file modified
BIN
-104 KB
(31%)
...shots/linux/desktop/use-cases/startup-mvp-prototyping-development/_solution.png
Oops, something went wrong.
Binary file modified
BIN
-51.5 KB
(59%)
.../desktop/use-cases/startup-mvp-prototyping-development/_testimonials-header.png
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
-29.4 KB
(26%)
test/fixtures/screenshots/linux/mobile/about_page/achievements.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
-22.7 KB
(37%)
test/fixtures/screenshots/linux/mobile/blog/index/_pagination.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
-24.9 KB
(43%)
test/fixtures/screenshots/linux/mobile/free_consultation.png
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
-7.3 KB
(62%)
test/fixtures/screenshots/linux/mobile/nav/hamburger_menu.png
Oops, something went wrong.
Binary file modified
BIN
-17.8 KB
(53%)
test/fixtures/screenshots/linux/mobile/nav/hamburger_menu/services.png
Oops, something went wrong.
Binary file modified
BIN
-36.6 KB
(96%)
test/fixtures/screenshots/linux/pages/careers/benefits-section.png
Oops, something went wrong.
Binary file modified
BIN
-36.6 KB
(96%)
test/fixtures/screenshots/linux/pages/careers/benefits-spacing.png
Oops, something went wrong.
Binary file modified
BIN
-36.6 KB
(96%)
test/fixtures/screenshots/linux/pages/careers/careers-page-full.png
Oops, something went wrong.
Binary file modified
BIN
-36.6 KB
(96%)
test/fixtures/screenshots/linux/pages/careers/feature-cards-section.png
Oops, something went wrong.
Binary file modified
BIN
-36.6 KB
(96%)
test/fixtures/screenshots/linux/pages/careers/newsletter-section.png
Oops, something went wrong.
Binary file modified
BIN
-10.6 KB
(99%)
test/fixtures/screenshots/macos/pages/careers/benefits-section.png
Oops, something went wrong.
Binary file modified
BIN
-10.6 KB
(99%)
test/fixtures/screenshots/macos/pages/careers/benefits-spacing.png
Oops, something went wrong.
Binary file modified
BIN
-10.6 KB
(99%)
test/fixtures/screenshots/macos/pages/careers/careers-page-full.png
Oops, something went wrong.
Binary file modified
BIN
-10.6 KB
(99%)
test/fixtures/screenshots/macos/pages/careers/feature-cards-section.png
Oops, something went wrong.
Binary file modified
BIN
-10.6 KB
(99%)
test/fixtures/screenshots/macos/pages/careers/newsletter-section.png
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,80 +1,24 @@ | ||
| # Screenshot Testing Configuration | ||
| # | ||
| # Environment Variables for controlling screenshot behavior: | ||
| # - SCREENSHOT_TOLERANCE: Override global tolerance (default: 0.01 = 1%) | ||
| # - SCREENSHOT_STABILITY_TIME: Override stability wait time (default: 1.0s) | ||
| # - FORCE_SCREENSHOT_UPDATE: Set to 'true' to regenerate all baseline screenshots | ||
| # - CAPYBARA_SCREENSHOT_DIFF_FAIL_ON_DIFFERENCE: Set to 'false' to update baselines | ||
| # | ||
| # Usage Examples: | ||
| # SCREENSHOT_TOLERANCE=0.02 bundle exec rake test # 2% tolerance | ||
| # SCREENSHOT_STABILITY_TIME=2.0 bundle exec rake test # 2s stability time | ||
| # FORCE_SCREENSHOT_UPDATE=true bundle exec rake test # Regenerate baselines | ||
| # Environment Variables: | ||
| # - SCREENSHOT_STABILITY_TIME: Override stability wait time (default: 0.1s) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| # - FORCE_SCREENSHOT_UPDATE: Set to 'true' to regenerate all baselines | ||
| # | ||
|
|
||
| require "capybara_screenshot_diff/minitest" | ||
| require "capybara_screenshot_diff/reporters/html" | ||
|
|
||
| Capybara::Screenshot.save_path = "test/fixtures/screenshots" | ||
| Capybara::Screenshot.add_os_path = true | ||
| Capybara::Screenshot.window_size = nil | ||
|
|
||
| # Screenshot stability and tolerance settings | ||
| # | ||
| # stability_time_limit: Time to wait for the page to be stable before taking screenshot | ||
| # Increased from 0.25s to 1.0s to reduce flakiness from animations/loading states | ||
| Capybara::Screenshot.stability_time_limit = ENV.fetch("SCREENSHOT_STABILITY_TIME", "0.1").to_f | ||
|
|
||
| # tolerance: Allowed difference percentage between baseline and current screenshot | ||
| # Increased from 0.005 (0.5%) to 0.01 (1%) to handle cross-platform rendering differences | ||
| # across different environments, versions, and operating systems | ||
| Capybara::Screenshot::Diff.tolerance = ENV.fetch("SCREENSHOT_TOLERANCE", "0.005").to_f | ||
| Capybara::Screenshot.disable_animations = true | ||
| Capybara::Screenshot.root = Dir.pwd | ||
|
|
||
| Capybara::Screenshot::Diff.driver = :vips | ||
| Capybara::Screenshot::Diff.perceptual_threshold = 2.0 | ||
|
pftg marked this conversation as resolved.
|
||
| Capybara::Screenshot::Diff.delayed = true | ||
| Capybara.default_max_wait_time = 5 | ||
|
|
||
| # Add global setup hook to disable animations for all screenshot tests | ||
| Capybara.configure do |config| | ||
| # Ensure screenshots are taken with consistent rendering | ||
| config.default_set_options = {clear: :backspace} | ||
| end | ||
|
|
||
| # Add after_action callback to prepare pages for screenshots if needed | ||
| module ScreenshotPreparation | ||
| def self.disable_animations_globally(page) | ||
| page.execute_script(<<~JS) if page.driver.browser.respond_to?(:execute_script) | ||
| if (!document.querySelector('#screenshot-test-animations-disabled')) { | ||
| const style = document.createElement('style'); | ||
| style.id = 'screenshot-test-animations-disabled'; | ||
| style.innerHTML = ` | ||
| *, *::before, *::after { | ||
| animation-duration: 0s !important; | ||
| animation-delay: 0s !important; | ||
| transition-duration: 0s !important; | ||
| transition-delay: 0s !important; | ||
| animation-play-state: paused !important; | ||
| -webkit-animation-duration: 0s !important; | ||
| -webkit-animation-delay: 0s !important; | ||
| -webkit-transition-duration: 0s !important; | ||
| -webkit-transition-delay: 0s !important; | ||
| } | ||
| `; | ||
| document.head.appendChild(style); | ||
| } | ||
| JS | ||
| end | ||
| end | ||
|
|
||
| # Environment variable controls for screenshot behavior | ||
| # | ||
| # CAPYBARA_SCREENSHOT_DIFF_FAIL_ON_DIFFERENCE=false: Useful for updating screenshot baselines | ||
| if ENV["CAPYBARA_SCREENSHOT_DIFF_FAIL_ON_DIFFERENCE"] == "false" | ||
| Capybara::Screenshot::Diff.fail_on_difference = false | ||
| end | ||
|
|
||
| # FORCE_SCREENSHOT_UPDATE=true: Regenerate all baseline screenshots | ||
| if ENV["FORCE_SCREENSHOT_UPDATE"] == "true" | ||
| Capybara::Screenshot::Diff.fail_on_difference = false | ||
| end | ||
|
|
||
| Capybara::Screenshot.root = Dir.pwd | ||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
cat -n .github/workflows/test.yml | head -50Repository: jetthoughts/jetthoughts.github.io
Length of output: 1369
🏁 Script executed:
Repository: jetthoughts/jetthoughts.github.io
Length of output: 298
Pin external action refs to immutable commit SHAs instead of
@master.Lines 26 and 40 reference moving branches which can break reproducibility and increase supply-chain risk. Replace
@masterwith specific commit SHAs for bothsetup-ruby-and-dependenciesandupload-screenshotsactions.🤖 Prompt for AI Agents