effective_test_bot 1.0.4 → 1.0.5

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
  SHA1:
3
- metadata.gz: 66cd88280ff7f36cda35278ca3450c5730585e4b
4
- data.tar.gz: 03ba295258c0c6dfe5d2ae0b2ff50ffbaeaa091c
3
+ metadata.gz: 3b5e93862a13279c13941dccc609c0017608f525
4
+ data.tar.gz: 7681af026c0969053b9bdc48f5e2d78eeb6f0e98
5
5
  SHA512:
6
- metadata.gz: 1afa159c79583a7400349d93f05d212625ea3d6de55f21a3155aefffbeed4ce5efcded550575e7361a5469e3778ffe5c0dd55d00cd5d42b9b1e8c9de125c2e0a
7
- data.tar.gz: d3f632ae8e3557b872656f6d12ed847f7af8b7ff3fd5595b6ee4bbc485d37bb6864ea4b328b343a807aeb4e4f290d6e0491843b3e6a41879c724928b1a291942
6
+ metadata.gz: 7039bad69afa88edd7ae9617eaa52637c952fcae4342c08ed3546f2787c8dfc5d9b9f112eccc7d1abfc2fc64bac35435cd13a6f040f1cb28b676a87001a096e0
7
+ data.tar.gz: 786394b805a080c664f57719f848cce65e3bd2f4c7940c3454b7bb505fd5a08d647866925a37a85d70b407bcaed6410a12a951de47569d06449114d08695bd83
@@ -1,3 +1,3 @@
1
1
  module EffectiveTestBot
2
- VERSION = '1.0.4'.freeze
2
+ VERSION = '1.0.5'.freeze
3
3
  end
@@ -100,7 +100,7 @@ module EffectiveTestBotAssertions
100
100
  end
101
101
 
102
102
  def assert_no_ajax_requests(message = "(no_ajax_requests) :count: Unexpected AJAX requests present")
103
- active = page.evaluate_script('jQuery.active')
103
+ active = page.evaluate_script('$.active')
104
104
  assert (active.blank? || active.zero?), message.sub(':count:', active.to_s)
105
105
  end
106
106
 
@@ -87,7 +87,7 @@ module EffectiveTestBotFormFiller
87
87
  ckeditor_text_area?(field) ? fill_ckeditor_text_area(field, value) : field.set(value)
88
88
  when 'select', 'select_select-one'
89
89
  if EffectiveTestBot.tour_mode_extreme? && field['class'].to_s.include?('select2') # select2
90
- page.execute_script("try { $('select##{field['id']}').select2('open'); } catch(e) {};")
90
+ try_script "$('select##{field['id']}').select2('open')"
91
91
  save_test_bot_screenshot
92
92
  end
93
93
 
@@ -96,7 +96,7 @@ module EffectiveTestBotFormFiller
96
96
  end
97
97
 
98
98
  if EffectiveTestBot.tour_mode_extreme? && field['class'].to_s.include?('select2')
99
- page.execute_script("try { $('select##{field['id']}').select2('close'); } catch(e) {};")
99
+ try_script "$('select##{field['id']}').select2('close')"
100
100
  end
101
101
  when 'input_file'
102
102
  if field['class'].to_s.include?('asset-box-uploader-fileinput')
@@ -348,7 +348,7 @@ module EffectiveTestBotFormFiller
348
348
 
349
349
  def fill_ckeditor_text_area(field, value)
350
350
  value = "<p>#{value.gsub("'", '')}</p>"
351
- page.execute_script("try { CKEDITOR.instances['#{field['id']}'].setData('#{value}'); } catch(e) {};")
351
+ try_script "CKEDITOR.instances['#{field['id']}'].setData('#{value}')"
352
352
  end
353
353
 
354
354
  # The field here is going to be the %input{:type => file}. Files can be one or more pathnames
@@ -400,11 +400,11 @@ module EffectiveTestBotFormFiller
400
400
  end
401
401
 
402
402
  def clear_effective_select(field)
403
- page.execute_script("try { $('select##{field['id']}').val('').trigger('change.select2'); } catch(e) {};")
403
+ try_script "$('select##{field['id']}').val('').trigger('change.select2')"
404
404
  end
405
405
 
406
406
  def close_effective_date_time_picker(field)
407
- page.execute_script("try { $('input##{field['id']}').data('DateTimePicker').hide(); } catch(e) {};")
407
+ try_script "$('input##{field['id']}').data('DateTimePicker').hide()"
408
408
  end
409
409
 
410
410
  private
@@ -43,6 +43,30 @@ module EffectiveTestBotFormHelper
43
43
  true
44
44
  end
45
45
 
46
+ # submit_stripe(content: 'Thank you!'), or
47
+ #
48
+ # submit_stripe
49
+ # assert page.has_content?('Thank you for your support!', wait: 10)
50
+ def submit_stripe(success_content: nil)
51
+ stripe_iframe = find('iframe[name=stripe_checkout_app]')
52
+ assert stripe_iframe.present?, 'unable to find stripe iframe'
53
+
54
+ within_frame(stripe_iframe) do
55
+ fill_in('Card number', with: '4242424242424242')
56
+ fill_in('Expiry', with: "12#{Time.zone.now.year - 1999}")
57
+ fill_in('CVC', with: '123')
58
+ find_submit.click
59
+ end
60
+
61
+ synchronize! # Doesn't seem to work
62
+
63
+ if success_content
64
+ assert page.has_content?(success_content, wait: Capybara.default_max_wait_time * 10), "#{success_content} not found"
65
+ end
66
+
67
+ true
68
+ end
69
+
46
70
  def clear_form
47
71
  all('input,select,textarea').each do |field|
48
72
  if field.tag_name == 'select' && field['class'].to_s.include?('select2') # effective_select
@@ -67,9 +91,9 @@ module EffectiveTestBotFormHelper
67
91
  submit = find_submit(label, last: last)
68
92
 
69
93
  if EffectiveTestBot.screenshots?
70
- page.execute_script "$('input[data-disable-with]').each(function(i) { $.rails.disableFormElement($(this)); });"
94
+ try_script "$('input[data-disable-with]').each(function(i) { $.rails.disableFormElement($(this)); });"
71
95
  save_test_bot_screenshot
72
- page.execute_script "$('input[data-disable-with]').each(function(i) { $.rails.enableFormElement($(this)); });"
96
+ try_script "$('input[data-disable-with]').each(function(i) { $.rails.enableFormElement($(this)); });"
73
97
  end
74
98
 
75
99
  if debug
@@ -51,6 +51,10 @@ module EffectiveTestBotTestHelper
51
51
  from_path != (to_path || page.current_path)
52
52
  end
53
53
 
54
+ def try_script(script)
55
+ page.execute_script("try { #{script}; } catch(e) {};")
56
+ end
57
+
54
58
  # Calls capybara within do .. end if selector is present and bool is true
55
59
  def within_if(selector, bool = true, &block)
56
60
  (selector.present? && bool) ? within(first(selector)) { yield } : yield
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.0.4
4
+ version: 1.0.5
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: 2018-07-22 00:00:00.000000000 Z
11
+ date: 2018-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails