effective_test_bot 1.1.29 → 1.1.34

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: 720882b4c8bc15be729ff26a90638d345786b523862ae226b86c15f2de18e8a8
4
- data.tar.gz: c495c1463653e9c3ab5c0ff6eefc1b935dff9ce1808bb8bb15855a3eae5beb11
3
+ metadata.gz: cbc62ecd64fb4cb7347234c1d202b2cedaa79f65522d08d3b1cc9c4910b41982
4
+ data.tar.gz: ad97cd5e6a5102265456a761f92b9923ef1556aa2df9fbc0db0de3c00c35d8dd
5
5
  SHA512:
6
- metadata.gz: f435286f63ddbe6990fa6bf09aef992b982df7542b7c2ea7cbfc60086fe8403d9b85003c22ebb0a3b77e6f856f991583895783f60c6a319dc1871debfb77eff3
7
- data.tar.gz: 369ec84101fb1e56135d4b92939a6b296adbc9199bc7d1970ac7ceae7bd4f86cca4c068ff707df2a3c30c38bfe1b938d0d9e4553ccade05b536c22b3bd04e4d8
6
+ metadata.gz: 259356daa7725ae3cc06eb278904eac48beca8383fbed43db425de744f7980ec7fc2b51f116889124baa6ea4312a4f4e4fe76fce1fae1367ac93dfa5af733c28
7
+ data.tar.gz: b8bd1757017c4e95d71d49040dd6f18a29bfc45cdc569f726c52315bc0d82bf75e25678de4b1b0dda47debbe4c8888ef1329bc4cc0594cc42420d89580299122
@@ -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.29'.freeze
2
+ VERSION = '1.1.34'.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.29
4
+ version: 1.1.34
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