workarea-storefront 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.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +52 -0
  3. data/app/assets/javascripts/workarea/storefront/application.js.erb +2 -12
  4. data/app/assets/javascripts/workarea/storefront/config.js.erb +0 -5
  5. data/app/assets/javascripts/workarea/storefront/modules/{analytics.js → analytics.js.erb} +17 -0
  6. data/app/assets/javascripts/workarea/storefront/modules/dialog_buttons.js +1 -1
  7. data/app/assets/javascripts/workarea/storefront/modules/workarea_analytics.js +4 -0
  8. data/app/assets/stylesheets/workarea/storefront/application.scss.erb +0 -2
  9. data/app/assets/stylesheets/workarea/storefront/email/_base.scss +9 -1
  10. data/app/assets/stylesheets/workarea/storefront/email/_components.scss +1 -1
  11. data/app/assets/stylesheets/workarea/storefront/email/_helpers.scss +16 -0
  12. data/app/assets/stylesheets/workarea/storefront/email/{_settings.scss → _settings.scss.erb} +1 -1
  13. data/app/controllers/workarea/storefront/analytics_controller.rb +36 -21
  14. data/app/controllers/workarea/storefront/application_controller.rb +2 -4
  15. data/app/controllers/workarea/storefront/cart_items_controller.rb +1 -2
  16. data/app/controllers/workarea/storefront/checkout/addresses_controller.rb +0 -2
  17. data/app/controllers/workarea/storefront/checkouts_controller.rb +6 -4
  18. data/app/controllers/workarea/storefront/content_areas_controller.rb +1 -0
  19. data/app/controllers/workarea/storefront/content_blocks_controller.rb +1 -0
  20. data/app/controllers/workarea/storefront/current_checkout.rb +20 -14
  21. data/app/controllers/workarea/storefront/downloads_controller.rb +18 -0
  22. data/app/controllers/workarea/storefront/email_signups_controller.rb +1 -0
  23. data/app/controllers/workarea/storefront/errors_controller.rb +6 -0
  24. data/app/controllers/workarea/storefront/recent_views_controller.rb +2 -35
  25. data/app/controllers/workarea/storefront/recommendations_controller.rb +2 -2
  26. data/app/controllers/workarea/storefront/searches_controller.rb +0 -11
  27. data/app/controllers/workarea/storefront/users/accounts_controller.rb +2 -7
  28. data/app/controllers/workarea/storefront/users/credit_cards_controller.rb +5 -2
  29. data/app/controllers/workarea/storefront/users/passwords_controller.rb +1 -5
  30. data/app/helpers/workarea/storefront/application_helper.rb +19 -3
  31. data/app/helpers/workarea/storefront/content_helper.rb +1 -1
  32. data/app/helpers/workarea/storefront/favicons_helper.rb +6 -7
  33. data/app/helpers/workarea/storefront/navigation_helper.rb +10 -0
  34. data/app/helpers/workarea/storefront/schema_org_helper.rb +156 -0
  35. data/app/mailers/workarea/storefront/application_mailer.rb +1 -0
  36. data/app/view_models/workarea/storefront/category_view_model.rb +2 -2
  37. data/app/view_models/workarea/storefront/content_block_view_model.rb +41 -10
  38. data/app/view_models/workarea/storefront/content_blocks/product_insights_view_model.rb +1 -1
  39. data/app/view_models/workarea/storefront/display_content.rb +3 -1
  40. data/app/view_models/workarea/storefront/inquiry_view_model.rb +1 -7
  41. data/app/view_models/workarea/storefront/inventory_status_view_model.rb +10 -6
  42. data/app/view_models/workarea/storefront/order_item_view_model.rb +14 -0
  43. data/app/view_models/workarea/storefront/product_view_model.rb +22 -4
  44. data/app/view_models/workarea/storefront/recommendations_view_model.rb +8 -4
  45. data/app/view_models/workarea/storefront/search_view_model.rb +1 -1
  46. data/app/view_models/workarea/storefront/user_activity_view_model.rb +6 -17
  47. data/app/views/layouts/workarea/storefront/application.html.haml +13 -17
  48. data/app/views/layouts/workarea/storefront/checkout.html.haml +1 -1
  49. data/app/views/layouts/workarea/storefront/content_preview.html.haml +1 -0
  50. data/app/views/layouts/workarea/storefront/email.html.haml +33 -26
  51. data/app/views/layouts/workarea/storefront/empty.html.haml +1 -0
  52. data/app/views/layouts/workarea/storefront/navigation.html.haml +1 -1
  53. data/app/views/workarea/storefront/account_mailer/creation.html.haml +2 -0
  54. data/app/views/workarea/storefront/account_mailer/password_reset.html.haml +2 -0
  55. data/app/views/workarea/storefront/cart_items/create.html.haml +1 -1
  56. data/app/views/workarea/storefront/carts/show.html.haml +1 -1
  57. data/app/views/workarea/storefront/categories/show.html.haml +3 -2
  58. data/app/views/workarea/storefront/checkouts/confirmation.html.haml +1 -1
  59. data/app/views/workarea/storefront/contacts/show.html.haml +4 -2
  60. data/app/views/workarea/storefront/content_areas/show.html.haml +1 -0
  61. data/app/views/workarea/storefront/content_blocks/_category_summary.html.haml +2 -1
  62. data/app/views/workarea/storefront/content_blocks/_product_insights.html.haml +2 -1
  63. data/app/views/workarea/storefront/content_blocks/_product_list.html.haml +2 -1
  64. data/app/views/workarea/storefront/errors/show.html.haml +1 -0
  65. data/app/views/workarea/storefront/fulfillment_mailer/shipped.html.haml +3 -1
  66. data/app/views/workarea/storefront/order_mailer/_summary.html.haml +6 -0
  67. data/app/views/workarea/storefront/order_mailer/confirmation.html.haml +3 -0
  68. data/app/views/workarea/storefront/order_mailer/reminder.html.haml +3 -0
  69. data/app/views/workarea/storefront/orders/_summary.html.haml +3 -1
  70. data/app/views/workarea/storefront/orders/show.html.haml +3 -3
  71. data/app/views/workarea/storefront/pages/home_page.html.haml +4 -0
  72. data/app/views/workarea/storefront/pages/robots.text.erb +0 -1
  73. data/app/views/workarea/storefront/pages/show.html.haml +1 -0
  74. data/app/views/workarea/storefront/products/_price.html.haml +1 -2
  75. data/app/views/workarea/storefront/products/_pricing.html.haml +12 -6
  76. data/app/views/workarea/storefront/products/_summary.html.haml +3 -3
  77. data/app/views/workarea/storefront/products/show.html.haml +6 -4
  78. data/app/views/workarea/storefront/products/templates/_generic.html.haml +5 -5
  79. data/app/views/workarea/storefront/products/templates/_option_selects.html.haml +5 -7
  80. data/app/views/workarea/storefront/products/templates/_option_thumbnails.html.haml +5 -7
  81. data/app/views/workarea/storefront/recent_views/aside.html.haml +3 -10
  82. data/app/views/workarea/storefront/recent_views/narrow.html.haml +3 -10
  83. data/app/views/workarea/storefront/recent_views/show.html.haml +3 -10
  84. data/app/views/workarea/storefront/recommendations/show.html.haml +1 -1
  85. data/app/views/workarea/storefront/searches/show.html.haml +4 -5
  86. data/app/views/workarea/storefront/users/accounts/edit.html.haml +3 -3
  87. data/app/views/workarea/storefront/users/accounts/show.html.haml +3 -3
  88. data/app/views/workarea/storefront/users/addresses/edit.html.haml +3 -3
  89. data/app/views/workarea/storefront/users/addresses/new.html.haml +3 -3
  90. data/app/views/workarea/storefront/users/credit_cards/edit.html.haml +3 -3
  91. data/app/views/workarea/storefront/users/credit_cards/new.html.haml +3 -3
  92. data/app/views/workarea/storefront/users/orders/index.html.haml +3 -3
  93. data/app/views/workarea/storefront/users/orders/show.html.haml +4 -4
  94. data/app/views/workarea/storefront/users/passwords/new.html.haml +3 -3
  95. data/config/locales/en.yml +16 -3
  96. data/config/routes.rb +4 -2
  97. data/test/dummy/config/initializers/session_store.rb +1 -1
  98. data/test/helpers/workarea/storefront/content_helper_test.rb +1 -0
  99. data/test/helpers/workarea/storefront/navigation_helper_test.rb +4 -0
  100. data/test/helpers/workarea/storefront/schema_org_helper_test.rb +27 -0
  101. data/test/integration/workarea/storefront/analytics_integration_test.rb +44 -4
  102. data/test/integration/workarea/storefront/cart_items_integration_test.rb +0 -12
  103. data/test/integration/workarea/storefront/categories_integration_test.rb +0 -10
  104. data/test/integration/workarea/storefront/checkout_side_effects_integration_test.rb +15 -1
  105. data/test/integration/workarea/storefront/checkouts_integration_test.rb +68 -11
  106. data/test/integration/workarea/storefront/contact_form_integration_test.rb +18 -20
  107. data/test/integration/workarea/storefront/content_blocks_integration_test.rb +1 -4
  108. data/test/integration/workarea/storefront/current_checkout_integration_test.rb +53 -2
  109. data/test/integration/workarea/storefront/downloads_integration_test.rb +38 -0
  110. data/test/integration/workarea/storefront/email_signups_integration_test.rb +2 -0
  111. data/test/integration/workarea/storefront/guest_browsing_integration_test.rb +2 -2
  112. data/test/integration/workarea/storefront/impersonations_integration_test.rb +2 -2
  113. data/test/integration/workarea/storefront/login_integration_test.rb +3 -9
  114. data/test/integration/workarea/storefront/order_data_integration_test.rb +1 -9
  115. data/test/integration/workarea/storefront/place_order_integration_test.rb +5 -7
  116. data/test/integration/workarea/storefront/placing_order_integration_test.rb +1 -1
  117. data/test/integration/workarea/storefront/recent_views_integration_test.rb +29 -0
  118. data/test/integration/workarea/storefront/releases_integration_test.rb +132 -0
  119. data/test/integration/workarea/storefront/search_integration_test.rb +0 -46
  120. data/test/integration/workarea/storefront/segment_overrides_integration_test.rb +48 -0
  121. data/test/integration/workarea/storefront/segments_integration_test.rb +250 -0
  122. data/test/integration/workarea/storefront/store_credit_integration_test.rb +1 -1
  123. data/test/integration/workarea/storefront/users/credit_cards_integration_test.rb +2 -2
  124. data/test/integration/workarea/storefront/users/passwords_integration_test.rb +0 -19
  125. data/test/javascripts/traffic_referrer_spec.js +1 -1
  126. data/test/mailers/workarea/storefront/transactional_mailer_test.rb +9 -13
  127. data/test/system/workarea/storefront/analytics_system_test.rb +54 -40
  128. data/test/system/workarea/storefront/content_system_test.rb +10 -1
  129. data/test/system/workarea/storefront/digital_products_system_test.rb +2 -0
  130. data/test/system/workarea/storefront/download_system_test.rb +145 -0
  131. data/test/system/workarea/storefront/guest_checkout_system_test.rb +20 -0
  132. data/test/system/workarea/storefront/logged_in_checkout_system_test.rb +31 -32
  133. data/test/system/workarea/storefront/passwords_system_test.rb +35 -37
  134. data/test/system/workarea/storefront/pricing_overrides_system_test.rb +13 -2
  135. data/test/system/workarea/storefront/segment_overrides_system_test.rb +69 -0
  136. data/test/view_models/workarea/storefront/category_view_model_test.rb +20 -0
  137. data/test/view_models/workarea/storefront/content_block_view_model_test.rb +135 -3
  138. data/test/view_models/workarea/storefront/display_content_test.rb +4 -0
  139. data/test/view_models/workarea/storefront/product_view_model/option_set_test.rb +7 -8
  140. data/test/view_models/workarea/storefront/product_view_model_test.rb +17 -10
  141. data/test/view_models/workarea/storefront/search_view_model_test.rb +0 -6
  142. data/test/view_models/workarea/storefront/user_activity_view_model_test.rb +18 -20
  143. metadata +20 -22
  144. data/app/assets/javascripts/workarea/storefront/modules/recent_views.js +0 -25
  145. data/app/assets/javascripts/workarea/storefront/modules/search_fields.js +0 -59
  146. data/app/assets/javascripts/workarea/storefront/templates/ui_menu_heading.jst.ejs +0 -1
  147. data/app/assets/javascripts/workarea/storefront/templates/ui_menu_item.jst.ejs +0 -8
  148. data/app/assets/stylesheets/jquery_ui/storefront/_ui_autocomplete.scss +0 -17
  149. data/app/assets/stylesheets/jquery_ui/storefront/_ui_menu.scss +0 -40
  150. data/app/controllers/workarea/storefront/http_caching.rb +0 -33
  151. data/app/controllers/workarea/storefront/user_activity.rb +0 -19
  152. data/app/view_models/workarea/storefront/search_suggestion_view_model.rb +0 -87
  153. data/app/views/workarea/storefront/searches/index.json.jbuilder +0 -1
  154. data/app/views/workarea/storefront/style_guides/components/_ui_autocomplete.html.haml +0 -11
  155. data/test/dummy/tmp/screenshots/.keep +0 -0
  156. data/test/view_models/workarea/storefront/search_suggestion_view_model_test.rb +0 -42
@@ -98,7 +98,7 @@ module Workarea
98
98
  assert_equal('Test Card', payment.credit_card.issuer)
99
99
  assert_equal('XXXX-XXXX-XXXX-1', payment.credit_card.display_number)
100
100
  assert_equal(1, payment.credit_card.month)
101
- assert_equal(next_year, payment.credit_card.year)
101
+ assert_equal(2020, payment.credit_card.year)
102
102
  assert_equal(13.19.to_m, payment.credit_card.amount)
103
103
  refute(payment.credit_card.token.blank?)
104
104
  assert_equal(1, payment.credit_card.transactions.length)
@@ -49,14 +49,14 @@ module Workarea
49
49
  params: {
50
50
  credit_card: {
51
51
  month: '2',
52
- year: next_year.to_s,
52
+ year: '2020',
53
53
  cvv: '999'
54
54
  }
55
55
  }
56
56
 
57
57
  credit_card.reload
58
58
  assert_equal(2, credit_card.month)
59
- assert_equal(next_year, credit_card.year)
59
+ assert_equal(2020, credit_card.year)
60
60
  end
61
61
 
62
62
  def test_removes_credit_cards
@@ -31,7 +31,6 @@ module Workarea
31
31
 
32
32
  def test_handles_a_missing_password_reset
