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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c4545f0de7b20b1fbfcf71a08ed644553d5445001370ff3d59a4d8c9fc9c88f
4
- data.tar.gz: a3aa8204023cab2f89f1799f0fbf7aee7fe6965bbbe00d1944e75c27010dc158
3
+ metadata.gz: ad9e5b4eaf1c9021974e3b98572e5df40de5cd7d9a76a4596d1d1498a5b1ba6e
4
+ data.tar.gz: d43fd39b24c6501f2e22f89c63e83df203da15cc111b4812b520727fa26280e7
5
5
  SHA512:
6
- metadata.gz: 4aed98cd98f7137740c85d5b9d994adbec0ecd2f9c06c972c7caacc5b4087e7450710855e267d507651ceb1f5d4f4667bfb1bdf8d0a9d0f037c5d39f27bcadb4
7
- data.tar.gz: f801d661ab48e2d980fc39aaa7f8d9614a79a6c6b3795c7335f33263658a872d97894c8e7ad76fabf72bd51767d2dfbbc17ad45c056bd86661c4c425e8d1d8b6
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 — nothing re-checks it.
66
- sleep(interval) unless attempt == max_attempts - 1
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Capybara
4
4
  module Storyboard
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-storyboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - aki