lookbook_visual_tester 0.5.6 → 0.5.7
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5198b58b3f8bffad2cb68f1bce804b1bce9d2ccc3e32513699f68a83e04fb054
|
|
4
|
+
data.tar.gz: bca7f0aa36413c702b5c65e3ed330ac18c4c05edeeeb36e5cb94b0ec1aaa4831
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7908ba3fb95002233392bc7b570bdf21f7bfd38f25c0206b0521f5fc89a8773173ea2689fbc1ddaca41b1e838d904118d47d4d3a2760dd829265e7e46d8148c9
|
|
7
|
+
data.tar.gz: ee266274b9ee9bfd9dd24c146bf6537618da8c10490cee78c8a667d072a8c1bb06e5a43d0ac402ca98131de425fe7e5df9ace5c9b015ca8830db35788940f8b6
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## [0.5.7] - 2026-01-06
|
|
3
|
+
|
|
4
|
+
### Fixed
|
|
5
|
+
- **Flaky Screenshots**: Added `wait_time` configuration to `LookbookVisualTester.config` to allow explicit waiting before screenshot capture. This resolves blank or layout-only screenshots in slower environments.
|
|
6
|
+
- **Robust Driver**: Updated `FerrumDriver` to include consistent network idle checks and support the new `wait_time` option.
|
|
7
|
+
|
|
2
8
|
## [0.5.6] - 2026-01-06
|
|
3
9
|
|
|
4
10
|
### Fixed
|
data/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
A powerful visual regression testing tool for [ViewComponent](https://viewcomponent.org/) via [Lookbook](https://lookbook.build/). It automates the process of capturing screenshots of your components, comparing them against baselines, and highlighting differences with human-friendly aesthetics.
|
|
6
6
|
|
|
7
|
+
*This tool has been tested "at home". If it doesn't work for you, feel free to open an issue. **It works on my machine!***
|
|
8
|
+
|
|
7
9
|
### Key Features
|
|
8
10
|
|
|
9
11
|
- **Automated Visual Regression**: Captures and compares screenshots of all Lookbook previews.
|
|
@@ -48,6 +50,7 @@ LookbookVisualTester.configure do |config|
|
|
|
48
50
|
config.base_path = "coverage/screenshots" # Root for screenshots
|
|
49
51
|
config.copy_to_clipboard = true # Enable xclip support
|
|
50
52
|
config.threads = 4 # Number of parallel threads (default: 4)
|
|
53
|
+
config.wait_time = 0.5 # Optional: Wait time (seconds) before screenshot (fixes blank screens)
|
|
51
54
|
end
|
|
52
55
|
```
|
|
53
56
|
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
module LookbookVisualTester
|
|
2
2
|
class Configuration
|
|
3
3
|
attr_reader :base_path
|
|
4
|
-
attr_accessor :lookbook_host,
|
|
5
|
-
:
|
|
6
|
-
:
|
|
7
|
-
:
|
|
8
|
-
:automatic_run,
|
|
9
|
-
:mask_selectors, :driver_adapter,
|
|
10
|
-
:preview_checker_setup,
|
|
11
|
-
:logger
|
|
4
|
+
attr_accessor :lookbook_host, :ui_comparison, :diff_dir, :baseline_dir, :current_dir,
|
|
5
|
+
:history_dir, :history_keep_last_n, :threads, :copy_to_clipboard,
|
|
6
|
+
:components_folder, :automatic_run, :mask_selectors, :driver_adapter,
|
|
7
|
+
:preview_checker_setup, :logger, :wait_time
|
|
12
8
|
|
|
13
9
|
DEFAULT_THREADS = 4
|
|
14
10
|
|
|
@@ -31,6 +27,7 @@ module LookbookVisualTester
|
|
|
31
27
|
@mask_selectors = []
|
|
32
28
|
@driver_adapter = :ferrum
|
|
33
29
|
@preview_checker_setup = nil
|
|
30
|
+
@wait_time = 0.5
|
|
34
31
|
@logger = if defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger
|
|
35
32
|
Rails.logger
|
|
36
33
|
else
|
|
@@ -53,22 +53,26 @@ module LookbookVisualTester
|
|
|
53
53
|
wait_for_network_idle
|
|
54
54
|
wait_for_fonts
|
|
55
55
|
wait_for_custom_selectors
|
|
56
|
+
# Explicit wait if configured, for robustness against "blank screenshot" issues
|
|
57
|
+
sleep(config.wait_time) if config.wait_time.positive?
|
|
56
58
|
end
|
|
57
59
|
|
|
58
60
|
def wait_for_fonts
|
|
59
|
-
@browser.execute(
|
|
61
|
+
@browser.execute('return document.fonts.ready')
|
|
60
62
|
end
|
|
61
63
|
|
|
62
|
-
def wait_for_network_idle
|
|
63
|
-
# Ferrum has built-in network idle waiting
|
|
64
|
+
def wait_for_network_idle
|
|
65
|
+
# Ferrum has built-in network idle waiting.
|
|
66
|
+
# We rely on default settings or explicit sleep for extra safety.
|
|
64
67
|
@browser.network.wait_for_idle
|
|
65
68
|
rescue Ferrum::TimeoutError
|
|
66
|
-
# Log warning but proceed
|
|
69
|
+
# Log warning but proceed - sometimes long polling or other scripts keep net active
|
|
70
|
+
config.logger.warn 'LookbookVisualTester: Network idle timeout. Proceeding with screenshot.'
|
|
67
71
|
end
|
|
68
72
|
|
|
69
73
|
def save_screenshot(path)
|
|
70
74
|
@browser.screenshot(path: path, full: true)
|
|
71
|
-
#
|
|
75
|
+
# NOTE: full: true captures the whole page.
|
|
72
76
|
# If we capture viewport only, we should remove full: true.
|
|
73
77
|
# Usually for visual testing full page is better unless specifically testing viewport.
|
|
74
78
|
end
|
|
@@ -86,7 +90,7 @@ module LookbookVisualTester
|
|
|
86
90
|
end
|
|
87
91
|
|
|
88
92
|
def disable_animations
|
|
89
|
-
css =
|
|
93
|
+
css = '* { transition: none !important; animation: none !important; caret-color: transparent !important; }'
|
|
90
94
|
inject_style(css)
|
|
91
95
|
end
|
|
92
96
|
|
|
@@ -95,15 +99,17 @@ module LookbookVisualTester
|
|
|
95
99
|
start = Time.now
|
|
96
100
|
until @browser.execute("return document.fonts.status === 'loaded'")
|
|
97
101
|
break if Time.now - start > 5
|
|
102
|
+
|
|
98
103
|
sleep 0.1
|
|
99
104
|
end
|
|
100
105
|
|
|
101
106
|
# Also check for images loading attributes if needed
|
|
102
107
|
# "check that no images have loading attributes active"
|
|
103
108
|
# Often checking complete property is enough
|
|
104
|
-
until @browser.execute(
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
until @browser.execute('return Array.from(document.images).every(i => i.complete)')
|
|
110
|
+
break if Time.now - start > 5
|
|
111
|
+
|
|
112
|
+
sleep 0.1
|
|
107
113
|
end
|
|
108
114
|
end
|
|
109
115
|
end
|