workarea-testing 3.4.45 → 3.5.0.beta.1

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: 59f0297883efec8dc2e207de6c1c5cca9f5e96f83e07350cc30e076bddb3822e
4
- data.tar.gz: 03fb6c22ee93ef7dce856147f8672d9ff45e923289a1c7509bd44ad68843a2b8
3
+ metadata.gz: fa760dc3bfe6e7d0e7314f22e870e803bf29c05d417cec5d685e381e1acd2d40
4
+ data.tar.gz: 0c867ee33caf405fa051f7794d799a18486fd9f7c9360082090a0b520efd94db
5
5
  SHA512:
6
- metadata.gz: c3852099a08e8a218e48f8fd766846e342e095efcfe2a805c83c238c813572fbbae6d0d11bf0e457d0f5ed71b4154c95a9a96f0ea0d2d09fc6417aecb381d907
7
- data.tar.gz: f2f58ccb86dbed6eecfcd6cddde2b481e7d36514ec836805d359773e53d821418058d63291cc15eee9ea7b08dd9e9b312c0b08a73361569aaee0a04b66a6ad57
6
+ metadata.gz: dfaee00f907b6dc2e62a8f598fc2fffebeeb651e683e29e11ca2b654f9854999bdbe3978d1b0d83ad43540508e7cb7b8e941ac3a0d645e5f1435d7b842382d20
7
+ data.tar.gz: 315a4b24e6604c75a0ddc705baeece3a5acf927316bb38f768f854930d9f73bbf65334b26c52870097be45567c138f8e602dae146ddac49c7966e6149ded27f9
data/LICENSE.txt ADDED
@@ -0,0 +1,52 @@
1
+ WebLinc
2
+ Business Source License
3
+
4
+ Licensor: WebLinc Corporation, 22 S. 3rd Street, 2nd Floor, Philadelphia PA 19106
5
+
6
+ Licensed Work: Workarea Commerce Platform
7
+ The Licensed Work is (c) 2019 WebLinc Corporation
8
+
9
+ Additional Use Grant:
10
+ You may make production use of the Licensed Work without an additional license agreement with WebLinc so long as you do not use the Licensed Work for a Commerce Service.
11
+
12
+ A "Commerce Service" is a commercial offering that allows third parties (other than your employees and contractors) to access the functionality of the Licensed Work by creating or managing commerce functionality, the products, taxonomy, assets and/or content of which are controlled by such third parties.
13
+
14
+ For information about obtaining an additional license agreement with WebLinc, contact licensing@workarea.com.
15
+
16
+ Change Date: 2019-08-20
17
+
18
+ Change License: Version 2.0 or later of the GNU General Public License as published by the Free Software Foundation
19
+
20
+ Terms
21
+
22
+ The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
23
+
24
+ Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
25
+
26
+ If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
27
+
28
+ All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
29
+
30
+ You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
31
+
32
+ Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
33
+
34
+ This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License). TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to use this License’s text to license your works and to refer to it using the trademark "Business Source License" as long as you comply with the Covenants of Licensor below.
35
+
36
+ Covenants of Licensor
37
+ In consideration of the right to use this License’s text and the "Business Source License" name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor:
38
+
39
+ To specify as the Change License the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where "compatible" means that software provided under the Change License can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional Change Licenses without limitation.
40
+
41
+ To either: (a) specify an additional grant of rights to use that does not impose any additional restriction on the right granted in this License, as the Additional Use Grant; or (b) insert the text "None."
42
+
43
+ To specify a Change Date.
44
+
45
+ Not to modify this License in any other way.
46
+
47
+ Notice
48
+ The Business Source License (this document, or the "License") is not an Open Source license. However, the Licensed Work will eventually be made available under an Open Source License, as stated in this License.
49
+
50
+ For more information on the use of the Business Source License generally, please visit the Adopting and Developing Business Source License FAQ.
51
+
52
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. "Business Source License" is a trademark of MariaDB Corporation Ab.
@@ -1,5 +1,6 @@
1
1
  module Workarea
2
2
  class GeneratorTest < Rails::Generators::TestCase
3
3
  extend TestCase::Decoration
4
+ include TestCase::Configuration
4
5
  end
