capybara-storyboard 0.2.0 → 0.3.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/CHANGELOG.md +4 -0
- data/lib/capybara/storyboard/page_stability.rb +32 -2
- data/lib/capybara/storyboard/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ad9e5b4eaf1c9021974e3b98572e5df40de5cd7d9a76a4596d1d1498a5b1ba6e
|
|
4
|
+
data.tar.gz: d43fd39b24c6501f2e22f89c63e83df203da15cc111b4812b520727fa26280e7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83807f656992133cd59d9602f2a1574e9d018d69e63a69010b01dc28ba0bcc27de48d464fe10e36eb1e60ab914eae6b9725d226735b4b3266cf39c983c24d0ce
|
|
7
|
+
data.tar.gz: 513c4e0147ef78eee5a5e36c720ea428b8a8ee9ebbf885c31201438d3d12b8bdbc2bc495a3e0fd6e8c58c2458ba49fc7ddd3d8350f59d5ead1b5f9e019953afc
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.3.0] - 2026-07-23
|
|
4
|
+
|
|
5
|
+
- Fix `NoMethodError` / spurious "skipped after error" warnings when a page navigation happens between setup and a stability poll, by treating non-finite poll results (nil/NaN/Infinity) as "measurement lost" and re-arming the observer
|
|
6
|
+
|
|
3
7
|
## [0.2.0] - 2026-07-22
|
|
4
8
|
|
|
5
9
|
- Add `visual-regression-test` skill for AI-assisted before/after screenshot comparison
|
|
@@ -62,8 +62,15 @@ module Capybara
|
|
|
62
62
|
stable = stable?(result, interval)
|
|
63
63
|
break if stable
|
|
64
64
|
|
|
65
|
-
# No point sleeping after the final check —
|
|
66
|
-
|
|
65
|
+
# No point re-arming or sleeping after the final check — cleanup runs
|
|
66
|
+
# immediately after and nothing re-checks it.
|
|
67
|
+
next if attempt == max_attempts - 1
|
|
68
|
+
|
|
69
|
+
# The measurement was reset by a page navigation (non-numeric result);
|
|
70
|
+
# re-arm the observer with the configured excluded animations so the
|
|
71
|
+
# next poll can measure again.
|
|
72
|
+
setup(page, excluded_animations) unless measurable?(result)
|
|
73
|
+
sleep(interval)
|
|
67
74
|
end
|
|
68
75
|
|
|
69
76
|
# Unstable (or max_attempts was 0): the page is deemed good enough.
|
|
@@ -106,9 +113,32 @@ module Capybara
|
|
|
106
113
|
nil
|
|
107
114
|
end
|
|
108
115
|
|
|
116
|
+
# True when the poll returned real numbers to compare. A page navigation
|
|
117
|
+
# between setup and a poll swaps in a fresh document whose
|
|
118
|
+
# window._lastMutationTime is undefined, so Date.now() - undefined === NaN.
|
|
119
|
+
# Callers use this to decide whether to re-arm the observer (Ruby side) and
|
|
120
|
+
# whether the numeric comparison in #stable? is even meaningful.
|
|
121
|
+
def measurable?(result)
|
|
122
|
+
finite_number?(result['runningAnimations']) && finite_number?(result['timeSinceLastMutation'])
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# True only for a real, finite number. Guards against nil (Selenium
|
|
126
|
+
# serializes a navigation-reset NaN to JSON null) and against Float::NAN /
|
|
127
|
+
# Infinity (CDP drivers such as Cuprite/Ferrum decode the reset NaN back
|
|
128
|
+
# into a literal Float::NAN), both of which mean "the measurement was lost
|
|
129
|
+
# and must be re-armed".
|
|
130
|
+
def finite_number?(value)
|
|
131
|
+
value.is_a?(Numeric) && (!value.is_a?(Float) || value.finite?)
|
|
132
|
+
end
|
|
133
|
+
|
|
109
134
|
# evaluate_script returns string-keyed hashes on the real drivers; the
|
|
110
135
|
# DOM-quiet window is measured in ms, so compare against interval * 1000.
|
|
136
|
+
# A non-numeric result (e.g. the measurement was reset by a page
|
|
137
|
+
# navigation) is treated as "not stable yet", which also keeps this
|
|
138
|
+
# comparison free of NoMethodError regardless of what the driver hands back.
|
|
111
139
|
def stable?(result, interval)
|
|
140
|
+
return false unless measurable?(result)
|
|
141
|
+
|
|
112
142
|
result['runningAnimations'].zero? && result['timeSinceLastMutation'] >= (interval * 1000)
|
|
113
143
|
end
|
|
114
144
|
|