lookbook_visual_tester 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env.example +13 -0
- data/CHANGELOG.md +26 -0
- data/README.md +18 -9
- data/Rakefile +53 -0
- data/docs/superpowers/plans/2026-08-09-lookbook-visual-tester-hardening.md +1792 -0
- data/lib/lookbook_visual_tester/browser_discovery.rb +31 -0
- data/lib/lookbook_visual_tester/configuration.rb +11 -4
- data/lib/lookbook_visual_tester/drivers/ferrum_driver.rb +8 -4
- data/lib/lookbook_visual_tester/preview_checker.rb +41 -214
- data/lib/lookbook_visual_tester/railtie.rb +2 -8
- data/lib/lookbook_visual_tester/runner.rb +108 -92
- data/lib/lookbook_visual_tester/server_test_runner.rb +102 -0
- data/lib/lookbook_visual_tester/services/image_trimmer.rb +59 -0
- data/lib/lookbook_visual_tester/update_previews.rb +3 -12
- data/lib/lookbook_visual_tester/version.rb +1 -1
- data/lib/lookbook_visual_tester.rb +4 -0
- data/lib/tasks/lookbook_visual_tester.rake +50 -51
- metadata +38 -51
- data/lib/lookbook_visual_tester/baseline_manager.rb +0 -34
- data/lib/lookbook_visual_tester/capybara_setup.rb +0 -29
- data/lib/lookbook_visual_tester/screenshot_taker.rb +0 -118
- data/lib/lookbook_visual_tester/session_manager.rb +0 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d94b40b51271e7c94f1107872615622267d87fea8a4daefd0e3454b4b768f9f1
|
|
4
|
+
data.tar.gz: f7768f6d78d43b0e42b04cfca1ef4d23e41b932fe1d0005c53e580206a261ee3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 00ed31dbc76cc7baf465ce2875416862f9e4772e114c015798944fa0a1aef81d461cad7dd27456fbed685c1d9bd2454cef1c073cb082d913bc18c986d5493a83
|
|
7
|
+
data.tar.gz: 2b5a9a9f81b96eef19e3b0e1cf3ff4f49b3d6d9e26216650f31a1c75c4ddb7e966af4785de2323761df15dbb928cdb271a394068b77f1667819c521cd57f7372
|
data/.env.example
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# RubyGems release credentials. Copy to .env and fill in.
|
|
2
|
+
# Get an API key at: https://rubygems.org/profile/api_keys
|
|
3
|
+
# For a release-only key, enable the "Push rubygem" scope (and MFA if your
|
|
4
|
+
# account requires it). Keep this file private — never commit the real .env.
|
|
5
|
+
#
|
|
6
|
+
# cp .env.example .env
|
|
7
|
+
# # edit .env, then: rake release:gem
|
|
8
|
+
|
|
9
|
+
RUBYGEMS_API_KEY=
|
|
10
|
+
|
|
11
|
+
# Optional: if your account has MFA enabled for API access, set the current
|
|
12
|
+
# one-time code here (or pass it at the prompt via `rake release:otp`).
|
|
13
|
+
# GEM_HOST_OTP_CODE=
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## [0.7.0] - 2026-08-09
|
|
3
|
+
|
|
4
|
+
### Removed
|
|
5
|
+
- `cuprite` runtime dependency; legacy `LookbookVisualTester::SessionManager`, `CapybaraSetup`, `ScreenshotTaker`, and `BaselineManager` classes.
|
|
6
|
+
- ImageMagick `convert` and `compare` shell calls from the visual regression path.
|
|
7
|
+
- Hard-coded Devise/Warden/Pundit auth mocking inside the gem.
|
|
8
|
+
- Lookbook 1.x (`examples`) fallback — only Lookbook 2.x (`scenarios`) is supported.
|
|
9
|
+
- Global `$stdout` mutation in rake tasks.
|
|
10
|
+
- Version-fragile `check_preview_controller_config` introspection in `PreviewChecker`.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Pure-Ruby `LookbookVisualTester::ImageTrimmer` (ChunkyPNG) — no ImageMagick needed to trim screenshots.
|
|
14
|
+
- `config.preview_checker_setup` host hook for providing auth/helpers during deep checks.
|
|
15
|
+
- `LookbookVisualTester::ServerTestRunner` and `rake lookbook:server_and_test` for unattended agent/CI runs (process-group cleanup, log capture, configurable timeout).
|
|
16
|
+
- `Runner#initialize(..., output:)` — injectable output stream for thread-safe/quiet runs.
|
|
17
|
+
- `LookbookVisualTester::BrowserDiscovery` plus `config.browser_path` / `LOOKBOOK_BROWSER_PATH` to resolve a real Chrome binary, avoiding PATH-resolved wrapper scripts that break headless mode.
|
|
18
|
+
- `config.browser_options` (defaults to `{ "headless" => "new" }`), `config.browser_timeout`, and `config.process_timeout` for robust modern-Chrome launches.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- `copy_to_clipboard` now defaults to `false` (opt in to `xclip`).
|
|
22
|
+
- `automatic_run` is parsed as a boolean from the `LOOKBOOK_AUTOMATIC_RUN` env var.
|
|
23
|
+
- The Railtie `Lookbook.after_change` auto-run hook now drives the Ferrum `Runner` instead of the deleted Capybara `ScreenshotTaker`.
|
|
24
|
+
- `Runner#run_scenario` decomposed into focused private methods; the concurrent path stores its driver per-thread.
|
|
25
|
+
- `lookbook:approve` matches namespaced previews by exact base name or `_suffix`, so approving `ui/button/default` no longer also approves `ui_button_defaultmobile`.
|
|
26
|
+
- Ferrum dependency bumped to `>= 0.16` and launches with `--headless=new`, fixing "Multiple targets are not supported in headless mode" on modern Chrome builds.
|
|
27
|
+
|
|
2
28
|
## [0.6.0] - 2026-01-12
|
|
3
29
|
|
|
4
30
|
### Fixed
|
data/README.md
CHANGED
|
@@ -12,19 +12,16 @@ A powerful visual regression testing tool for [ViewComponent](https://viewcompon
|
|
|
12
12
|
- **Intelligent Diffing**: High-quality image comparison using `chunky_png`.
|
|
13
13
|
- **Human-Friendly Aesthetics**: Context is rendered with a light blue tint to make red highlights of differences pop.
|
|
14
14
|
- **Robust Capture**: Automatically disables animations, waits for network idle, and allows masking/cropping.
|
|
15
|
-
- **Lookbook Support**: Compatible with
|
|
15
|
+
- **Lookbook Support**: Compatible with Lookbook 2.x (`scenarios`).
|
|
16
16
|
- **Internal Test Harness**: Includes a dummy Rails app for self-contained testing and development.
|
|
17
17
|
|
|
18
18
|
## Installation
|
|
19
19
|
|
|
20
20
|
### System Dependencies
|
|
21
21
|
|
|
22
|
-
The gem
|
|
22
|
+
The gem uses [Ferrum](https://github.com/rubycdp/ferrum) (Chrome) and [ChunkyPNG](https://github.com/wvanbergen/chunky_png) for image processing. You need a Chrome-compatible browser installed locally. **No ImageMagick or `xclip` required.**
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
sudo apt-get install imagemagick xclip
|
|
27
|
-
```
|
|
24
|
+
Clipboard support via `xclip` is optional and opt-in (`config.copy_to_clipboard = true`).
|
|
28
25
|
|
|
29
26
|
### Gem Installation
|
|
30
27
|
|
|
@@ -46,12 +43,16 @@ You can configure the tester in a Rails initializer:
|
|
|
46
43
|
|
|
47
44
|
```ruby
|
|
48
45
|
LookbookVisualTester.configure do |config|
|
|
49
|
-
config.lookbook_host = "http://localhost:
|
|
46
|
+
config.lookbook_host = "http://localhost:5000" # Where your rails app is running
|
|
50
47
|
config.base_path = "coverage/screenshots" # Root for screenshots
|
|
51
|
-
config.copy_to_clipboard =
|
|
48
|
+
config.copy_to_clipboard = false # Default: off; opt in to xclip
|
|
52
49
|
config.threads = 4 # Number of parallel threads (default: 4)
|
|
53
50
|
config.wait_time = 0.5 # Optional: Wait time (seconds) before screenshot (fixes blank screens)
|
|
54
|
-
config.tolerance = 0.
|
|
51
|
+
config.tolerance = 0.0 # Optional: Mismatch tolerance (0.0 to 1.0) to ignore minor rendering differences
|
|
52
|
+
config.preview_checker_setup = -> {
|
|
53
|
+
# Provide auth/helpers for deep checks, e.g.:
|
|
54
|
+
# Current.user = LookbookFixtures.demo_user
|
|
55
|
+
}
|
|
55
56
|
end
|
|
56
57
|
```
|
|
57
58
|
|
|
@@ -83,6 +84,14 @@ Runs all Lookbook previews, generates a terminal summary, and creates an HTML re
|
|
|
83
84
|
bundle exec rake lookbook:test
|
|
84
85
|
```
|
|
85
86
|
|
|
87
|
+
#### Start Server, Test, Stop (for agents/CI)
|
|
88
|
+
Starts Rails, waits for Lookbook to be reachable, runs `lookbook:test`, and stops the server.
|
|
89
|
+
```bash
|
|
90
|
+
bundle exec rake lookbook:server_and_test
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Set `LOOKBOOK_SERVER_TIMEOUT` (seconds) and optional `LOOKBOOK_SERVER_LOG` (path to capture server output) as needed.
|
|
94
|
+
|
|
86
95
|
#### Test a Specific Preview
|
|
87
96
|
Filter previews by name or label.
|
|
88
97
|
```bash
|
data/Rakefile
CHANGED
|
@@ -22,4 +22,57 @@ namespace :release do
|
|
|
22
22
|
ENV['GEM_HOST_OTP_CODE'] = otp
|
|
23
23
|
Rake::Task['release'].invoke
|
|
24
24
|
end
|
|
25
|
+
|
|
26
|
+
desc 'Build the gem and push it to RubyGems (reads .env / RUBYGEMS_API_KEY)'
|
|
27
|
+
task :gem do
|
|
28
|
+
require 'fileutils'
|
|
29
|
+
load_dotenv
|
|
30
|
+
|
|
31
|
+
api_key = ENV['RUBYGEMS_API_KEY'] || ENV['GEM_HOST_API_KEY']
|
|
32
|
+
unless api_key
|
|
33
|
+
abort <<~MSG
|
|
34
|
+
Missing RubyGems API key.
|
|
35
|
+
Set RUBYGEMS_API_KEY (or GEM_HOST_API_KEY) in your environment or .env:
|
|
36
|
+
https://rubygems.org/profile/api_keys (enable MFA scopes as needed)
|
|
37
|
+
Then run: rake release:gem
|
|
38
|
+
MSG
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
write_credentials(api_key)
|
|
42
|
+
Rake::Task['build'].invoke
|
|
43
|
+
|
|
44
|
+
gem_path = Dir.glob('pkg/*.gem').max_by { |f| File.mtime(f) }
|
|
45
|
+
push_cmd = ['gem', 'push', gem_path]
|
|
46
|
+
push_cmd += ['--otp', ENV['GEM_HOST_OTP_CODE']] if ENV['GEM_HOST_OTP_CODE']
|
|
47
|
+
sh(*push_cmd)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def load_dotenv
|
|
51
|
+
path = File.expand_path('.env', Dir.pwd)
|
|
52
|
+
return unless File.file?(path)
|
|
53
|
+
File.readlines(path).each do |line|
|
|
54
|
+
line = line.strip
|
|
55
|
+
next if line.empty? || line.start_with?('#')
|
|
56
|
+
key, val = line.split('=', 2)
|
|
57
|
+
next unless key && val
|
|
58
|
+
ENV[key] = val.delete_suffix("\n").strip unless ENV.key?(key)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def write_credentials(api_key)
|
|
63
|
+
creds_path = File.expand_path('~/.gem/credentials')
|
|
64
|
+
creds = if File.file?(creds_path)
|
|
65
|
+
File.read(creds_path)
|
|
66
|
+
else
|
|
67
|
+
''
|
|
68
|
+
end
|
|
69
|
+
updated = if creds =~ /^:rubygems_api_key: /
|
|
70
|
+
creds.gsub(/^:rubygems_api_key: .*/, ":rubygems_api_key: #{api_key}")
|
|
71
|
+
else
|
|
72
|
+
creds + ":rubygems_api_key: #{api_key}\n"
|
|
73
|
+
end
|
|
74
|
+
FileUtils.mkdir_p(File.dirname(creds_path))
|
|
75
|
+
File.write(creds_path, updated)
|
|
76
|
+
FileUtils.chmod(0o600, creds_path)
|
|
77
|
+
end
|
|
25
78
|
end
|