effective_test_bot 1.1.23 → 1.1.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/test_helper.rb +3 -0
- data/lib/effective_test_bot.rb +3 -3
- data/lib/effective_test_bot/dsl.rb +3 -0
- data/lib/effective_test_bot/engine.rb +4 -4
- data/lib/effective_test_bot/version.rb +1 -1
- data/test/support/effective_test_bot_assertions.rb +2 -0
- data/test/support/effective_test_bot_form_faker.rb +7 -10
- data/test/support/effective_test_bot_form_filler.rb +36 -9
- data/test/support/effective_test_bot_mocks.rb +31 -0
- data/test/support/effective_test_bot_screenshots_helper.rb +9 -9
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5590f0c1b7be5d9eae672f585d6171c64bc9a49a809b7deb63c3cb77c6d26180
|
4
|
+
data.tar.gz: bb8d8cea77300a83004d96d206a8f8ed8a11f96b7ddad4b71b71da7179f11f5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebe2ca7bff109d9d3a844e734ab1d29112e0c88aca0c9bc7d0efc3324fb2a7c04a3947d90bb160195379d24a9f828aa9bf2483d7f2b8d6744a2da058841023b8
|
7
|
+
data.tar.gz: '09d8abd2735e66d95ece47b509022cfed74372faaca8543d7c202eaa602407eb69528ed5dad2178ee5aff2bcc6bca54797897b81395cbf918f823c4c3d721cc4'
|
data/config/test_helper.rb
CHANGED
@@ -2,6 +2,7 @@ ENV['RAILS_ENV'] ||= 'test'
|
|
2
2
|
require_relative '../config/environment'
|
3
3
|
|
4
4
|
require 'rails/test_help'
|
5
|
+
require 'minitest/mock'
|
5
6
|
require 'minitest/spec'
|
6
7
|
require 'minitest/reporters'
|
7
8
|
require 'minitest/fail_fast' if EffectiveTestBot.fail_fast?
|
@@ -10,6 +11,8 @@ class ActiveSupport::TestCase
|
|
10
11
|
# Run tests in parallel with specified workers
|
11
12
|
# parallelize(workers: :number_of_processors) if respond_to?(:parallelize)
|
12
13
|
|
14
|
+
include EffectiveTestBot::DSL
|
15
|
+
|
13
16
|
fixtures :all # Loads all fixtures in test/fixtures/*.yml
|
14
17
|
extend Minitest::Spec::DSL # For the let syntax
|
15
18
|
end
|
data/lib/effective_test_bot.rb
CHANGED
@@ -66,7 +66,7 @@ module EffectiveTestBot
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def self.gifs?
|
69
|
-
image_processing_class.present?
|
69
|
+
screenshots? && image_processing_class.present?
|
70
70
|
end
|
71
71
|
|
72
72
|
def self.image_processing_class
|
@@ -97,7 +97,7 @@ module EffectiveTestBot
|
|
97
97
|
if ENV['TOUR'].present?
|
98
98
|
ENV['TOUR'].to_s != 'false'
|
99
99
|
else
|
100
|
-
|
100
|
+
gifs? && (tour_mode != false)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -106,7 +106,7 @@ module EffectiveTestBot
|
|
106
106
|
if ENV['TOUR'].present?
|
107
107
|
['extreme', 'debug'].include?(ENV['TOUR'].to_s.downcase)
|
108
108
|
else
|
109
|
-
|
109
|
+
gifs? && ['extreme', 'debug'].include?(tour_mode.to_s)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -3,6 +3,7 @@ module EffectiveTestBot
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
+
# test/support/
|
6
7
|
include EffectiveTestBotAssertions
|
7
8
|
include EffectiveTestBotFormFaker
|
8
9
|
include EffectiveTestBotFormFiller
|
@@ -12,6 +13,8 @@ module EffectiveTestBot
|
|
12
13
|
include EffectiveTestBotScreenshotsHelper
|
13
14
|
include EffectiveTestBotTestHelper
|
14
15
|
|
16
|
+
BasicObject.send :include, EffectiveTestBotMocks
|
17
|
+
|
15
18
|
# test/test_botable/
|
16
19
|
include BaseTest
|
17
20
|
include CrudTest
|
@@ -3,14 +3,14 @@ module EffectiveTestBot
|
|
3
3
|
engine_name 'effective_test_bot'
|
4
4
|
|
5
5
|
config.autoload_paths += Dir[
|
6
|
-
"#{config.root}/test/test_botable/",
|
7
|
-
"#{config.root}/test/concerns/",
|
6
|
+
"#{config.root}/test/test_botable/",
|
7
|
+
"#{config.root}/test/concerns/",
|
8
8
|
"#{config.root}/test/support/"
|
9
9
|
]
|
10
10
|
|
11
11
|
config.eager_load_paths += Dir[
|
12
|
-
"#{config.root}/test/test_botable/",
|
13
|
-
"#{config.root}/test/concerns/",
|
12
|
+
"#{config.root}/test/test_botable/",
|
13
|
+
"#{config.root}/test/concerns/",
|
14
14
|
"#{config.root}/test/support/"
|
15
15
|
]
|
16
16
|
|
@@ -5,6 +5,8 @@ require 'faker'
|
|
5
5
|
module EffectiveTestBotFormFaker
|
6
6
|
DIGITS = ('1'..'9').to_a
|
7
7
|
LETTERS = %w(A B C E G H J K L M N P R S T V X Y) # valid letters of a canadian postal code, eh?
|
8
|
+
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON']
|
9
|
+
FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF']
|
8
10
|
|
9
11
|
# Generates an appropriately pseudo-random value for the given field
|
10
12
|
# Pass in a Hash of fills to define pre-selected values
|
@@ -124,6 +126,9 @@ module EffectiveTestBotFormFaker
|
|
124
126
|
when 'textarea', 'textarea_textarea'
|
125
127
|
Faker::Lorem.paragraph
|
126
128
|
|
129
|
+
when 'input_hidden'
|
130
|
+
Faker::Lorem.paragraph
|
131
|
+
|
127
132
|
when 'input_submit', 'input_search', 'input_button'
|
128
133
|
nil
|
129
134
|
|
@@ -269,19 +274,11 @@ module EffectiveTestBotFormFaker
|
|
269
274
|
end
|
270
275
|
|
271
276
|
def truthy?(value)
|
272
|
-
|
273
|
-
::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(value)
|
274
|
-
else
|
275
|
-
ActiveRecord::Type::Boolean.new.cast(value)
|
276
|
-
end
|
277
|
+
TRUE_VALUES.include?(value)
|
277
278
|
end
|
278
279
|
|
279
280
|
def falsey?(value)
|
280
|
-
|
281
|
-
::ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(value)
|
282
|
-
else
|
283
|
-
::ActiveRecord::Type::Boolean.new.cast(value) == false
|
284
|
-
end
|
281
|
+
FALSE_VALUES.include?(value)
|
285
282
|
end
|
286
283
|
|
287
284
|
end
|
@@ -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
|
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
|
@@ -130,6 +134,7 @@ module EffectiveTestBotFormFiller
|
|
130
134
|
@filled_country_fields = nil
|
131
135
|
|
132
136
|
save_test_bot_screenshot
|
137
|
+
true
|
133
138
|
end
|
134
139
|
|
135
140
|
def fill_input_text(field, value)
|
@@ -173,6 +178,15 @@ module EffectiveTestBotFormFiller
|
|
173
178
|
end
|
174
179
|
end
|
175
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
|
+
|
176
190
|
def fill_input_select(field, value)
|
177
191
|
if EffectiveTestBot.tour_mode_extreme? && select2_input?(field)
|
178
192
|
try_script "$('select##{field['id']}').select2('open')"
|
@@ -273,6 +287,10 @@ module EffectiveTestBotFormFiller
|
|
273
287
|
(field['class'].to_s.include?('ckeditor') || all("span[id='cke_#{field['id']}']", wait: false).present?)
|
274
288
|
end
|
275
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
|
+
|
276
294
|
def custom_control_input?(field) # Bootstrap 4 radios and checks
|
277
295
|
field['class'].to_s.include?('custom-control-input')
|
278
296
|
end
|
@@ -291,16 +309,25 @@ module EffectiveTestBotFormFiller
|
|
291
309
|
|
292
310
|
def skip_form_field?(field)
|
293
311
|
field.reload # Handle a field changing visibility/disabled state from previous form field manipulations
|
294
|
-
|
295
312
|
field_id = field['id'].to_s
|
296
313
|
|
297
|
-
field_id.start_with?('datatable_')
|
298
|
-
field_id.start_with?('filters_scope_')
|
299
|
-
field_id.start_with?('filters_') && field['name'].blank?
|
300
|
-
|
301
|
-
(
|
302
|
-
['true', true, 1].include?(field['data-test-bot-skip'])
|
303
|
-
|
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
|
304
331
|
end
|
305
332
|
|
306
333
|
def field_key(field)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# https://github.com/codeodor/minitest-stub_any_instance
|
2
|
+
|
3
|
+
# included on BasicObject when test_helper calls include EffectiveTestBot::DSL
|
4
|
+
module EffectiveTestBotMocks
|
5
|
+
def stub_any_instance(name, val_or_callable = nil, &block)
|
6
|
+
new_name = "__minitest_any_instance_stub__#{name}"
|
7
|
+
owns_method = instance_method(name).owner == self
|
8
|
+
|
9
|
+
class_eval do
|
10
|
+
alias_method new_name, name if owns_method
|
11
|
+
|
12
|
+
define_method(name) do |*args|
|
13
|
+
if val_or_callable.respond_to? :call then
|
14
|
+
instance_exec(*args, &val_or_callable)
|
15
|
+
else
|
16
|
+
val_or_callable
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
yield
|
22
|
+
ensure
|
23
|
+
class_eval do
|
24
|
+
remove_method name
|
25
|
+
if owns_method
|
26
|
+
alias_method name, new_name
|
27
|
+
remove_method new_name
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -7,17 +7,15 @@ module EffectiveTestBotScreenshotsHelper
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def save_test_bot_screenshot
|
10
|
-
return unless EffectiveTestBot.
|
11
|
-
return unless page.current_path.present?
|
12
|
-
|
10
|
+
return unless EffectiveTestBot.gifs?
|
11
|
+
return unless (page.current_path rescue false).present?
|
12
|
+
|
13
13
|
page.save_screenshot("#{current_test_temp_path}/#{current_test_screenshot_id}.png")
|
14
14
|
true
|
15
15
|
end
|
16
16
|
|
17
17
|
def save_test_bot_failure_gif
|
18
|
-
return unless EffectiveTestBot.screenshots?
|
19
18
|
return unless EffectiveTestBot.gifs?
|
20
|
-
|
21
19
|
return unless save_test_bot_screenshot
|
22
20
|
|
23
21
|
Dir.mkdir(current_test_failure_path) unless File.exist?(current_test_failure_path)
|
@@ -28,7 +26,6 @@ module EffectiveTestBotScreenshotsHelper
|
|
28
26
|
end
|
29
27
|
|
30
28
|
def save_test_bot_tour_gif
|
31
|
-
return unless EffectiveTestBot.screenshots?
|
32
29
|
return unless EffectiveTestBot.gifs?
|
33
30
|
return unless (@test_bot_screenshot_id || 0) > 0
|
34
31
|
|
@@ -42,9 +39,12 @@ module EffectiveTestBotScreenshotsHelper
|
|
42
39
|
def without_screenshots(&block)
|
43
40
|
original = EffectiveTestBot.screenshots
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
begin
|
43
|
+
EffectiveTestBot.screenshots = false
|
44
|
+
yield
|
45
|
+
ensure
|
46
|
+
EffectiveTestBot.screenshots = original
|
47
|
+
end
|
48
48
|
end
|
49
49
|
|
50
50
|
protected
|
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.28
|
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-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- test/support/effective_test_bot_form_helper.rb
|
161
161
|
- test/support/effective_test_bot_login_helper.rb
|
162
162
|
- test/support/effective_test_bot_minitest_helper.rb
|
163
|
+
- test/support/effective_test_bot_mocks.rb
|
163
164
|
- test/support/effective_test_bot_screenshots_helper.rb
|
164
165
|
- test/support/effective_test_bot_test_helper.rb
|
165
166
|
- test/test_bot/system/application_test.rb
|
@@ -190,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
191
|
- !ruby/object:Gem::Version
|
191
192
|
version: '0'
|
192
193
|
requirements: []
|
193
|
-
rubygems_version: 3.1.
|
194
|
+
rubygems_version: 3.1.4
|
194
195
|
signing_key:
|
195
196
|
specification_version: 4
|
196
197
|
summary: A shared library of rails model & system tests that should pass in every
|