capybara-lockstep 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ece5e0daeb6883b02791ed06f6ff2afca446e5aa5635f22d3ec5b94d0e96aa7
4
- data.tar.gz: 5e4d53a8c59f71071aa48fee8ec87fa62e5c189e026b5cac563fd9427a082c59
3
+ metadata.gz: 271ed22154f61a70a3961eb2bd2a8a7d29430dfb37107b9f1176257e8efab320
4
+ data.tar.gz: 6ba0d7a5c7e8bff779ee2a9ac2d6d32829374041dff41d7bddd9cbd19627a468
5
5
  SHA512:
6
- metadata.gz: 7e68bf91ab8b5ecf91b145159697e7990dbbbb3a5497955d50d91ea83d802c50195f803ae1fd029b2b76dc18b407bd1995b03aa292e30873cd35f8746dfa509e
7
- data.tar.gz: 8fb8d9b19fc47b5769208d36125b6cc2fb40375a8d5b46216ec318a3fd8459ca26f6bf22f352efcf350b7d7cbfe89f7bb866633fb4e096812b7d31513d4c7bae
6
+ metadata.gz: 24f098f75fc9093065cf4210eed7fab3b8f1ea69d49d6e328f195f92affe41c262fa92daecbf1ee8247dba8bcad1d3d5c0941766bd3889416be6aedf79f3e354
7
+ data.tar.gz: ea3debf0f2e4178dbc200c84a98aae87a614914de889769d10ed1cc2e311f83e93de460e2b1a4c163b756dc331838164bfe7ae8f77f676833df93a984a2fda49
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file.
2
2
 
3
3
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
4
4
 
5
+ ## 1.1.1 - 2022-03-16
6
+
7
+ - Activate rubygems MFA
8
+
5
9
  ## 1.1.0
6
10
 
7
11
  - Stop handling of `[data-initializing]` attribute. Apps that have late initialization after the `load` event can just use `CapybaraLockstep.startWork()`.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capybara-lockstep (1.1.0)
4
+ capybara-lockstep (1.1.1)
5
5
  activesupport (>= 3.2)
6
6
  capybara (>= 2.0)
7
7
  ruby2_keywords
data/README.md CHANGED
@@ -58,11 +58,17 @@ How capybara-lockstep helps
58
58
 
59
59
  capybara-lockstep waits until the browser is idle before moving on to the next Capybara command. This greatly relieves the pressure on [Capybara's retry logic](https://github.com/teamcapybara/capybara#asynchronous-javascript-ajax-and-friends).
60
60
 
61
- Before Capybara simulates a user interaction (clicking, typing, etc.) or before it visits a new URL:
61
+ capybara-lockstep synchronizes before:
62
62
 
63
- - capybara-lockstep waits for all document resources to load (images, CSS, fonts, frames).
64
- - capybara-lockstep waits for any AJAX requests to finish.
65
- - capybara-lockstep waits for client-side JavaScript to render or hydrate DOM elements.
63
+ - Capybara simulates a user interaction (clicking, typing, etc.)
64
+ - Capybara visits a new URL
65
+ - Capybara executes JavaScript
66
+
67
+ When capybara-lockstep synchronizes it will:
68
+
69
+ - wait for all document resources to load (images, CSS, fonts, frames).
70
+ - wait for client-side JavaScript to render or hydrate DOM elements.
71
+ - wait for any pending AJAX requests to finish and their callbacks to be called.
66
72
  - capybara-lockstep waits for dynamically inserted `<script>`s to load (e.g. from [dynamic imports](https://webpack.js.org/guides/code-splitting/#dynamic-imports) or Analytics snippets).
67
73
  - capybara-lockstep waits for dynamically inserted `<img>` or `<iframe>` elements to load.
68
74
 
@@ -111,7 +117,7 @@ capybara-lockstep requires a JavaScript snippet to be embedded by the applicatio
111
117
  **If you're using Rails** you can use the `capybara_lockstep` helper to insert the snippet into your application layouts:
112
118
 
113
119
  ```erb
114
- <%= capybara_lockstep if Rails.env.test? %>
120
+ <%= capybara_lockstep if defined?(Capybara::Lockstep) %>
115
121
  ```
116
122
 
117
123
  Ideally the snippet should be included in the `<head>` before any other `<script>` tags.
@@ -146,22 +152,24 @@ Note that you may see some failures from tests with wrong assertions, which prev
146
152
 
147
153
  ## Signaling asynchronous work
148
154
 
149
- By default capybara-lockstep blocks all async work that
155
+ By default capybara-lockstep waits until resources have loaded, AJAX requests have finished and their callbacks have been called.
150
156
 
151
- If for some reason you want capybara-lockstep to consider additional asynchronous work as "busy", you can do so:
157
+ You can configure capybara-lockstep to wait for other async work that does not involve the network. Let's say we have an animation that fades in a new element over 2 seconds. The following will prevent Capybara from observing the page while the animation is running:
152
158
 
153
159
  ```js
154
- CapybaraLockstep.startWork('Eject warp core')
155
- doAsynchronousWork().then(function() {
156
- CapybaraLockstep.stopWork('Eject warp core')
157
- })
160
+ async function fadeIn(element) {
161
+ CapybaraLockstep.startWork('Animation')
162
+ startAnimation(element, 'fade-in')
163
+ await waitForAnimationEnd(element)
164
+ CapybaraLockstep.stopWork('Animation')
165
+ }
158
166
  ```
159
167
 
160
168
  The string argument is used for logging (when logging is enabled). It does **not** need to be unique per job. In this case you should see messages like this in your browser's JavaScript console:
161
169
 
162
170
  ```text
163
- [capybara-lockstep] Started work: Eject warp core [1 jobs]
164
- [capybara-lockstep] Finished work: Eject warp core [0 jobs]
171
+ [capybara-lockstep] Started work: Animation [1 jobs]
172
+ [capybara-lockstep] Finished work: Animation [0 jobs]
165
173
  ```
166
174
 
167
175
  You may omit the string argument, in which case nothing will be logged, but the work will still be tracked.
@@ -177,6 +185,12 @@ if (window.CapybaraLockstep) {
177
185
  }
178
186
  ```
179
187
 
188
+ If you can use ES6 you may also use [optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) to only call a function if `window.CapybaraLockstep` is defined:
189
+
190
+ ```js
191
+ window.CapybaraLockstep?.startWork('Work')
192
+ ```
193
+
180
194
 
181
195
  ## Performance impact
182
196
 
@@ -306,25 +320,29 @@ Capybara::Lockstep.synchronize # will not synchronize
306
320
 
307
321
  ## Handling legacy promises
308
322
 
309
- Legacy promise implementations (like jQuery's `$.Deferred` and AngularJS' `$q`) work using tasks instead of microtasks. Their AJAX implementations (like `$.ajax()` and `$http`) use these promises to signal that a request is done.
323
+ Legacy promise implementations (like jQuery's `$.Deferred` and AngularJS' `$q`) work using [tasks instead of microtasks](https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/). Their AJAX implementations (like `$.ajax()` and `$http`) use task-based promises to signal that a request is done.
310
324
 
311
325
  This means there is a time window in which all AJAX requests have finished, but their callbacks have not yet run:
312
326
 
313
327
  ```js
314
- $.ajax('/foo').then(function() {
328
+ $http.get('/foo').then(function() {
315
329
  // This callback runs one task after the response was received
316
330
  })
317
331
  ```
318
332
 
319
- It is theoretically possible that your test will observe the browser in that window, and expect content that has not been rendered yet. This will usually be mitigated by Capybara's retry logic. **If** you think that this is an issue for your test suite, you can configure capybara-headless to wait additional tasks before it considers the browser to be idle:
333
+ It is theoretically possible that your test will observe the browser in that window, and expect content that has not been rendered yet. Affected code must call `then()` on a task-based promise **or** use `setTimeout()` to push work into the next task.
320
334
 
321
- ```js
322
- Capybara:Lockstep.wait_tasks = 1
335
+ Any issues caused by this will usually be mitigated by Capybara's retry logic. **If** you think that this is an issue for your test suite, you can configure capybara-headless to wait additional tasks before it considers the browser to be idle:
336
+
337
+ ```ruby
338
+ Capybara::Lockstep.wait_tasks = 1
323
339
  ```
324
340
 
325
- If you see longer `then()` chains in your code, you may need to configure a higher number of tasks to wait.
341
+ If you see longer chains of `then()` or nested `setTimeout()` calls in your code, you may need to configure a higher number of tasks to wait.
342
+
343
+ Waiting additional tasks will have a negative performance impact on your test suite.
326
344
 
327
- This will have a negative performance impact on your test suite.
345
+ > **Note:** When capybara-lockstep detects jQuery on the page, it will automatically patch [`$.ajax()`](https://api.jquery.com/jQuery.ajax/) to wait an additional task after the response was received. If your only concern is callbacks to `$.ajax()` you do not need so set `Capybara::Lockstep.wait_tasks`.
328
346
 
329
347
 
330
348
  ## Contributing
@@ -14,6 +14,10 @@ Gem::Specification.new do |spec|
14
14
  spec.metadata["homepage_uri"] = spec.homepage
15
15
  spec.metadata["source_code_uri"] = spec.homepage
16
16
 
17
+ spec.metadata["bug_tracker_uri"] = "https://github.com/makandra/capybara-lockstep/issues"
18
+ spec.metadata["changelog_uri"] = "https://github.com/makandra/capybara-lockstep/blob/master/CHANGELOG.md"
19
+ spec.metadata["rubygems_mfa_required"] = 'true'
20
+
17
21
  # Specify which files should be added to the gem when it is released.
18
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
23
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module Lockstep
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-lockstep
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-08 00:00:00.000000000 Z
11
+ date: 2022-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -101,6 +101,9 @@ licenses:
101
101
  metadata:
102
102
  homepage_uri: https://github.com/makandra/capybara-lockstep
103
103
  source_code_uri: https://github.com/makandra/capybara-lockstep
104
+ bug_tracker_uri: https://github.com/makandra/capybara-lockstep/issues
105
+ changelog_uri: https://github.com/makandra/capybara-lockstep/blob/master/CHANGELOG.md
106
+ rubygems_mfa_required: 'true'
104
107
  post_install_message:
105
108
  rdoc_options: []
106
109
  require_paths:
@@ -116,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
119
  - !ruby/object:Gem::Version
117
120
  version: '0'
118
121
  requirements: []
119
- rubygems_version: 3.2.6
122
+ rubygems_version: 3.1.4
120
123
  signing_key:
121
124
  specification_version: 4
122
125
  summary: Synchronize Capybara commands with client-side JavaScript and AJAX requests