effective_test_bot 1.6.0 → 1.7.1

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: a55f62eb834bfd80ba7a0f1daeada6083104044368d5e8c23e018451ba9e774e
4
- data.tar.gz: a0f06bbc4ffd9e9f10a7efc69ee950cc64080174a00691031e1c16f1bfa0d542
3
+ metadata.gz: 914a9df1a597575ab9150aeed63569eb8d76066822f8cdb746a7204f1235d5fe
4
+ data.tar.gz: 240e22997753bf272671a9ceb8709b863052d3039f55b84fe673cdc7b029f2dc
5
5
  SHA512:
6
- metadata.gz: 56946f3a358665ba2bb7bfed8a7e40ddcb64209eb251b0911fe8f2a53f9752adb5c9c5e1c5176ba0afaf0484f84be09d7bc1120a6c7b591d4f5400263e14843e
7
- data.tar.gz: 7fecd67c89b0081ca0615ab41032b1dee34ccbbee435c9988a3a5092a1843e38713efb0c5dc363b62ca62df9f0c2e59a71b066001f131cedf8c597e49f0604be
6
+ metadata.gz: 62624653851827706582229b697e9cfeb7644e3a11372c832432c96acccd1de929ef6dd676b023c540c004d376b4cceb08d936f2bfcd2631a4e0fac5a04e3cdf
7
+ data.tar.gz: 5054abd3cfe3d42acca6b467349365d41221afe0381112939839e6847725d27ad905b1a44b1ef9c312d86acffe427521ad0c827a003ac943476bdbd2847b6a0e
@@ -1,3 +1,3 @@
1
1
  module EffectiveTestBot
2
- VERSION = '1.6.0'.freeze
2
+ VERSION = '1.7.1'.freeze
3
3
  end
@@ -19,15 +19,25 @@ module EffectiveTestBotFormHelper
19
19
  true
20
20
  end
21
21
 
22
- def submit_page(label = nil, last: false, assert_path_changed: true, debug: false)
23
- submit_form(label, last: last, assert_path_changed: assert_path_changed, debug: debug)
22
+ def submit_page(label = nil, last: false, assert_path_changed: true, wait: true, debug: false)
23
+ submit_form(label, last: last, assert_path_changed: assert_path_changed, wait: wait, debug: debug)
24
+ end
25
+
26
+ def submit_ajax_form(label = nil, last: false, assert_path_changed: false, wait: false, debug: false)
27
+ submit_form(label, last: last, assert_path_changed: assert_path_changed, wait: wait, debug: debug)
24
28
  end
25
29
 
26
30
  # This submits the form, while checking for html5 form validation errors and unpermitted params
27
- def submit_form(label = nil, last: false, assert_path_changed: false, debug: false)
31
+ def submit_form(label = nil, last: false, assert_path_changed: false, wait: true, debug: false)
28
32
  assert_no_html5_form_validation_errors unless test_bot_skip?(:no_html5_form_validation_errors)
29
33
  assert_jquery_ujs_disable_with(label) unless test_bot_skip?(:jquery_ujs_disable_with)
30
34
 
35
+ # Add a div to track form submission
36
+ if wait
37
+ page.execute_script("$('body').prepend($('<div id=\"effective-test-bot-submitting-form\"></div>'));")
38
+ page.assert_selector(:xpath, '//div[@id="effective-test-bot-submitting-form"]')
39
+ end
40
+
31
41
  before_path = page.current_path
32
42
  before_path = 'ignore' unless assert_path_changed
33
43
 
@@ -39,9 +49,23 @@ module EffectiveTestBotFormHelper
39
49
 
40
50
  assert_no_assigns_errors unless test_bot_skip?(:no_assigns_errors)
41
51
 
42
- # This is a blocking selector that will wait until the page has changed url
43
52
  assert_no_current_path(before_path.to_s, wait: Capybara.default_max_wait_time * 10)
44
53
 
54
+ # Wait for form-submitting div to disappear via JS (not Capybara element)
55
+ if wait
56
+ begin
57
+ Timeout.timeout(Capybara.default_max_wait_time * 10) do
58
+ loop do
59
+ gone = page.evaluate_script("document.querySelector('#effective-test-bot-submitting-form') === null")
60
+ break if gone
61
+ sleep 0.1
62
+ end
63
+ end
64
+ rescue Timeout::Error
65
+ raise Timeout::Error, "Form submission did not disappear after #{Capybara.default_max_wait_time * 10} seconds. The form submission may have stalled or failed."
66
+ end
67
+ end
68
+
45
69
  assert_no_exceptions unless test_bot_skip?(:exceptions)
46
70
  assert_authorization unless test_bot_skip?(:authorization)
47
71
  assert_page_status unless test_bot_skip?(:page_status)
@@ -189,11 +213,14 @@ module EffectiveTestBotFormHelper
189
213
  elsif submit['data-confirm']
190
214
  page.accept_confirm { submit.click }
191
215
  else
192
- submit.click
216
+ begin
217
+ submit.click
218
+ rescue => e
219
+ submit.click
220
+ end
193
221
  end
194
222
 
195
- synchronize ? synchronize! : sleep(2)
196
-
223
+ synchronize! if synchronize
197
224
  save_test_bot_screenshot if EffectiveTestBot.screenshots?
198
225
 
199
226
  true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_test_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-15 00:00:00.000000000 Z
11
+ date: 2025-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails