workarea-wish_lists 3.0.4
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 +7 -0
- data/.editorconfig +20 -0
- data/.eslintignore +2 -0
- data/.eslintrc +24 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
- data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.gitignore +15 -0
- data/.scss-lint.yml +188 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +610 -0
- data/CODE_OF_CONDUCT.md +3 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +6 -0
- data/LICENSE +52 -0
- data/README.md +58 -0
- data/Rakefile +53 -0
- data/app/assets/javascripts/workarea/storefront/wish_lists/modules/wish_list_button.js +35 -0
- data/app/assets/javascripts/workarea/storefront/wish_lists/modules/wish_list_public_quantity_fields.js +42 -0
- data/app/assets/javascripts/workarea/storefront/wish_lists/templates/hidden_input.jst.ejs +1 -0
- data/app/assets/stylesheets/workarea/storefront/wish_lists/components/_wish_list_button.scss +6 -0
- data/app/assets/stylesheets/workarea/storefront/wish_lists/components/_wish_lists.scss +24 -0
- data/app/controllers/workarea/admin/users_controller.decorator +20 -0
- data/app/controllers/workarea/storefront/users/wish_lists_controller.rb +128 -0
- data/app/controllers/workarea/storefront/wish_lists_controller.rb +22 -0
- data/app/models/workarea/wish_list.rb +212 -0
- data/app/models/workarea/wish_list/item.rb +76 -0
- data/app/models/workarea/wish_list/pricing.rb +14 -0
- data/app/models/workarea/wish_list/pricing/calculators/totals_calculator.rb +26 -0
- data/app/models/workarea/wish_list/public_search.rb +34 -0
- data/app/models/workarea/wish_list/request.rb +36 -0
- data/app/seeds/workarea/wish_list_seeds.rb +24 -0
- data/app/services/workarea/set_wish_list_details.rb +49 -0
- data/app/services/workarea/wish_list_session.rb +53 -0
- data/app/view_models/workarea/admin/user_view_model.decorator +12 -0
- data/app/view_models/workarea/storefront/user_view_model.decorator +31 -0
- data/app/view_models/workarea/storefront/wish_list_item_view_model.rb +35 -0
- data/app/view_models/workarea/storefront/wish_list_view_model.rb +75 -0
- data/app/views/layouts/workarea/storefront/_wish_lists_link.html.haml +6 -0
- data/app/views/workarea/admin/users/_wish_list_card.html.haml +24 -0
- data/app/views/workarea/admin/users/_wish_list_item_summary.html.haml +8 -0
- data/app/views/workarea/admin/users/wish_list.html.haml +26 -0
- data/app/views/workarea/storefront/carts/_move_to_wish_list.html.haml +4 -0
- data/app/views/workarea/storefront/products/_add_to_wish_list.html.haml +4 -0
- data/app/views/workarea/storefront/style_guides/_wish_lists_product_list_docs.html.haml +158 -0
- data/app/views/workarea/storefront/users/accounts/_wish_list_summary.html.haml +15 -0
- data/app/views/workarea/storefront/users/wish_lists/show.html.haml +125 -0
- data/app/views/workarea/storefront/wish_lists/_wish_lists_link.html.haml +4 -0
- data/app/views/workarea/storefront/wish_lists/index.html.haml +32 -0
- data/app/views/workarea/storefront/wish_lists/show.html.haml +97 -0
- data/app/workers/workarea/mark_wish_list_items_purchased.rb +18 -0
- data/app/workers/workarea/update_wish_list_details.rb +19 -0
- data/bin/rails +18 -0
- data/config/initializers/append_points.rb +46 -0
- data/config/initializers/configuration.rb +10 -0
- data/config/locales/en.yml +60 -0
- data/config/routes.rb +23 -0
- data/lib/workarea/testing/factories/wish_lists.rb +22 -0
- data/lib/workarea/wish_lists.rb +13 -0
- data/lib/workarea/wish_lists/engine.rb +15 -0
- data/lib/workarea/wish_lists/version.rb +5 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/config/application.rb +24 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +54 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +43 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/workarea.rb +5 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +3 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/workarea/storefront/wish_lists_integration_test.rb +211 -0
- data/test/models/workarea/wish_list/public_search_test.rb +82 -0
- data/test/models/workarea/wish_list_test.rb +158 -0
- data/test/services/workarea/set_wish_list_details_test.rb +62 -0
- data/test/services/workarea/wish_list_session_test.rb +47 -0
- data/test/system/workarea/admin/wish_lists_system_test.rb +46 -0
- data/test/system/workarea/storefront/wish_lists_system_test.rb +287 -0
- data/test/test_helper.rb +10 -0
- data/test/view_models/workarea/storefront/user_view_model_test.rb +46 -0
- data/test/view_models/workarea/storefront/wish_list_item_view_model_test.rb +47 -0
- data/test/view_models/workarea/storefront/wish_list_view_model_test.rb +74 -0
- data/test/workers/workarea/mark_wish_list_items_purchased_test.rb +21 -0
- data/workarea-wish_lists.gemspec +21 -0
- metadata +188 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Workarea
|
|
4
|
+
class SetWishListDetailsTest < TestCase
|
|
5
|
+
def test_perform
|
|
6
|
+
Sidekiq::Callbacks.disable(UpdateWishListDetails) do
|
|
7
|
+
wish_list = create_wish_list(user_id: nil)
|
|
8
|
+
SetWishListDetails.new(wish_list).perform # should raise no error
|
|
9
|
+
|
|
10
|
+
wish_list = create_wish_list(user_id: 'not_an_id')
|
|
11
|
+
SetWishListDetails.new(wish_list).perform # should raise no error
|
|
12
|
+
|
|
13
|
+
user = create_user(
|
|
14
|
+
first_name: nil,
|
|
15
|
+
last_name: nil,
|
|
16
|
+
email: 'test@workarea.com'
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
wish_list = WishList.for_user(user.id)
|
|
20
|
+
SetWishListDetails.new(wish_list).perform
|
|
21
|
+
|
|
22
|
+
assert_equal('test@workarea.com', wish_list.email)
|
|
23
|
+
assert_equal(wish_list.email, wish_list.name)
|
|
24
|
+
refute(wish_list.first_name.present?)
|
|
25
|
+
refute(wish_list.last_name.present?)
|
|
26
|
+
refute(wish_list.location.present?)
|
|
27
|
+
|
|
28
|
+
user.update_attributes!(
|
|
29
|
+
first_name: 'Foo',
|
|
30
|
+
last_name: 'Bar'
|
|
31
|
+
)
|
|
32
|
+
SetWishListDetails.new(wish_list).perform
|
|
33
|
+
|
|
34
|
+
assert_equal('test@workarea.com', wish_list.email)
|
|
35
|
+
assert_equal('Foo Bar', wish_list.name)
|
|
36
|
+
assert_equal('Foo', wish_list.first_name)
|
|
37
|
+
assert_equal('Bar', wish_list.last_name)
|
|
38
|
+
refute(wish_list.location.present?)
|
|
39
|
+
|
|
40
|
+
user.update_attributes!(
|
|
41
|
+
addresses: [{
|
|
42
|
+
first_name: 'Ben',
|
|
43
|
+
last_name: 'Crouse',
|
|
44
|
+
street: '22 S. 3rd St.',
|
|
45
|
+
street_2: 'Second Floor',
|
|
46
|
+
city: 'Philadelphia',
|
|
47
|
+
region: 'PA',
|
|
48
|
+
postal_code: '19106',
|
|
49
|
+
country: 'US'
|
|
50
|
+
}]
|
|
51
|
+
)
|
|
52
|
+
SetWishListDetails.new(wish_list).perform
|
|
53
|
+
|
|
54
|
+
assert_equal('test@workarea.com', wish_list.email)
|
|
55
|
+
assert_equal('Foo Bar', wish_list.name)
|
|
56
|
+
assert_equal('Foo', wish_list.first_name)
|
|
57
|
+
assert_equal('Bar', wish_list.last_name)
|
|
58
|
+
assert_equal('Philadelphia PA US 19106', wish_list.location)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Workarea
|
|
4
|
+
class WishListSessionTest < TestCase
|
|
5
|
+
def session
|
|
6
|
+
@seassion ||= {}
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def wish_list_session
|
|
10
|
+
@wish_list_session ||= WishListSession.new(session)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_store_item
|
|
14
|
+
item_id = BSON::ObjectId.new.to_s
|
|
15
|
+
params = {
|
|
16
|
+
'product_id' => '1',
|
|
17
|
+
'sku' => '2',
|
|
18
|
+
'quantity' => 1,
|
|
19
|
+
'item_id' => item_id
|
|
20
|
+
}
|
|
21
|
+
wish_list_session.store_item(params)
|
|
22
|
+
assert_equal(
|
|
23
|
+
{
|
|
24
|
+
'wish_list_item_id' => item_id,
|
|
25
|
+
'wish_list_product_id' => '1',
|
|
26
|
+
'wish_list_sku' => '2',
|
|
27
|
+
'wish_list_quantity' => 1
|
|
28
|
+
},
|
|
29
|
+
session
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_add_item
|
|
34
|
+
wish_list = create_wish_list
|
|
35
|
+
product = create_product(variants: [{ sku: 'SKU' }], details: { color: 'Red' })
|
|
36
|
+
|
|
37
|
+
session['wish_list_product_id'] = product.id
|
|
38
|
+
session['wish_list_sku'] = product.variants[0].sku
|
|
39
|
+
session['wish_list_quantity'] = 1
|
|
40
|
+
|
|
41
|
+
wish_list_session.add_item(wish_list)
|
|
42
|
+
assert_equal(1, wish_list.items.count)
|
|
43
|
+
assert({ 'color' => ['Red'] }, wish_list.items[0].product_attributes)
|
|
44
|
+
assert(session.blank?)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Workarea
|
|
4
|
+
module Admin
|
|
5
|
+
class WishListsSystemTest < Workarea::SystemTest
|
|
6
|
+
include Admin::IntegrationTest
|
|
7
|
+
|
|
8
|
+
def test_wish_list_viewing
|
|
9
|
+
user = create_user(email: 'bcrouse@workarea.com')
|
|
10
|
+
wish_list = WishList.find_or_create_by!(user_id: user.id)
|
|
11
|
+
|
|
12
|
+
products = Array.new(3) do |i|
|
|
13
|
+
product = create_product(
|
|
14
|
+
id: "PROD#{i}",
|
|
15
|
+
name: "Test Product #{i}",
|
|
16
|
+
variants: [{ sku: "SKU#{i}" }]
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
wish_list.add_item(product.id, product.variants.first.sku)
|
|
20
|
+
product
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
visit admin.user_path(user)
|
|
24
|
+
click_link t('workarea.admin.users.cards.wish_list.title')
|
|
25
|
+
|
|
26
|
+
assert(page.has_content?(products.first.name))
|
|
27
|
+
assert(page.has_content?(products.second.name))
|
|
28
|
+
assert(page.has_content?(products.third.name))
|
|
29
|
+
|
|
30
|
+
wish_list.items.first.update_attributes!(purchased: true)
|
|
31
|
+
|
|
32
|
+
visit admin.user_wish_list_path(user)
|
|
33
|
+
|
|
34
|
+
refute(page.has_content?(products.first.name))
|
|
35
|
+
assert(page.has_content?(products.second.name))
|
|
36
|
+
assert(page.has_content?(products.third.name))
|
|
37
|
+
|
|
38
|
+
select t('workarea.storefront.wish_lists.purchased_items'), from: :state
|
|
39
|
+
|
|
40
|
+
assert(page.has_content?(products.first.name))
|
|
41
|
+
refute(page.has_content?(products.second.name))
|
|
42
|
+
refute(page.has_content?(products.third.name))
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Workarea
|
|
4
|
+
module Storefront
|
|
5
|
+
class WishListsSystemTest < Workarea::SystemTest
|
|
6
|
+
include Storefront::SystemTest
|
|
7
|
+
|
|
8
|
+
setup :user, :product
|
|
9
|
+
|
|
10
|
+
def user
|
|
11
|
+
@user ||= create_user(
|
|
12
|
+
email: 'test@workarea.com',
|
|
13
|
+
password: 'w3bl1nc',
|
|
14
|
+
name: 'Ben Crouse'
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def product
|
|
19
|
+
@product ||= create_product(
|
|
20
|
+
name: 'Integration Product',
|
|
21
|
+
variants: [
|
|
22
|
+
{ sku: 'SKU1', regular: 10.to_m, sale: 5.to_m, on_sale: true, details: { 'color' => ['Red'] } },
|
|
23
|
+
{ sku: 'SKU2', details: { 'color' => ['Blue'] } }
|
|
24
|
+
]
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def add_to_wish_list(product)
|
|
29
|
+
visit storefront.product_path(product)
|
|
30
|
+
select 'SKU1'
|
|
31
|
+
click_link I18n.t('workarea.storefront.wish_lists.add_to_wish_list')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def login(email, password)
|
|
35
|
+
visit storefront.login_path
|
|
36
|
+
|
|
37
|
+
within '#login_form' do
|
|
38
|
+
fill_in 'email', with: email
|
|
39
|
+
fill_in 'password', with: password
|
|
40
|
+
click_button 'login'
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def search_wish_lists(query)
|
|
45
|
+
visit storefront.wish_lists_path
|
|
46
|
+
|
|
47
|
+
within '#find_wish_list_form' do
|
|
48
|
+
fill_in 'wish_list_query', with: query
|
|
49
|
+
click_button 'search'
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def set_wishlist_privacy(privacy)
|
|
54
|
+
wish_list = Workarea::WishList.first
|
|
55
|
+
wish_list.privacy = privacy
|
|
56
|
+
wish_list.save
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_managing_items
|
|
60
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
61
|
+
add_to_wish_list(product)
|
|
62
|
+
|
|
63
|
+
visit storefront.users_wish_list_path
|
|
64
|
+
assert(page.has_content?('Integration Product'))
|
|
65
|
+
assert(page.has_content?('Red'))
|
|
66
|
+
assert(page.has_content?('In Stock'))
|
|
67
|
+
assert(page.has_content?('$10.00'))
|
|
68
|
+
assert(page.has_content?('$5.00'))
|
|
69
|
+
|
|
70
|
+
click_button 'remove_item'
|
|
71
|
+
visit storefront.users_wish_list_path
|
|
72
|
+
assert(page.has_no_content?('Integration Product'))
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_toggle_between_purchased_and_unpurchased_items
|
|
76
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
77
|
+
add_to_wish_list(product)
|
|
78
|
+
|
|
79
|
+
visit storefront.users_wish_list_path
|
|
80
|
+
assert(page.has_content?('Integration Product'))
|
|
81
|
+
|
|
82
|
+
select I18n.t('workarea.storefront.wish_lists.purchased_items'), from: :state
|
|
83
|
+
assert(page.has_no_content?('Integration Product'))
|
|
84
|
+
|
|
85
|
+
select I18n.t('workarea.storefront.wish_lists.unpurchased_items'), from: :state
|
|
86
|
+
assert(page.has_content?('Integration Product'))
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def test_apply_variant_and_quantity_from_cart_form
|
|
90
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
91
|
+
|
|
92
|
+
visit storefront.product_path(product)
|
|
93
|
+
select 'SKU2'
|
|
94
|
+
fill_in 'quantity', with: '3'
|
|
95
|
+
click_link I18n.t('workarea.storefront.wish_lists.add_to_wish_list')
|
|
96
|
+
|
|
97
|
+
assert(page.has_content?('SKU2'))
|
|
98
|
+
assert(page.has_content?('Blue'))
|
|
99
|
+
assert(page.has_selector?('input[name="quantity"][value="3"]'))
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_cannot_add_if_cart_form_is_invalid
|
|
103
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
104
|
+
|
|
105
|
+
visit storefront.product_path(product)
|
|
106
|
+
click_link I18n.t('workarea.storefront.wish_lists.add_to_wish_list')
|
|
107
|
+
assert(page.has_content?('This field is required'))
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_add_item_to_wish_list_without_being_logged_in
|
|
111
|
+
add_to_wish_list(product)
|
|
112
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
113
|
+
|
|
114
|
+
visit storefront.users_account_path
|
|
115
|
+
assert(page.has_content?('Integration Product'))
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def test_updating_privacy
|
|
119
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
120
|
+
visit storefront.users_wish_list_path
|
|
121
|
+
|
|
122
|
+
choose 'privacy_shared'
|
|
123
|
+
assert(page.has_content?(Workarea::WishList.first.token))
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def test_finding_wish_list_by_name
|
|
127
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
128
|
+
add_to_wish_list(product)
|
|
129
|
+
search_wish_lists('Ben Crouse')
|
|
130
|
+
|
|
131
|
+
refute_text(t('workarea.storefront.searches.no_results', terms: 'Ben Crouse'))
|
|
132
|
+
|
|
133
|
+
within 'ol' do
|
|
134
|
+
assert(page.has_content?('Ben Crouse'))
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def test_finding_wish_list_by_email
|
|
139
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
140
|
+
add_to_wish_list(product)
|
|
141
|
+
search_wish_lists('test@workarea.com')
|
|
142
|
+
|
|
143
|
+
refute_text(t('workarea.storefront.searches.no_results', terms: 'test@workarea.com'))
|
|
144
|
+
|
|
145
|
+
within 'ol' do
|
|
146
|
+
assert(page.has_content?('Ben Crouse'))
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def test_viewing_a_wish_list
|
|
151
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
152
|
+
add_to_wish_list(product)
|
|
153
|
+
search_wish_lists('test@workarea.com')
|
|
154
|
+
click_link 'Ben Crouse'
|
|
155
|
+
|
|
156
|
+
assert(page.has_content?('Integration Product'))
|
|
157
|
+
assert(page.has_content?('In Stock'))
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def test_viewing_wish_list_summary_on_account_home
|
|
161
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
162
|
+
|
|
163
|
+
product = create_product(
|
|
164
|
+
name: 'Integration Product',
|
|
165
|
+
variants: [{ sku: 'SKU1', regular: 10.to_m }]
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
visit storefront.product_path(product)
|
|
169
|
+
click_link I18n.t('workarea.storefront.wish_lists.add_to_wish_list')
|
|
170
|
+
|
|
171
|
+
visit storefront.users_account_path
|
|
172
|
+
assert(page.has_content?('Integration Product'))
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def test_adding_item_to_cart_from_wish_list
|
|
176
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
177
|
+
|
|
178
|
+
product = create_product(
|
|
179
|
+
name: 'Integration Product',
|
|
180
|
+
variants: [{ sku: 'SKU1', regular: 10.to_m }]
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
visit storefront.product_path(product)
|
|
184
|
+
click_link I18n.t('workarea.storefront.wish_lists.add_to_wish_list')
|
|
185
|
+
|
|
186
|
+
visit storefront.users_wish_list_path
|
|
187
|
+
click_button 'add_to_cart', match: :first
|
|
188
|
+
|
|
189
|
+
assert(page.has_content?('Success'))
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def test_moving_an_item_from_cart_to_wish_list
|
|
193
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
194
|
+
|
|
195
|
+
product = create_product(
|
|
196
|
+
name: 'Integration Product',
|
|
197
|
+
variants: [{ sku: 'SKU1', regular: 10.to_m }]
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
visit storefront.product_path(product)
|
|
201
|
+
click_button 'add_to_cart'
|
|
202
|
+
wait_for_xhr
|
|
203
|
+
|
|
204
|
+
visit storefront.cart_path
|
|
205
|
+
click_button 'move_to_wish_list'
|
|
206
|
+
|
|
207
|
+
visit storefront.users_wish_list_path
|
|
208
|
+
assert(page.has_content?(product.name))
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def test_moving_an_item_from_cart_to_wish_list_when_not_logged_in
|
|
212
|
+
product = create_product(
|
|
213
|
+
name: 'Integration Product',
|
|
214
|
+
variants: [{ sku: 'SKU1', regular: 10.to_m }]
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
visit storefront.product_path(product)
|
|
218
|
+
click_button 'add_to_cart'
|
|
219
|
+
wait_for_xhr
|
|
220
|
+
|
|
221
|
+
visit storefront.cart_path
|
|
222
|
+
click_button 'move_to_wish_list'
|
|
223
|
+
|
|
224
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
225
|
+
|
|
226
|
+
visit storefront.users_wish_list_path
|
|
227
|
+
assert(page.has_content?(product.name))
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def test_non_purchasable_products_cannot_be_added_to_wish_list
|
|
231
|
+
product = create_product(purchasable: false)
|
|
232
|
+
|
|
233
|
+
visit storefront.product_path(product)
|
|
234
|
+
|
|
235
|
+
assert(page.has_no_content?('Add to Wish List'))
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def test_private_wishlists_are_not_searchable
|
|
239
|
+
set_wishlist_privacy('private')
|
|
240
|
+
|
|
241
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
242
|
+
add_to_wish_list(product)
|
|
243
|
+
search_wish_lists('test@workarea.com')
|
|
244
|
+
assert(page.has_no_content?('Ben Crouse'))
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def test_viewing_private_wish_list_summary_on_account_home
|
|
248
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
249
|
+
set_wishlist_privacy('private')
|
|
250
|
+
|
|
251
|
+
product = create_product(
|
|
252
|
+
name: 'Integration Product',
|
|
253
|
+
variants: [{ sku: 'SKU1', regular: 10.to_m }]
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
visit storefront.product_path(product)
|
|
257
|
+
click_link I18n.t('workarea.storefront.wish_lists.add_to_wish_list')
|
|
258
|
+
|
|
259
|
+
visit storefront.users_account_path
|
|
260
|
+
assert(page.has_content?('Integration Product'))
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def test_viewing_empty_wish_list
|
|
264
|
+
login('test@workarea.com', 'w3bl1nc')
|
|
265
|
+
|
|
266
|
+
visit storefront.users_wish_list_path
|
|
267
|
+
|
|
268
|
+
assert_text(
|
|
269
|
+
t(
|
|
270
|
+
'workarea.storefront.wish_lists.empty.message',
|
|
271
|
+
state: t('workarea.storefront.wish_lists.empty.states.unpurchased')
|
|
272
|
+
)
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
select 'Purchased', from: 'state'
|
|
276
|
+
wait_for_xhr
|
|
277
|
+
|
|
278
|
+
assert_text(
|
|
279
|
+
t(
|
|
280
|
+
'workarea.storefront.wish_lists.empty.message',
|
|
281
|
+
state: t('workarea.storefront.wish_lists.empty.states.purchased')
|
|
282
|
+
)
|
|
283
|
+
)
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
end
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Configure Rails Environment
|
|
2
|
+
ENV['RAILS_ENV'] = 'test'
|
|
3
|
+
|
|
4
|
+
require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
|
|
5
|
+
require 'rails/test_help'
|
|
6
|
+
require 'workarea/test_help'
|
|
7
|
+
|
|
8
|
+
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
|
9
|
+
# to be shown.
|
|
10
|
+
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|