5
6
  end
@@ -32,25 +32,16 @@ module Workarea
32
32
  end
33
33
  end
34
34
 
35
- module Locales
36
- def set_locales(*)
37
- super
38
-
39
- Workarea::Elasticsearch::Document.all.each(&:create_indexes!)
40
- Workarea::Search::Storefront.ensure_dynamic_mappings
41
- end
42
- end
43
-
44
35
  extend TestCase::Decoration
36
+ include TestCase::Configuration
45
37
  include TestCase::Workers
46
38
  include TestCase::SearchIndexing
47
39
  include TestCase::Mail
48
40
  include TestCase::RunnerLocation
49
41
  include TestCase::Locales
50
42
  include TestCase::S3
51
- include TestCase::Geocoder
43
+ include TestCase::Encryption
52
44
  include Factories
53
45
  include Configuration
54
- include Locales
55
46
  end
56
47
  end
@@ -0,0 +1,23 @@
1
+ module Workarea
2
+ class MailerTest < ActionMailer::TestCase
3
+ extend TestCase::Decoration
4
+ extend TestCase::RunnerLocation
5
+ include TestCase::Configuration
6
+ include Factories
7
+ include TestCase::Workers
8
+ include TestCase::RunnerLocation
9
+ include TestCase::Locales
10
+ include TestCase::S3
11
+ include TestCase::Encryption
12
+ include TestCase::SearchIndexing
13
+ include TestCase::Mail
14
+
15
+ setup do
16
+ Mongoid.truncate!
17
+ Workarea.redis.flushdb
18
+ WebMock.disable_net_connect!(allow_localhost: true)
19
+ end
20
+
21
+ teardown :travel_back
22
+ end
23
+ end
@@ -3,15 +3,15 @@ require 'benchmark'
3
3
  module Workarea
4
4
  class PerformanceTest < ActionDispatch::IntegrationTest
5
5
  extend TestCase::Decoration
6
+ include TestCase::Configuration
6
7
  include TestCase::Workers
7
8
  include TestCase::SearchIndexing
8
9
  include TestCase::RunnerLocation
9
10
  include TestCase::Locales
10
11
  include TestCase::S3
11
- include TestCase::Geocoder
12
+ include TestCase::Encryption
12
13
  include Factories
13
14
  include IntegrationTest::Configuration
14
- include IntegrationTest::Locales
15
15
 
16
16
  HEADER = %w(measurement created_at workarea rails ruby revision passed)
17
17
 
@@ -66,7 +66,7 @@ module Workarea
66
66
  credit_card: {
67
67
  number: '1',
68
68
  month: 1,
69
- year: next_year,
69
+ year: 2020,
70
70
  cvv: '999'
71
71
  }
72
72
  }
@@ -137,6 +137,20 @@ module Workarea
137
137
  def select_shipping_service
138
138
  choose 'Ground'
139
139
  end
140
+
141
+ def disable_analytics_dom_events
142
+ page.execute_script('WORKAREA.analytics.disableDomEvents();')
143
+ end
144
+
145
+ def find_analytics_events(for_event: nil)
146
+ all_events = page.evaluate_script('WORKAREA.analytics.events')
147
+
148
+ if for_event.blank?
149
+ all_events
150
+ else
151
+ all_events.select { |e| e['name'] == for_event }
152
+ end
153
+ end
140
154
  end
141
155
  end
142
156
  end
@@ -1,14 +1,17 @@
1
1
  require 'capybara/rails'
2
2
  require 'webdrivers'
3
3
  require 'puma'
4
+ require 'capybara/chromedriver/logger'
4
5
  require 'workarea/integration_test'
5
6
  require 'workarea/testing/custom_capybara_matchers'
7
+ require 'workarea/testing/headless_chrome'
8
+ require 'workarea/testing/capybara_chromedriver_logger_collector.decorator'
6
9
 
7
10
  # get options on load to ensure initial configuration is captured.
8
11
  # Capybara.register_driver does not execute the passed block immediately, which
9
12
  # can cause issues with the aliasing of Workarea.config.headless_chrome_options.
10
13
  # This can be removed in the upcoming minor to rename that configuration.
11
- chrome_options = Workarea::Configuration::HeadlessChrome.options
14
+ chrome_options = Workarea::HeadlessChrome.options
12
15
 
13
16
  Capybara.server_errors = [Exception]
14
17
  Capybara.automatic_label_click = true
@@ -17,11 +20,24 @@ Capybara.register_driver :headless_chrome do |app|
17
20
  app,
18
21
  browser: :chrome,
19
22
  desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(
20
- chromeOptions: chrome_options
23
+ chromeOptions: chrome_options,
24
+ loggingPrefs: {
25
+ browser: 'ALL'
26
+ }
21
27
  )
22
28
  )
23
29
  end
24
30
 
31
+ # Fail tests when JS errors are thrown.
32
+ Capybara::Chromedriver::Logger.raise_js_errors = true
33
+
34
+ # Ignore common error responses for `/current_user.json` and /login`.
35
+ # These occur during the normal course of testing authentication, so
36
+ # they don't need to be output in the test results.
37
+ Capybara::Chromedriver::Logger.filters = [
38
+ /(login|current_user\.json) - Failed to load resource: the server responded with a status of (401|422)/
39
+ ]
40
+
25
41
  Capybara.server = :puma, { Silent: true }
26
42
  Capybara.javascript_driver = :headless_chrome
27
43
 
@@ -47,16 +63,16 @@ ENV["RAILS_SYSTEM_TESTING_SCREENSHOT"] ||= 'simple'
47
63
  module Workarea
48
64
  class SystemTest < ActionDispatch::SystemTestCase
49
65
  extend TestCase::Decoration
66
+ include TestCase::Configuration
50
67
  include TestCase::Workers
51
68
  include TestCase::SearchIndexing
52
69
  include TestCase::Mail
53
70
  include TestCase::RunnerLocation
54
71
  include TestCase::Locales
55
72
  include TestCase::S3
56
- include TestCase::Geocoder
73
+ include TestCase::Encryption
57
74
  include Factories
58
75
  include IntegrationTest::Configuration
59
- include IntegrationTest::Locales
60
76
 
61
77
  driven_by :headless_chrome
62
78
 
@@ -65,7 +81,7 @@ module Workarea
65
81
  end
66
82
 
67
83
  teardown do
68
- assert_no_js_errors if javascript?
84
+ Capybara::Chromedriver::Logger::TestHooks.after_example! if javascript?
69
85
  end
70
86
 
71
87
  # This is to make sure Chrome chills out and allows XHR requests to finish
@@ -137,21 +153,6 @@ module Workarea
137
153
  page.execute_script('window.scrollBy(0, 9999999)')
138
154
  end
139
155
 
140
- # Intentionally fails, providing a custom error message, if
141
- # any JavaScript errors are thrown during a test run.
142
- def assert_no_js_errors
143
- page.driver.browser.manage.logs.get(:browser).each do |log_entry|
144
- # Bad responses (like 422 or 401) show as errors as well, which are OK
145
- # for system tests because they indicate the site is functioning properly.
146
- if log_entry.level == 'SEVERE' && log_entry.message =~ /Uncaught/
147
- assert(false, log_entry.message)
148
- elsif log_entry.level == 'WARNING'
149
- STDERR.puts 'WARN: Browser warning'
150
- STDERR.puts log_entry.message
151
- end
152
- end
153
- end
154
-
155
156
  # There is some kind of timing problem around waiting for this iframe that
156
157
  # after a few hours we still can't find. This is a hack to keep this
157
158
  # passing.
@@ -41,7 +41,7 @@ module Workarea
41
41
  included do
42
42
  setup do
43
43
  @_worker_state =
44
- Sidekiq::Callbacks.workers.reduce({}) do |memo, worker|
44
+ Sidekiq::CallbacksWorker.workers.reduce({}) do |memo, worker|
45
45
  memo[worker] = [worker.enabled?, worker.inlined?]
46
46
  memo
47
47
  end
@@ -51,7 +51,7 @@ module Workarea
51
51
  end
52
52
 
53
53
  teardown do
54
- Sidekiq::Callbacks.workers.each do |worker|
54
+ Sidekiq::CallbacksWorker.workers.each do |worker|
55
55
  worker.enabled = @_worker_state[worker].first
56
56
  worker.inlined = @_worker_state[worker].second
57
57
  end
@@ -100,13 +100,16 @@ module Workarea
100
100
  Rails.root.to_s.split('/test/').first.eql?(calling_test.split('/test/').first)
101
101
  end
102
102
 
103
+ # TODO remove in v3.6
103
104
  def running_in_gem?
104
- warn <<~eos
105
- DEPRECATION WARNING: running_in_gem? is deprecated, use running_from_dummy_app? if
106
- you want to know if the test suite is running from a plugin or
107
- running_from_source? if you want to know if the currently executing test
108
- is defined in the current Rails project.
109
- eos
105
+ Workarea.deprecation.warn(
106
+ <<~eos.squish
107
+ running_in_gem? is deprecated, use running_from_dummy_app? if
108
+ you want to know if the test suite is running from a plugin or
109
+ running_from_source? if you want to know if the currently executing test
110
+ is defined in the current Rails project.
111
+ eos
112
+ )
110
113
  running_from_source?
111
114
  end
112
115
 
@@ -126,11 +129,10 @@ module Workarea
126
129
  delegate :t, to: :I18n
127
130
  end
128
131
 
129
- def set_locales(available:, default:, current: nil, fallbacks: nil)
132
+ def set_locales(available:, default:, current: nil)
130
133
  Rails.application.config.i18n.available_locales = I18n.available_locales = available
131
134
  Rails.application.config.i18n.default_locale = I18n.default_locale = default
132
135
  I18n.locale = current || default
133
- I18n.fallbacks = fallbacks if I18n.respond_to?(:fallbacks=)
134
136
  end
135
137
 
136
138
  def save_locales
@@ -140,7 +142,6 @@ module Workarea
140
142
  @current_i18n_available_locales = I18n.available_locales
141
143
  @current_i18n_default_locale = I18n.default_locale
142
144
  @current_i18n_locale = I18n.default_locale
143
- @current_i18n_fallbacks = I18n.try(:fallbacks)
144
145
  end
145
146
 
146
147
  def restore_locales
@@ -150,7 +151,6 @@ module Workarea
150
151
  I18n.available_locales = @current_i18n_available_locales
151
152
  I18n.default_locale = @current_i18n_default_locale
152
153
  I18n.locale = @current_i18n_locale
153
- I18n.fallbacks = @current_i18n_fallbacks if I18n.respond_to?(:fallbacks=)
154
154
  end
155
155
  end
156
156
 
@@ -165,46 +165,58 @@ module Workarea
165
165
  def mock_s3
166
166
  Fog.mock!
167
167
  Workarea.s3.directories.create(key: Workarea::Configuration::S3.bucket)
168
- Workarea.s3.stubs(:get_bucket_cors).returns(mock_s3_cors_response)
169
- Workarea.s3.stubs(:put_bucket_cors)
170
168
  end
171
169
 
172
170
  def reset_s3
173
171
  Fog::Mock.reset
174
172
  end
173
+ end
174
+
175
+ module Configuration
176
+ extend ActiveSupport::Concern
177
+
178
+ included do
179
+ setup :store_config_state
180
+ teardown :reset_config_state
181
+ end
182
+
183
+ def store_config_state
184
+ @original_config = Rails.configuration.workarea.deep_dup
185
+ end
175
186
 
176
- def mock_s3_cors_response
177
- result = mock('Excon::Response')
178
- result.stubs(data: { body: { 'CORSConfiguration' => [] } })
179
- result
187
+ def reset_config_state
188
+ Rails.configuration.workarea = @original_config
180
189
  end
181
190
  end
182
191
 
183
- module Geocoder
192
+ module Encryption
184
193
  extend ActiveSupport::Concern
185
194
 
186
195
  included do
187
- setup :save_geocoder_config
188
- teardown :restore_geocoder_config
196
+ setup :ensure_encryption_key
197
+ teardown :reset_encryption_key
189
198
  end
190
199
 
191
- def save_geocoder_config
192
- @original_geocoder_config = ::Geocoder.config.deep_dup
200
+ def ensure_encryption_key(key: ActiveSupport::EncryptedFile.generate_key)
201
+ env_key = Mongoid::Encrypted.configuration.env_key
202
+ @original_key = ENV[env_key]
203
+ ENV[env_key] ||= key
193
204
  end
194
205
 
195
- def restore_geocoder_config
196
- ::Geocoder.configure(@original_geocoder_config)
206
+ def reset_encryption_key
207
+ ENV[Mongoid::Encrypted.configuration.env_key] = @original_key
197
208
  end
198
209
  end
199
210
 
200
211
  extend Decoration
201
212
  extend RunnerLocation
213
+ include Configuration
202
214
  include Factories
203
215
  include Workers
204
216
  include RunnerLocation
205
217
  include Locales
206
218
  include S3
207
- include Geocoder
219
+ include Encryption
208
220
 
209
221
  setup do
210
222
  Mongoid.truncate!
@@ -24,6 +24,7 @@ require 'workarea/system_test'
24
24
  require 'workarea/view_test'
25
25
  require 'workarea/generator_test'
26
26
  require 'workarea/performance_test'
27
+ require 'workarea/mailer_test'
27
28
 
28
29
  require 'workarea/admin/integration_test'
29
30
  require 'workarea/core/discount_condition_tests'
@@ -65,7 +66,3 @@ Workarea::Plugin.installed.each do |plugin|
65
66
  require support_file
66
67
  end
67
68
  end
68
-
69
- # Set this to the lowest setting to improve performance creating passwords.
70
- # Read more here: https://github.com/codahale/bcrypt-ruby#cost-factors
71
- BCrypt::Engine.cost = 4
@@ -0,0 +1,12 @@
1
+ # Bad responses (like 422 or 401) show as errors as well, which are OK
2
+ # for system tests because they indicate the site is functioning properly.
3
+ decorate Capybara::Chromedriver::Logger::Collector do
4
+ def flush_logs!
5
+ browser_logs.each do |log|
6
+ message = Capybara::Chromedriver::Logger::Message.new(log)
7
+ errors << message if message.error? && message.message =~ /Uncaught/
8
+
9
+ log_destination.puts message.to_s unless should_filter?(message)
10
+ end
11
+ end
12
+ end
@@ -16,6 +16,16 @@ module Workarea
16
16
  create = CreateFulfillment.new(order).tap(&:perform)
17
17
  create.fulfillment
18
18
  end
19
+
20
+ def create_fulfillment_sku(overrides = {})
21
+ attributes = factory_defaults(:fulfillment_sku).merge(overrides)
22
+ Workarea::Fulfillment::Sku.create!(attributes)
23
+ end
24
+
25
+ def create_fulfillment_token(overrides = {})
26
+ attributes = factory_defaults(:fulfillment_token).merge(overrides)
27
+ Workarea::Fulfillment::Token.create!(attributes)
28
+ end
19
29
  end
20
30
  end
21
31
  end
@@ -16,6 +16,8 @@ module Workarea
16
16
 
17
17
  def create_search_by_week(overrides = {})
18
18
  attributes = factory_defaults(:insights_search_by_week).merge(overrides)
19
+ attributes[:query_id] ||= QueryString.new(attributes[:query_string]).id
20
+
19
21
  Workarea::Metrics::SearchByWeek.create!(attributes).tap do
20
22
  Factories::Metrics.search_by_week_count += 1
21
23
  end
@@ -72,6 +72,40 @@ module Workarea
72
72
 
73
73
  checkout.place_order
74
74
  end
75
+
76
+ def create_fraudulent_order(overrides = {})
77
+ attributes = factory_defaults(:fraudulent_order).merge(overrides)
78
+ decision_attributes = attributes.slice(:fraud_decision)
79
+
80
+ decision = create_fraud_decision(decision_attributes[:fraud_decision])
81
+
82
+ shipping_service = create_shipping_service
83
+ sku = 'SKU'
84
+ create_product(variants: [{ sku: sku, regular: 5.to_m }])
85
+ details = OrderItemDetails.find(sku)
86
+ order = Workarea::Order.new(attributes)
87
+
88
+ item = { sku: sku, quantity: 2 }.merge(details.to_h)
89
+
90
+ order.add_item(item)
91
+
92
+ checkout = Checkout.new(order)
93
+ checkout.update(
94
+ factory_defaults(:checkout_payment).merge(
95
+ shipping_address: factory_defaults(:shipping_address),
96
+ billing_address: factory_defaults(:billing_address),
97
+ shipping_service: shipping_service.name,
98
+ )
99
+ )
100
+
101
+ order.set_fraud_decision!(decision)
102
+ order
103
+ end
104
+
105
+ def create_fraud_decision(overrides = {})
106
+ attributes = factory_defaults(:fraud_decision).merge(overrides)
107
+ Workarea::Order::FraudDecision.new(attributes)
108
+ end
75
109
  end
76
110
  end
77
111
  end
@@ -32,10 +32,6 @@ module Workarea
32
32
 
33
33
  capture.complete!
34
34
  end
35
-
36
- def next_year
37
- 1.year.from_now.year
38
- end
39
35
  end
40
36
  end
41
37
  end
@@ -0,0 +1,62 @@
1
+ module Workarea
2
+ module Factories
3
+ module Segment
4
+ Factories.add(self)
5
+
6
+ def create_life_cycle_segments
7
+ Workarea::Segment::LifeCycle.create!
8
+ end
9
+
10
+ def create_segment(overrides = {})
11
+ attributes = factory_defaults(:segment).merge(overrides)
12
+ Workarea::Segment.create!(attributes)
13
+ end
14
+
15
+ def create_visit(overrides = {})
16
+ attributes = sample_rack_env.merge(overrides.except(:email, :sessions))
17
+ result = Workarea::Visit.new(attributes)
18
+
19
+ if overrides[:email].present?
20
+ result.cookies.signed[:email] = overrides[:email]
21
+ end
22
+
23
+ if overrides[:sessions].present?
24
+ result.cookies[:sessions] = overrides[:sessions]
25
+ end
26
+
27
+ if overrides.key?(:logged_in)
28
+ result.stubs(logged_in?: overrides[:logged_in])
29
+ end
30
+
31
+ result
32
+ end
33
+
34
+ def sample_rack_env
35
+ Rails.application.env_config.merge(
36
+ 'rack.version' => [1, 3],
37
+ 'rack.multithread' => true,
38
+ 'rack.multiprocess' => true,
39
+ 'rack.run_once' => false,
40
+ 'REQUEST_METHOD' => 'GET',
41
+ 'SERVER_NAME' => 'www.example.com',
42
+ 'SERVER_PORT' => '80',
43
+ 'QUERY_STRING' => '',
44
+ 'PATH_INFO' => '/current_user.json',
45
+ 'rack.url_scheme' => 'http',
46
+ 'HTTPS' => 'off',
47
+ 'SCRIPT_NAME' => '',
48
+ 'CONTENT_LENGTH' => '0',
49
+ 'rack.test' => true,
50
+ 'REMOTE_ADDR' => '127.0.0.1',
51
+ 'REQUEST_URI' => '/current_user.json',
52
+ 'HTTP_HOST' => 'www.example.com',
53
+ 'CONTENT_TYPE' => nil,
54
+ 'HTTP_ACCEPT' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
55
+ 'HTTP_COOKIE' => '',
56
+ 'ORIGINAL_FULLPATH' => '/current_user.json',
57
+ 'ORIGINAL_SCRIPT_NAME' => ''
58
+ )
59
+ end
60
+ end
61
+ end
62
+ end
@@ -34,12 +34,16 @@ defaults.content = { name: 'Test content' }
34
34
  defaults.page = { name: 'Test Page' }
35
35
 
36
36
  # factories/data_file.rb
37
- defaults.import = { model_type: Workarea::Catalog::Product }
38
- defaults.export = Proc.new { { model_type: Workarea::Catalog::Product, query_id: Workarea::Search::AdminProducts.new.to_global_id } }
37
+ defaults.import = { model_type: 'Workarea::Catalog::Product' }
38
+ defaults.export = Proc.new { { model_type: 'Workarea::Catalog::Product', query_id: Workarea::Search::AdminProducts.new.to_global_id } }
39
+
40
+ # factories/fulfillment.rb
41
+ defaults.fulfillment_sku = { id: '2134', policy: 'ship' }
42
+ defaults.fulfillment_token = { order_id: '1234', order_item_id: '3456', sku: '2134' }
39
43
 
40
44
  # factories/insights.rb
41
45
  defaults.insights_product_by_week = Proc.new { { product_id: "foo-#{product_by_week_count}", reporting_on: Time.current } }
42
- defaults.insights_search_by_week = Proc.new { { query_id: "foo#{search_by_week_count}", reporting_on: Time.current } }
46
+ defaults.insights_search_by_week = Proc.new { { query_string: "foo #{search_by_week_count}", searches: 1, reporting_on: Time.current } }
43
47
  defaults.hot_products = Proc.new { { results: Array.new(3) { create_product_by_week.as_document } } }
44
48
  defaults.cold_products = Proc.new { { results: Array.new(3) { create_product_by_week.as_document } } }
45
49
  defaults.top_products = Proc.new { { results: Array.new(3) { create_product_by_week.as_document } } }
@@ -54,6 +58,7 @@ defaults.menu = Proc.new { { taxon: create_taxon } }
54
58
  # factories/order.rb
55
59
  defaults.order = { email: 'bcrouse@workarea.com' }
56
60
  defaults.placed_order = Proc.new { { id: '1234', email: 'bcrouse-new@workarea.com', placed_at: Time.current } }
61
+ defaults.fraudulent_order = Proc.new { { id: '1234', email: 'bcrouse-new@workarea.com', fraud_decision: { decision: :declined, message: "declined for fraud", response: "test response" } } }
57
62
  defaults.shipping_address = { first_name: 'Ben', last_name: 'Crouse', street: '22 S. 3rd St.', street_2: 'Second Floor', city: 'Philadelphia', region: 'PA', postal_code: '19106', country: 'US' }
58
63
  defaults.billing_address = { first_name: 'Ben', last_name: 'Crouse', street: '22 S. 3rd St.', street_2: 'Second Floor', city: 'Philadelphia', region: 'PA', postal_code: '19106', country: 'US' }
59
64
  defaults.checkout_payment = { payment: 'new_card', credit_card: { number: '1', month: '1', year: Time.current.year + 1, cvv: '999' } }
@@ -86,5 +91,11 @@ defaults.search_customization = { id: 'foo', query: 'Foo' }
86
91
  defaults.admin_search = Proc.new { { results: [create_product, create_product, create_product], stats: {}, facets: { 'color' => { 'Red' => 2, 'Blue' => 1 } }, total: 3, page: 1, per_page: Workarea.config.per_page } }
87
92
  defaults.product_browse_search_options = Proc.new { { products: [create_product, create_product, create_product], stats: {}, facets: { 'color' => { 'Red' => 2, 'Blue' => 1 } }, total: 3, page: 1, per_page: Workarea.config.per_page } }
88
93
 
94
+ # factories/segments.rb
95
+ defaults.segment = Proc.new { { name: 'Philadelphians', rules: [{ _type: 'Workarea::Segment::Rules::Geolocation', locations: %w(Philadelphia) }] } }
96
+
89
97
  # factories/user.rb
90
98
  defaults.user = Proc.new { { email: "user#{user_count}@workarea.com", password: 'W3bl1nc!', first_name: 'Ben', last_name: 'Crouse' } }
99
+
100
+ # factories/fraud_decision.rb
101
+ defaults.fraud_decision = { decision: :no_decision, message: 'Workarea default fraud check.' }
@@ -0,0 +1,27 @@
1
+ module Workarea
2
+ module HeadlessChrome
3
+ extend self
4
+
5
+ def options
6
+ Workarea.config.headless_chrome_options.merge(env_options).merge(args: args)
7
+ end
8
+
9
+ def env_options
10
+ parsed = if ENV['WORKAREA_HEADLESS_CHROME_OPTIONS'].blank?
11
+ {}
12
+ else
13
+ JSON.parse(ENV['WORKAREA_HEADLESS_CHROME_OPTIONS'])
14
+ end
15
+
16
+ parsed.symbolize_keys
17
+ end
18
+
19
+ def args
20
+ (Workarea.config.headless_chrome_args + env_args).uniq
21
+ end
22
+
23
+ def env_args
24
+ ENV['WORKAREA_HEADLESS_CHROME_ARGS'].to_s.split
25
+ end
26
+ end
27
+ end
@@ -16,6 +16,7 @@ end
16
16
  module Workarea
17
17
  class ViewTest < ActionView::TestCase
18
18
  extend TestCase::Decoration
19
+ include TestCase::Configuration
19
20
  include TestCase::RunnerLocation
20
21
  include Factories
21
22
  include TestCase::Workers
@@ -26,5 +26,6 @@ Gem::Specification.new do |s|
26
26
  s.add_dependency 'mocha', '~> 1.3.0'
27
27
  s.add_dependency 'selenium-webdriver', '~> 3.142'
28
28
  s.add_dependency 'webdrivers', '~> 3.0'
29
+ s.add_dependency 'capybara-chromedriver-logger', '~> 0.2.1'
29
30
  s.add_dependency 'minitest-retry', '~> 0.1.5'
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workarea-testing
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.45
4
+ version: 3.5.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Crouse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-20 00:00:00.000000000 Z
11
+ date: 2019-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: workarea-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.4.45
19
+ version: 3.5.0.beta.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.4.45
26
+ version: 3.5.0.beta.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: capybara
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '3.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: capybara-chromedriver-logger
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.2.1
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.2.1
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: minitest-retry
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -172,6 +186,7 @@ extensions: []
172
186
  extra_rdoc_files: []
173
187
  files:
174
188
  - LICENSE
189
+ - LICENSE.txt
175
190
  - README.md
176
191
  - app/assets/javascripts/workarea/admin/spec_helper.js
177
192
  - app/assets/javascripts/workarea/core/feature_test_helper.js
@@ -185,6 +200,7 @@ files:
185
200
  - lib/workarea/core/navigable_test.rb
186
201
  - lib/workarea/generator_test.rb
187
202
  - lib/workarea/integration_test.rb
203
+ - lib/workarea/mailer_test.rb
188
204
  - lib/workarea/performance_test.rb
189
205
  - lib/workarea/storefront/breakpoint_helpers.rb
190
206
  - lib/workarea/storefront/catalog_customization_test_class.rb
@@ -195,6 +211,7 @@ files:
195
211
  - lib/workarea/system_test.rb
196
212
  - lib/workarea/test_case.rb
197
213
  - lib/workarea/test_help.rb
214
+ - lib/workarea/testing/capybara_chromedriver_logger_collector.decorator
198
215
  - lib/workarea/testing/cassette_persister.rb
199
216
  - lib/workarea/testing/custom_capybara_matchers.rb
200
217
  - lib/workarea/testing/decoration_reporter.rb
@@ -218,8 +235,10 @@ files:
218
235
  - lib/workarea/testing/factories/pricing.rb
219
236
  - lib/workarea/testing/factories/recommendation.rb
220
237
  - lib/workarea/testing/factories/search.rb
238
+ - lib/workarea/testing/factories/segment.rb
221
239
  - lib/workarea/testing/factories/user.rb
222
240
  - lib/workarea/testing/factory_configuration.rb
241
+ - lib/workarea/testing/headless_chrome.rb
223
242
  - lib/workarea/testing/indexes.rb
224
243
  - lib/workarea/testing/locale_routing_fixes.rb
225
244
  - lib/workarea/testing/product_image.jpg
@@ -243,11 +262,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
243
262
  version: 2.3.0
244
263
  required_rubygems_version: !ruby/object:Gem::Requirement
245
264
  requirements:
246
- - - ">="
265
+ - - ">"
247
266
  - !ruby/object:Gem::Version
248
- version: '0'
267
+ version: 1.3.1
249
268
  requirements: []
250
- rubygems_version: 3.2.3
269
+ rubygems_version: 3.0.6
251
270
  signing_key:
252
271
  specification_version: 4
253
272
  summary: Testing tools for the Workarea Commerce Platform