effective_test_bot 1.1.27 → 1.1.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/effective_test_bot_controller_helper.rb +4 -2
- data/lib/effective_test_bot.rb +5 -1
- data/lib/effective_test_bot/version.rb +1 -1
- data/test/support/effective_test_bot_form_faker.rb +3 -0
- data/test/support/effective_test_bot_form_filler.rb +32 -8
- data/test/support/effective_test_bot_form_helper.rb +2 -2
- data/test/support/effective_test_bot_test_helper.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48c18bd23b31a9fbc1ea45a86275fffe86d1ed4178d6b639fab958de45092b0a
|
4
|
+
data.tar.gz: 184a735e80bfa2e483236fae17f04d62be01e3e5ca0303eb7c5effcce59b0245
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a28cb45fb1f5b3be46bb380aba5ade362d0376d8495a0b10467cac6a0cb728c27f68a0066cd45df94b3757f630be3853f71da7c7c6497094f23c2c385af0104f
|
7
|
+
data.tar.gz: b7bc9f3512a1fcadcc7170b5a08b2bae79fe948091bffe84f03991f60dbf1321d615b30f3759d344c94e8184482a17104722ad555be5b751ae7d7352121c8e73
|
@@ -5,12 +5,14 @@ module EffectiveTestBotControllerHelper
|
|
5
5
|
def assign_test_bot_payload(payload = {})
|
6
6
|
payload.merge!({ response_code: response.code, assigns: test_bot_view_assigns, flash: flash.to_hash })
|
7
7
|
|
8
|
-
|
8
|
+
media_type = (response.respond_to?(:media_type) ? response.media_type : response.content_type).to_s
|
9
|
+
|
10
|
+
if media_type.start_with?('text/html') && response.body[BODY_TAG].present?
|
9
11
|
payload = view_context.content_tag(:script, build_payload_javascript(payload), id: 'test_bot_payload')
|
10
12
|
|
11
13
|
split = response.body.split(BODY_TAG)
|
12
14
|
response.body = "#{split.first}#{payload}#{BODY_TAG}#{split.last if split.size > 1}"
|
13
|
-
elsif
|
15
|
+
elsif media_type.start_with?('text/javascript') && response.body.present?
|
14
16
|
payload = build_payload_javascript(payload)
|
15
17
|
|
16
18
|
response.body = "#{response.body};#{payload}"
|
data/lib/effective_test_bot.rb
CHANGED
@@ -124,7 +124,11 @@ module EffectiveTestBot
|
|
124
124
|
return if EffectiveTestBot.passed_tests[name] == true
|
125
125
|
|
126
126
|
EffectiveTestBot.passed_tests[name] = true
|
127
|
-
|
127
|
+
|
128
|
+
# Make test pass directory
|
129
|
+
Dir.mkdir("#{Rails.root}/tmp") unless Dir.exist?("#{Rails.root}/tmp")
|
130
|
+
Dir.mkdir("#{Rails.root}/tmp/test_bot") unless Dir.exist?("#{Rails.root}/tmp/test_bot")
|
131
|
+
|
128
132
|
File.open(passed_tests_filename, 'a') { |file| file.puts(name) }
|
129
133
|
end
|
130
134
|
|
@@ -115,6 +115,8 @@ module EffectiveTestBotFormFiller
|
|
115
115
|
fill_input_file(field, value)
|
116
116
|
when 'input_submit', 'input_search', 'input_button'
|
117
117
|
skip_field_screenshot = true # Do nothing
|
118
|
+
when 'input_hidden'
|
119
|
+
fill_action_text_input(field, value)
|
118
120
|
else
|
119
121
|
raise "unsupported field type #{field_name}"
|
120
122
|
end
|
@@ -176,6 +178,15 @@ module EffectiveTestBotFormFiller
|
|
176
178
|
end
|
177
179
|
end
|
178
180
|
|
181
|
+
def fill_action_text_input(field, value)
|
182
|
+
return unless action_text_input?(field)
|
183
|
+
|
184
|
+
trix_id = field['id'].to_s.split('_trix_input_form').first
|
185
|
+
return unless trix_id.present?
|
186
|
+
|
187
|
+
try_script "document.querySelector(\"##{trix_id}\").editor.insertString(\"#{value}\")"
|
188
|
+
end
|
189
|
+
|
179
190
|
def fill_input_select(field, value)
|
180
191
|
if EffectiveTestBot.tour_mode_extreme? && select2_input?(field)
|
181
192
|
try_script "$('select##{field['id']}').select2('open')"
|
@@ -276,6 +287,10 @@ module EffectiveTestBotFormFiller
|
|
276
287
|
(field['class'].to_s.include?('ckeditor') || all("span[id='cke_#{field['id']}']", wait: false).present?)
|
277
288
|
end
|
278
289
|
|
290
|
+
def action_text_input?(field)
|
291
|
+
field.tag_name == 'input' && field['type'] == 'hidden' && field['id'].to_s.include?('trix_input_form')
|
292
|
+
end
|
293
|
+
|
279
294
|
def custom_control_input?(field) # Bootstrap 4 radios and checks
|
280
295
|
field['class'].to_s.include?('custom-control-input')
|
281
296
|
end
|
@@ -294,16 +309,25 @@ module EffectiveTestBotFormFiller
|
|
294
309
|
|
295
310
|
def skip_form_field?(field)
|
296
311
|
field.reload # Handle a field changing visibility/disabled state from previous form field manipulations
|
297
|
-
|
298
312
|
field_id = field['id'].to_s
|
299
313
|
|
300
|
-
field_id.start_with?('datatable_')
|
301
|
-
field_id.start_with?('filters_scope_')
|
302
|
-
field_id.start_with?('filters_') && field['name'].blank?
|
303
|
-
|
304
|
-
(
|
305
|
-
['true', true, 1].include?(field['data-test-bot-skip'])
|
306
|
-
|
314
|
+
return true if field_id.start_with?('datatable_')
|
315
|
+
return true if field_id.start_with?('filters_scope_')
|
316
|
+
return true if field_id.start_with?('filters_') && field['name'].blank?
|
317
|
+
return true if field['type'] == 'button'
|
318
|
+
return true if (field.disabled? rescue true) # Selenium::WebDriver::Error::StaleElementReferenceError: stale element reference: element is not attached to the page document
|
319
|
+
return true if ['true', true, 1].include?(field['data-test-bot-skip'])
|
320
|
+
return true if @test_bot_excluded_fields_xpath.present? && field.path.include?(@test_bot_excluded_fields_xpath)
|
321
|
+
|
322
|
+
if !field.visible?
|
323
|
+
return false if ckeditor_text_area?(field)
|
324
|
+
return false if custom_control_input?(field)
|
325
|
+
return false if file_input?(field)
|
326
|
+
return false if action_text_input?(field)
|
327
|
+
return true
|
328
|
+
end
|
329
|
+
|
330
|
+
false
|
307
331
|
end
|
308
332
|
|
309
333
|
def field_key(field)
|
@@ -106,7 +106,7 @@ module EffectiveTestBotFormHelper
|
|
106
106
|
# This kind of sucks, as we want to simulate mouse movements with the tour
|
107
107
|
# Instead we manually trigger submit buttons and use the data-disable-with to
|
108
108
|
# make the 'submit form' step look nice
|
109
|
-
def click_submit(label = nil, last: false, debug: false)
|
109
|
+
def click_submit(label = nil, last: false, synchronize: true, debug: false)
|
110
110
|
submit = find_submit(label, last: last)
|
111
111
|
|
112
112
|
if EffectiveTestBot.screenshots?
|
@@ -128,7 +128,7 @@ module EffectiveTestBotFormHelper
|
|
128
128
|
submit.click
|
129
129
|
end
|
130
130
|
|
131
|
-
synchronize!
|
131
|
+
synchronize ? synchronize! : sleep(2)
|
132
132
|
|
133
133
|
save_test_bot_screenshot if EffectiveTestBot.screenshots? && page.current_path.present?
|
134
134
|
|
@@ -73,7 +73,8 @@ module EffectiveTestBotTestHelper
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def effective_bootstrap_custom_data_confirm?
|
76
|
-
(page.evaluate_script('$.rails.effective_bootstrap_custom_data_confirm') rescue nil)
|
76
|
+
(page.evaluate_script('$.rails.effective_bootstrap_custom_data_confirm') rescue nil) ||
|
77
|
+
(page.evaluate_script('window.Rails.effective_bootstrap_custom_data_confirm') rescue nil)
|
77
78
|
end
|
78
79
|
|
79
80
|
# EffectiveTestBot includes an after_filter on ApplicationController to set an http header
|
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.1.
|
4
|
+
version: 1.1.32
|
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: 2020-
|
11
|
+
date: 2020-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
191
|
- !ruby/object:Gem::Version
|
192
192
|
version: '0'
|
193
193
|
requirements: []
|
194
|
-
rubygems_version: 3.1.
|
194
|
+
rubygems_version: 3.1.2
|
195
195
|
signing_key:
|
196
196
|
specification_version: 4
|
197
197
|
summary: A shared library of rails model & system tests that should pass in every
|