33
33
  get storefront.reset_password_path(token: 'foo')
34
- assert(flash[:error].present?)
35
34
  assert_redirected_to(storefront.forgot_password_path)
36
35
  end
37
36
 
@@ -43,24 +42,6 @@ module Workarea
43
42
  assert(flash[:error].present?)
44
43
  assert(response.redirect?)
45
44
  end
46
-
47
- def test_expired_resets
48
- post storefront.forgot_password_path, params: { email: 'passwords@workarea.com' }
49
- first = User::PasswordReset.desc(:created_at).first
50
-
51
- get storefront.reset_password_path(token: first.token)
52
- assert(response.ok?)
53
-
54
- post storefront.forgot_password_path, params: { email: 'passwords@workarea.com' }
55
- second = User::PasswordReset.desc(:created_at).first
56
-
57
- get storefront.reset_password_path(token: second.token)
58
- assert(response.ok?)
59
-
60
- get storefront.reset_password_path(token: first.token)
61
- assert(flash[:error].present?)
62
- assert_redirected_to(storefront.forgot_password_path)
63
- end
64
45
  end
65
46
  end
66
47
  end
@@ -15,7 +15,7 @@
15
15
  });
16
16
 
17
17
  it('does not set a cookie when host matches referrer', function () {
18
- WORKAREA.trafficReferrer.setReferrer(window.location.origin);
18
+ WORKAREA.trafficReferrer.setReferrer('http://127.0.0.1');
19
19
 
20
20
  WORKAREA.trafficReferrer.setCookie();
21
21
  expect(WORKAREA.cookie.read('workarea_referrer')).to.equal(null);
@@ -2,27 +2,23 @@ require 'test_helper'
2
2
 
3
3
  module Workarea
4
4
  module Storefront
5
- class TransactionalMailerTest < Workarea::IntegrationTest
5
+ class TransactionalMailerTest < MailerTest
6
6
  def test_enabled_transactional_emails
7
- Workarea.with_config do |config|
8
- config.send_transactional_emails = true
7
+ Workarea.config.send_transactional_emails = true
9
8
 
10
- order = create_placed_order
11
- OrderMailer.confirmation(order.id).deliver_now
9
+ order = create_placed_order
10
+ OrderMailer.confirmation(order.id).deliver_now
12
11
 
13
- assert(ActionMailer::Base.deliveries.last.present?)
14
- end
12
+ assert_emails(1)
15
13
  end
16
14
 
17
15
  def test_disabling_transactionl_email
18
- Workarea.with_config do |config|
19
- config.send_transactional_emails = false
16
+ Workarea.config.send_transactional_emails = false
20
17
 
21
- order = create_placed_order
22
- OrderMailer.confirmation(order.id).deliver_now
18
+ order = create_placed_order
19
+ OrderMailer.confirmation(order.id).deliver_now
23
20
 
24
- assert_nil(ActionMailer::Base.deliveries.last)
25
- end
21
+ assert_no_emails
26
22
  end
27
23
  end
28
24
  end
@@ -144,7 +144,7 @@ module Workarea
144
144
  def test_announcing_product_click_event
145
145
  visit storefront.category_path(@category)
146
146
 
147
- disable_dom_events
147
+ disable_analytics_dom_events
148
148
  within '.product-summary__name', match: :first do
149
149
  click_link 'Test Product 2'
150
150
  end
@@ -163,25 +163,6 @@ module Workarea
163
163
  assert_page_view
164
164
  end
165
165
 
166
- def test_announcing_product_click_event_search_type_ahead
167
- @products.each { |p| Search::Storefront::Product.new(p).save }
168
- visit storefront.root_path
169
- disable_dom_events
170
-
171
- page.evaluate_script('$("#storefront_search").categorizedAutocomplete("search", "test");')
172
-
173
- find('li', text: 'Test Product 1').click
174
-
175
- events = find_analytics_events(for_event: 'productClick')
176
- assert_equal(1, events.count)
177
- payload = events.first['arguments'].first
178
-
179
- assert_equal('PROD1', payload['id'])
180
- assert_equal('Test Product 1', payload['name'])
181
- assert_equal(false, payload['sale'])
182
- assert_equal(10, payload['price'])
183
- end
184
-
185
166
  def test_announcing_add_to_cart_event
186
167
  visit storefront.product_path(@products.second)
187
168
 
@@ -210,7 +191,7 @@ module Workarea
210
191
 
211
192
  visit storefront.cart_path
212
193
 
213
- disable_dom_events
194
+ disable_analytics_dom_events
214
195
  fill_in 'quantity', with: '1'
215
196
 
216
197
  events = find_analytics_events(for_event: 'updateCartItem')
@@ -236,7 +217,7 @@ module Workarea
236
217
  click_button t('workarea.storefront.products.add_to_cart')
237
218
  click_link t('workarea.storefront.carts.view_cart')
238
219
 
239
- disable_dom_events
220
+ disable_analytics_dom_events
240
221
  click_button t('workarea.storefront.carts.remove')
241
222
 
242
223
  events = find_analytics_events(for_event: 'removeFromCart')
@@ -487,7 +468,7 @@ module Workarea
487
468
 
488
469
  fill_in 'footer_email_signup_field', with: 'foo@bar.com'
489
470
 
490
- disable_dom_events
471
+ disable_analytics_dom_events
491
472
  click_button t('workarea.storefront.users.join')
492
473
 
493
474
  events = find_analytics_events(for_event: 'emailSignup')
@@ -502,7 +483,7 @@ module Workarea
502
483
 
503
484
  visit storefront.checkout_path
504
485
 
505
- disable_dom_events
486
+ disable_analytics_dom_events
506
487
  click_link t('workarea.storefront.users.login')
507
488
 
508
489
  events = find_analytics_events(for_event: 'checkoutLogin')
@@ -526,7 +507,7 @@ module Workarea
526
507
 
527
508
  fill_in 'password', with: 'W3bl1nc!'
528
509
 
529
- disable_dom_events
510
+ disable_analytics_dom_events
530
511
  click_button t('workarea.storefront.users.create_account')
531
512
 
532
513
  events = find_analytics_events(for_event: 'checkoutSignup')
@@ -543,7 +524,7 @@ module Workarea
543
524
  fill_in 'email', with: 'bcrouse@workarea.com'
544
525
  fill_in 'password', with: 'W3bl1nc!'
545
526
 
546
- disable_dom_events
527
+ disable_analytics_dom_events
547
528
  click_button t('workarea.storefront.users.login')
548
529
  end
549
530
 
@@ -559,7 +540,7 @@ module Workarea
559
540
  within '#forgot_password_form' do
560
541
  fill_in 'email', with: 'bcrouse@workarea.com'
561
542
 
562
- disable_dom_events
543
+ disable_analytics_dom_events
563
544
  click_button t('workarea.storefront.forms.send')
564
545
  end
565
546
 
@@ -576,7 +557,7 @@ module Workarea
576
557
  fill_in 'email', with: 'bcrouse@workarea.com'
577
558
  fill_in 'password', with: 'W3bl1nc!'
578
559
 
579
- disable_dom_events
560
+ disable_analytics_dom_events
580
561
  click_button t('workarea.storefront.users.create_account')
581
562
  end
582
563
 
@@ -592,7 +573,7 @@ module Workarea
592
573
 
593
574
  visit storefront.root_path
594
575
 
595
- disable_dom_events
576
+ disable_analytics_dom_events
596
577
  click_link 'First Level'
597
578
 
598
579
  events = find_analytics_events(for_event: 'primaryNavigationClick')
@@ -612,7 +593,7 @@ module Workarea
612
593
  fill_in_shipping_address
613
594
  click_button t('workarea.storefront.checkouts.continue_to_shipping')
614
595
 
615
- disable_dom_events
596
+ disable_analytics_dom_events
616
597
  click_link t('workarea.storefront.forms.edit')
617
598
 
618
599
  events = find_analytics_events(for_event: 'checkoutEdit')
@@ -700,25 +681,58 @@ module Workarea
700
681
  assert_equal('Home Page Content Block', payload['data']['html'])
701
682
  end
702
683
 
703
- private
684
+ def test_sessions
685
+ create_life_cycle_segments
704
686
 
705
- def find_analytics_events(for_event: nil)
706
- all_events = page.evaluate_script('WORKAREA.analytics.events')
687
+ visit storefront.root_path
688
+ assert_equal(1, find_analytics_events(for_event: 'newSession').size)
689
+ assert_equal(1, Metrics::SalesByDay.today.sessions)
690
+ assert_equal(1, Metrics::SegmentByDay.find_by(segment_id: 'first_time_visitor').sessions)
707
691
 
708
- if for_event.blank?
709
- all_events
710
- else
711
- all_events.select { |e| e['name'] == for_event }
712
- end
692
+ visit storefront.category_path(@category)
693
+ assert_equal(0, find_analytics_events(for_event: 'newSession').size)
694
+ assert_equal(1, Metrics::SalesByDay.today.sessions)
695
+ assert_equal(1, Metrics::SegmentByDay.find_by(segment_id: 'first_time_visitor').sessions)
696
+
697
+ expire_analytics_session
698
+ visit storefront.root_path
699
+ assert_equal(1, find_analytics_events(for_event: 'newSession').size)
700
+ assert_equal(2, Metrics::SalesByDay.today.sessions)
701
+ assert_equal(1, Metrics::SegmentByDay.find_by(segment_id: 'first_time_visitor').sessions)
702
+ assert_equal(1, Metrics::SegmentByDay.find_by(segment_id: 'returning_visitor').sessions)
703
+
704
+ setup_checkout_specs
705
+ add_user_data
706
+ start_guest_checkout
707
+
708
+ fill_in_email
709
+ fill_in_shipping_address
710
+ click_button t('workarea.storefront.checkouts.continue_to_shipping')
711
+ click_button t('workarea.storefront.checkouts.continue_to_payment')
712
+
713
+ fill_in_credit_card
714
+ click_button t('workarea.storefront.checkouts.place_order')
715
+ assert_current_path(storefront.checkout_confirmation_path)
716
+
717
+ expire_analytics_session
718
+ visit storefront.root_path
719
+ assert_equal(1, find_analytics_events(for_event: 'newSession').size)
720
+ assert_equal(3, Metrics::SalesByDay.today.sessions)
721
+ assert_equal(1, Metrics::SegmentByDay.find_by(segment_id: 'first_time_visitor').sessions)
722
+ assert_equal(1, Metrics::SegmentByDay.find_by(segment_id: 'returning_visitor').sessions)
723
+ assert_equal(1, Metrics::SegmentByDay.find_by(segment_id: 'first_time_customer').sessions)
713
724
  end
714
725
 
726
+ private
727
+
715
728
  def assert_page_view
716
729
  page_view = find_analytics_events(for_event: 'pageView')
717
730
  assert_equal(1, page_view.count)
718
731
  end
719
732
 
720
- def disable_dom_events
721
- page.execute_script('WORKAREA.analytics.disableDomEvents();')
733
+ def expire_analytics_session
734
+ # Simulate session expiration where this cookie would disappear
735
+ page.execute_script("WORKAREA.cookie.destroy('analytics_session');")
722
736
  end
723
737
  end
724
738
  end
@@ -20,7 +20,7 @@ module Workarea
20
20
  product1 = create_product(name: 'PL Product 1')
21
21
  product2 = create_product(name: 'PL Product 2')
22
22
 
23
- asset = create_asset
23
+ asset = create_asset(alt_text: 'Foobarbq')
24
24
 
25
25
  content = Content.for(@content_page)
26
26
  content.blocks.build(
@@ -35,6 +35,13 @@ module Workarea
35
35
  type: :image,
36
36
  data: { image: asset.id }
37
37
  )
38
+ content.blocks.build(
39
+ type: :image,
40
+ data: {
41
+ image: asset.id,
42
+ alt: 'Corgenator'
43
+ }
44
+ )
38
45
  content.blocks.build(
39
46
  type: :hero,
40
47
  data: {
@@ -65,6 +72,8 @@ module Workarea
65
72
  assert(page.has_content?('test html'))
66
73
  assert(page.has_content?('text'))
67
74
  assert(page.has_content?('foo headline'))
75
+ assert_match(/alt.*Foobarbq/, page.html)
76
+ assert_match(/alt.*Corgenator/, page.html)
68
77
  assert_match(/iframe/, page.html)
69
78
  assert(page.has_content?('Test Standard Category'))
70
79
  page.all(:css, '.category-summary-content-block').each do |el|
@@ -2,6 +2,8 @@ require 'test_helper'
2
2
 
3
3
  module Workarea
4
4
  module Storefront
5
+ # TODO: delete this for v3.6
6
+ # Leaving this in v3.5 for compatibility with existing builds
5
7
  class DigitalProductsSystemTest < Workarea::SystemTest
6
8
  include Storefront::SystemTest
7
9
 
@@ -0,0 +1,145 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Storefront
5
+ class DownloadSystemTest < Workarea::SystemTest
6
+ include Storefront::SystemTest
7
+
8
+ def test_checking_out_with_downloadable_product
9
+ setup_checkout_specs
10
+
11
+ Order.first.items.delete_all
12
+
13
+ product = create_product(
14
+ name: 'Digital Product',
15
+ variants: [
16
+ { sku: 'SKU1', regular: 10.to_m, tax_code: '001' },
17
+ { sku: 'SKU2', regular: 15.to_m, tax_code: '001' }
18
+ ]
19
+ )
20
+
21
+ create_fulfillment_sku(id: 'SKU1', policy: :download, file: product_image_file)
22
+ create_fulfillment_sku(id: 'SKU2', policy: :download, file: product_image_file)
23
+
24
+ visit storefront.product_path(product)
25
+
26
+ within '.product-details__add-to-cart-form' do
27
+ select product.skus.first, from: 'sku'
28
+ click_button t('workarea.storefront.products.add_to_cart')
29
+ end
30
+
31
+ assert(page.has_content?('Success'))
32
+
33
+ start_guest_checkout
34
+
35
+ assert_current_path(storefront.checkout_addresses_path)
36
+
37
+ fill_in_email
38
+ fill_in_billing_address
39
+ click_button t('workarea.storefront.checkouts.continue_to_payment')
40
+
41
+ assert_current_path(storefront.checkout_payment_path)
42
+ assert(page.has_content?('Success'))
43
+
44
+ fill_in_credit_card
45
+ click_button t('workarea.storefront.checkouts.place_order')
46
+
47
+ assert_current_path(storefront.checkout_confirmation_path)
48
+ assert(page.has_content?('Success'))
49
+ assert(page.has_content?(t('workarea.storefront.flash_messages.order_placed')))
50
+ assert(page.has_content?(Order.first.id))
51
+
52
+ assert(page.has_content?('1019 S. 47th St.'))
53
+ assert(page.has_content?('Philadelphia'))
54
+ assert(page.has_content?('PA'))
55
+ assert(page.has_content?('19143'))
56
+
57
+ assert(page.has_content?('Test Card'))
58
+ assert(page.has_content?('XX-1'))
59
+
60
+ assert(page.has_content?('Digital Product'))
61
+ assert(page.has_content?('$10.00'))
62
+ assert(page.has_content?('$0.70'))
63
+ assert(page.has_content?('$10.70'))
64
+ assert(page.has_content?(t('workarea.storefront.orders.download')))
65
+ end
66
+
67
+ def test_order_not_requiring_shipping
68
+ setup_checkout_specs
69
+ start_guest_checkout
70
+
71
+ create_shipping_service(
72
+ name: 'Next Day',
73
+ tax_code: '001',
74
+ rates: [{ price: 20.to_m }]
75
+ )
76
+
77
+ assert_current_path(storefront.checkout_addresses_path)
78
+ fill_in_email
79
+ fill_in_shipping_address
80
+
81
+ uncheck 'same_as_shipping'
82
+ fill_in_billing_address
83
+
84
+ click_button t('workarea.storefront.checkouts.continue_to_shipping')
85
+
86
+ assert_current_path(storefront.checkout_shipping_path)
87
+ click_button t('workarea.storefront.checkouts.continue_to_payment')
88
+
89
+ assert_current_path(storefront.checkout_payment_path)
90
+ assert(page.has_content?('Success'))
91
+
92
+ visit storefront.checkout_shipping_path
93
+ choose "shipping_service_Next_Day"
94
+ click_button t('workarea.storefront.checkouts.continue_to_payment')
95
+
96
+ assert_current_path(storefront.checkout_payment_path)
97
+ assert(page.has_content?('Success'))
98
+
99
+ # switch to downloadable product
100
+
101
+ Order.first.items.delete_all
102
+
103
+ product = create_product(
104
+ name: 'Digital Product',
105
+ variants: [
106
+ { sku: 'SKU1', regular: 10.to_m },
107
+ { sku: 'SKU2', regular: 15.to_m }
108
+ ]
109
+ )
110
+
111
+ create_fulfillment_sku(id: 'SKU1', policy: :download, file: product_image_file)
112
+ create_fulfillment_sku(id: 'SKU2', policy: :download, file: product_image_file)
113
+
114
+ visit storefront.product_path(product)
115
+
116
+ within '.product-details__add-to-cart-form' do
117
+ select product.skus.first, from: 'sku'
118
+ click_button t('workarea.storefront.products.add_to_cart')
119
+ end
120
+
121
+ click_link t('workarea.storefront.carts.checkout')
122
+
123
+ assert_current_path(storefront.checkout_addresses_path)
124
+
125
+ fill_in_email
126
+ fill_in_billing_address
127
+ click_button t('workarea.storefront.checkouts.continue_to_payment')
128
+
129
+ assert_current_path(storefront.checkout_payment_path)
130
+ assert(page.has_content?('Success'))
131
+
132
+ assert(page.has_content?('1019 S. 47th St.'))
133
+ assert(page.has_content?('Philadelphia'))
134
+ assert(page.has_content?('PA'))
135
+ assert(page.has_content?('19143'))
136
+
137
+ assert(page.has_no_content?("#{t('workarea.storefront.orders.tax')} $1.40"))
138
+ assert(page.has_no_content?("#{t('workarea.storefront.orders.total')} $31.40"))
139
+ assert(page.has_content?("#{t('workarea.storefront.orders.shipping')} #{t('workarea.storefront.checkouts.not_applicable')}"))
140
+ assert(page.has_content?("#{t('workarea.storefront.orders.tax')} $0.00"))
141
+ assert(page.has_content?("#{t('workarea.storefront.orders.total')} $10.00"))
142
+ end
143
+ end
144
+ end
145
+ end