effective_test_bot 1.1.30 → 1.1.35

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: 9dec06ddd30a8548521d86039448de854f1ba937f40799d0289e161b4e894131
4
- data.tar.gz: bd45ec5a42567d3e11ee9aecdd3cc9359c8351c8f4c8ed21e844f9baeb3d05da
3
+ metadata.gz: fc72acbdf713f34184e3b5ad7f5667632d0f6328a106de14042c74cf5f4905f6
4
+ data.tar.gz: 436bf4dee3250bb087ba2cb9119d48e7a4853078f0509cd9558feedb37114083
5
5
  SHA512:
6
- metadata.gz: d61ff64d42c6d0f95ce15ffb457307286e13ec36347b09c0c208241fb05ed3ca779140b44ad0af49143299f1135c48177a2137d442d5ffb815864359f642a13d
7
- data.tar.gz: 3c86a02228efb83687c2b26d7daa878304616361d6ae123bc455b2329ffbc6fb6b53273fd19b1cea05b239d5c46c47ad2af9cfb39407bff1bdf74b3fb5de69e5
6
+ metadata.gz: 4fb77d02cfa0da8f3b940fa697d7dcfa935f7a3c08003108a850a83d4073290e242bba9f448962f31bf27193879350a0f3e35c69e61c26b50193f4e751b68c96
7
+ data.tar.gz: 3778d54b3764389c71b9438b327218b56e55d9220b431062b8d1816d7c470e0d16a9215e92e7549c05cb45f76824c249329fa8d6d4434d2184d74652fe527ff3
@@ -58,10 +58,10 @@ module EffectiveTestBotControllerHelper
58
58
  case object
59
59
  when ActiveRecord::Base
60
60
  assigns[key] = object.attributes
61
- assigns[key][:errors] = object.errors.messages.delete_if { |_, v| v.blank? } if object.errors.present?
61
+ assigns[key][:errors] = object.errors.messages.select { |_, v| v.present? } if object.errors.present?
62
62
  when (ActiveModel::Model rescue nil)
63
63
  assigns[key] = object.respond_to?(:attributes) ? object.attributes : { present_but_not_serialized: true }
64
- assigns[key][:errors] = object.errors.messages.delete_if { |_, v| v.blank? } if object.errors.present?
64
+ assigns[key][:errors] = object.errors.messages.select { |_, v| v.present? } if object.errors.present?
65
65
  when TrueClass, FalseClass, NilClass, String, Symbol, Numeric
66
66
  assigns[key] = object
67
67
  else
@@ -1,3 +1,3 @@
1
1
  module EffectiveTestBot
2
- VERSION = '1.1.30'.freeze
2
+ VERSION = '1.1.35'.freeze
3
3
  end
@@ -217,16 +217,34 @@ 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'
223
- def assert_email(action = nil, to: nil, from: nil, subject: nil, body: nil, message: nil, &block)
237
+ def assert_email(action = nil, to: nil, from: nil, subject: nil, body: nil, message: nil, count: nil, &block)
224
238
  if block_given?
225
239
  before = ActionMailer::Base.deliveries.length
226
240
  yield
227
- after = ActionMailer::Base.deliveries.length
241
+ difference = (ActionMailer::Base.deliveries.length - before)
228
242
 
229
- assert (after - before == 1), "(assert_email) Expected one email to have been delivered"
243
+ if count.present?
244
+ assert (difference == count), "(assert_email) Expected #{count} email to have been delivered, but #{difference} were instead"
245
+ else
246
+ assert (difference > 0), "(assert_email) Expected at least one email to have been delivered"
247
+ end
230
248
  end
231
249
 
232
250
  if (action || to || from || subject || body).nil?
@@ -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.30
4
+ version: 1.1.35
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-11 00:00:00.000000000 Z
11
+ date: 2021-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails