effective_test_bot 1.1.25 → 1.1.30

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: c93ee6cbc4a6f2d015c6862cc56cb1fbf1c0a56eab77931996bf1f59d771196b
4
- data.tar.gz: 27a906d8cc6eed02996b0d98297a0bd832af9f0f6199029eafb94bcc4eb8d26d
3
+ metadata.gz: 9dec06ddd30a8548521d86039448de854f1ba937f40799d0289e161b4e894131
4
+ data.tar.gz: bd45ec5a42567d3e11ee9aecdd3cc9359c8351c8f4c8ed21e844f9baeb3d05da
5
5
  SHA512:
6
- metadata.gz: 3243af9fc54f6f92a7e6a34f9690a97aac9b2c2b94b6deaf37bb2981a4bbadd26620900717e2de6ca88be90447c9558c944ac9dfd0e0944e7bcb440298fd2005
7
- data.tar.gz: 71476e8e08e018a8a4111daabd9c1025fa14003f1079a190b35f8487103b9bbfaaa9990793515b559404993a74bd0fa24fc6728c6294155a1900ad942464b03e
6
+ metadata.gz: d61ff64d42c6d0f95ce15ffb457307286e13ec36347b09c0c208241fb05ed3ca779140b44ad0af49143299f1135c48177a2137d442d5ffb815864359f642a13d
7
+ data.tar.gz: 3c86a02228efb83687c2b26d7daa878304616361d6ae123bc455b2329ffbc6fb6b53273fd19b1cea05b239d5c46c47ad2af9cfb39407bff1bdf74b3fb5de69e5
@@ -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
- if response.content_type.to_s.start_with?('text/html') && response.body[BODY_TAG].present?
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 response.content_type.to_s.start_with?('text/javascript') && response.body.present?
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}"
@@ -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
- Dir.mkdir(passed_tests_path) unless File.exist?(passed_tests_path)
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
 
@@ -13,9 +13,7 @@ module EffectiveTestBot
13
13
  include EffectiveTestBotScreenshotsHelper
14
14
  include EffectiveTestBotTestHelper
15
15
 
16
- class BasicObject
17
- include EffectiveTestBotMocks
18
- end
16
+ BasicObject.send :include, EffectiveTestBotMocks
19
17
 
20
18
  # test/test_botable/
21
19
  include BaseTest
@@ -1,3 +1,3 @@
1
1
  module EffectiveTestBot
2
- VERSION = '1.1.25'.freeze
2
+ VERSION = '1.1.30'.freeze
3
3
  end
@@ -123,6 +123,8 @@ module EffectiveTestBotAssertions
123
123
  error = page.driver.browser.manage.logs.get(:browser).first # headless_chrome
124
124
  rescue NotImplementedError
125
125
  return
126
+ rescue => e
127
+ return
126
128
  end
127
129
 
128
130
  if strict == false
@@ -126,6 +126,9 @@ module EffectiveTestBotFormFaker
126
126
  when 'textarea', 'textarea_textarea'
127
127
  Faker::Lorem.paragraph
128
128
 
129
+ when 'input_hidden'
130
+ Faker::Lorem.paragraph
131
+
129
132
  when 'input_submit', 'input_search', 'input_button'
130
133
  nil
131
134
 
@@ -71,7 +71,9 @@ module EffectiveTestBotFormFiller
71
71
  end
72
72
 
73
73
  # Fill all fields now
74
- fields = all('input,select,textarea', visible: false).reject { |field| seen[field_key(field)] }
74
+ fields = all('input,select,textarea', visible: false).reject do |field|
75
+ (seen[field_key(field)] rescue true)
76
+ end
75
77
 
76
78
  break unless fields.present?
77
79
 
@@ -113,6 +115,8 @@ module EffectiveTestBotFormFiller
113
115
  fill_input_file(field, value)
114
116
  when 'input_submit', 'input_search', 'input_button'
115
117
  skip_field_screenshot = true # Do nothing
118
+ when 'input_hidden'
119
+ fill_action_text_input(field, value)
116
120
  else
117
121
  raise "unsupported field type #{field_name}"
118
122
  end
@@ -174,6 +178,15 @@ module EffectiveTestBotFormFiller
174
178
  end
175
179
  end
176
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
+
177
190
  def fill_input_select(field, value)
178
191
  if EffectiveTestBot.tour_mode_extreme? && select2_input?(field)
179
192
  try_script "$('select##{field['id']}').select2('open')"
@@ -274,6 +287,10 @@ module EffectiveTestBotFormFiller
274
287
  (field['class'].to_s.include?('ckeditor') || all("span[id='cke_#{field['id']}']", wait: false).present?)
275
288
  end
276
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
+
277
294
  def custom_control_input?(field) # Bootstrap 4 radios and checks
278
295
  field['class'].to_s.include?('custom-control-input')
279
296
  end
@@ -292,16 +309,25 @@ module EffectiveTestBotFormFiller
292
309
 
293
310
  def skip_form_field?(field)
294
311
  field.reload # Handle a field changing visibility/disabled state from previous form field manipulations
295
-
296
312
  field_id = field['id'].to_s
297
313
 
298
- field_id.start_with?('datatable_') ||
299
- field_id.start_with?('filters_scope_') ||
300
- field_id.start_with?('filters_') && field['name'].blank? ||
301
- (field.disabled? rescue true) || # Selenium::WebDriver::Error::StaleElementReferenceError: stale element reference: element is not attached to the page document
302
- (!field.visible? && !ckeditor_text_area?(field) && !custom_control_input?(field) && !file_input?(field)) ||
303
- ['true', true, 1].include?(field['data-test-bot-skip']) ||
304
- (@test_bot_excluded_fields_xpath.present? && field.path.include?(@test_bot_excluded_fields_xpath))
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
305
331
  end
306
332
 
307
333
  def field_key(field)
@@ -8,7 +8,7 @@ module EffectiveTestBotScreenshotsHelper
8
8
 
9
9
  def save_test_bot_screenshot
10
10
  return unless EffectiveTestBot.gifs?
11
- return unless page.current_path.present?
11
+ return unless (page.current_path rescue false).present?
12
12
 
13
13
  page.save_screenshot("#{current_test_temp_path}/#{current_test_screenshot_id}.png")
14
14
  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.1.25
4
+ version: 1.1.30
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-09-15 00:00:00.000000000 Z
11
+ date: 2020-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails