effective_test_bot 1.1.28 → 1.1.33

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5590f0c1b7be5d9eae672f585d6171c64bc9a49a809b7deb63c3cb77c6d26180
4
- data.tar.gz: bb8d8cea77300a83004d96d206a8f8ed8a11f96b7ddad4b71b71da7179f11f5b
3
+ metadata.gz: dae0671db7b1a7f8541f4ca3c950ec4a660367481e6651e81de83e5b93f352a6
4
+ data.tar.gz: a9311759796dac457296380f53b0842342cbd42dd923afc3813ffcb2ad2ec0e4
5
5
  SHA512:
6
- metadata.gz: ebe2ca7bff109d9d3a844e734ab1d29112e0c88aca0c9bc7d0efc3324fb2a7c04a3947d90bb160195379d24a9f828aa9bf2483d7f2b8d6744a2da058841023b8
7
- data.tar.gz: '09d8abd2735e66d95ece47b509022cfed74372faaca8543d7c202eaa602407eb69528ed5dad2178ee5aff2bcc6bca54797897b81395cbf918f823c4c3d721cc4'
6
+ metadata.gz: 55b346bda670b8f72f699b2bf485a4ff4aefb68d98645dcead6260b08996396ec6ef35610c1beee2d342743f38753bef525d29b0db7664c20b7b4b5edb7f9e5f
7
+ data.tar.gz: 3b722ca2cbfdfec86b07b1ac1795d3300a834a1123797d91072db785a2446f5212a28fcb73a41efdceae14466e5d96221bcfe67b18239f5620837c94db0f3030
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveTestBot
2
- VERSION = '1.1.28'.freeze
2
+ VERSION = '1.1.33'.freeze
3
3
  end
@@ -217,6 +217,20 @@ module EffectiveTestBotAssertions
217
217
  assert diff.blank?, "(assert_no_email) #{diff.length} unexpected emails delivered: #{diff}"
218
218
  end
219
219
 
220
+ # assert_effective_log { click_on('download.txt') }
221
+ def assert_effective_log(status: nil)
222
+ raise('EffectiveLogging is not defined') unless defined?(EffectiveLogging)
223
+ raise('expected a block') unless block_given?
224
+
225
+ logs = (status.present? ? Effective::Log.where(status: status).all : Effective::Log.all)
226
+
227
+ before = logs.count
228
+ yield
229
+ after = logs.count
230
+
231
+ assert (after - before == 1), "(assert_effective_log) Expected one log to have been created"
232
+ end
233
+
220
234
  # assert_email :new_user_sign_up
221
235
  # assert_email :new_user_sign_up, to: 'newuser@example.com'
222
236
  # assert_email from: 'admin@example.com'
@@ -37,7 +37,7 @@ module EffectiveTestBotFormFiller
37
37
  save_test_bot_screenshot
38
38
 
39
39
  tab_href = '#' + tab['href'].to_s.split('#').last
40
- within('div' + tab_href) { fill_form_fields(fills) }
40
+ within_if('div' + tab_href) { fill_form_fields(fills) }
41
41
  end
42
42
 
43
43
  # If there is no visible submits, go back to the first tab
@@ -193,8 +193,23 @@ module EffectiveTestBotFormFiller
193
193
  save_test_bot_screenshot
194
194
  end
195
195
 
196
- if field.all('option:enabled', wait: false).length > 0 && value != :unselect
197
- Array(value).each do |value|
196
+ if value == :unselect
197
+ return close_effective_select(field)
198
+ end
199
+
200
+ if field.all('option:enabled', wait: false).length == 0
201
+ return close_effective_select(field)
202
+ end
203
+
204
+ # Must be some options
205
+ Array(value).each do |value|
206
+ option = field.all("option:enabled[value=\"#{value}\"]", wait: false).first
207
+ option ||= field.all('option:enabled', wait: false).find { |field| field.text == value }
208
+
209
+ if option.present?
210
+ option.select_option
211
+ else
212
+ # This will most likely raise an error that it cant be found
198
213
  field.select(value.to_s, match: :first, disabled: false)
199
214
  end
200
215
  end
@@ -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
 
@@ -57,7 +57,7 @@ module EffectiveTestBotTestHelper
57
57
 
58
58
  # Calls capybara within do .. end if selector is present and bool is true
59
59
  def within_if(selector, bool = true, &block)
60
- (selector.present? && bool) ? within(first(selector)) { yield } : yield
60
+ (all(selector).length > 0 && bool) ? within(first(selector)) { yield } : yield
61
61
  end
62
62
 
63
63
  def within_each(selector, &block)
@@ -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) == true
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.28
4
+ version: 1.1.33
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-28 00:00:00.000000000 Z
11
+ date: 2021-02-02 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.4
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