effective_test_bot 1.7.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 +4 -4
- data/lib/effective_test_bot/version.rb +1 -1
- data/test/support/effective_test_bot_form_helper.rb +33 -10
- 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: 914a9df1a597575ab9150aeed63569eb8d76066822f8cdb746a7204f1235d5fe
|
4
|
+
data.tar.gz: 240e22997753bf272671a9ceb8709b863052d3039f55b84fe673cdc7b029f2dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62624653851827706582229b697e9cfeb7644e3a11372c832432c96acccd1de929ef6dd676b023c540c004d376b4cceb08d936f2bfcd2631a4e0fac5a04e3cdf
|
7
|
+
data.tar.gz: 5054abd3cfe3d42acca6b467349365d41221afe0381112939839e6847725d27ad905b1a44b1ef9c312d86acffe427521ad0c827a003ac943476bdbd2847b6a0e
|
@@ -19,17 +19,24 @@ 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
|
|
31
|
-
# Add a
|
32
|
-
|
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
|
33
40
|
|
34
41
|
before_path = page.current_path
|
35
42
|
before_path = 'ignore' unless assert_path_changed
|
@@ -42,10 +49,23 @@ module EffectiveTestBotFormHelper
|
|
42
49
|
|
43
50
|
assert_no_assigns_errors unless test_bot_skip?(:no_assigns_errors)
|
44
51
|
|
45
|
-
# Make sure the page has fully loaded afer submission
|
46
|
-
assert_no_selector('body.effective-test-bot-submitting-form', wait: Capybara.default_max_wait_time * 10)
|
47
52
|
assert_no_current_path(before_path.to_s, wait: Capybara.default_max_wait_time * 10)
|
48
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
|
+
|
49
69
|
assert_no_exceptions unless test_bot_skip?(:exceptions)
|
50
70
|
assert_authorization unless test_bot_skip?(:authorization)
|
51
71
|
assert_page_status unless test_bot_skip?(:page_status)
|
@@ -193,11 +213,14 @@ module EffectiveTestBotFormHelper
|
|
193
213
|
elsif submit['data-confirm']
|
194
214
|
page.accept_confirm { submit.click }
|
195
215
|
else
|
196
|
-
|
216
|
+
begin
|
217
|
+
submit.click
|
218
|
+
rescue => e
|
219
|
+
submit.click
|
220
|
+
end
|
197
221
|
end
|
198
222
|
|
199
|
-
synchronize
|
200
|
-
|
223
|
+
synchronize! if synchronize
|
201
224
|
save_test_bot_screenshot if EffectiveTestBot.screenshots?
|
202
225
|
|
203
226
|
true
|