workarea-package_products 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +20 -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/CHANGELOG.md +343 -0
- data/CODE_OF_CONDUCT.md +3 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +16 -0
- data/LICENSE +52 -0
- data/README.md +40 -0
- data/Rakefile +52 -0
- data/app/assets/javascripts/workarea/storefront/package_products/modules/family_product_add_to_cart.js +83 -0
- data/app/assets/javascripts/workarea/storefront/package_products/templates/family_add_to_cart_checkbox.jst.ejs +1 -0
- data/app/assets/stylesheets/workarea/admin/package_products/components/_product_cards.scss +7 -0
- data/app/assets/stylesheets/workarea/storefront/package_products/components/_product_detail_packaged_products.scss +11 -0
- data/app/controllers/workarea/admin/create_catalog_package_products_controller.rb +150 -0
- data/app/controllers/workarea/admin/create_catalog_products_controller.decorator +25 -0
- data/app/controllers/workarea/storefront/cart_items_controller.decorator +29 -0
- data/app/controllers/workarea/storefront/products_controller.decorator +8 -0
- data/app/models/workarea/catalog/product.decorator +44 -0
- data/app/models/workarea/search/admin/catalog_product.decorator +20 -0
- data/app/models/workarea/search/storefront/package_product.rb +40 -0
- data/app/queries/workarea/search/product_entries.decorator +8 -0
- data/app/seeds/workarea/package_product_seeds.rb +41 -0
- data/app/services/workarea/add_package_to_cart.rb +79 -0
- data/app/view_models/workarea/admin/product_view_model.decorator +35 -0
- data/app/view_models/workarea/storefront/product_templates/family_view_model.rb +6 -0
- data/app/view_models/workarea/storefront/product_templates/package_view_model.rb +33 -0
- data/app/view_models/workarea/storefront/product_view_model.decorator +13 -0
- data/app/views/workarea/admin/catalog_products/_create_package_button.html.haml +1 -0
- data/app/views/workarea/admin/catalog_products/_packaged_products_card.html.haml +26 -0
- data/app/views/workarea/admin/create_catalog_package_products/categorization.html.haml +64 -0
- data/app/views/workarea/admin/create_catalog_package_products/content.html.haml +54 -0
- data/app/views/workarea/admin/create_catalog_package_products/details.html.haml +87 -0
- data/app/views/workarea/admin/create_catalog_package_products/images.html.haml +57 -0
- data/app/views/workarea/admin/create_catalog_package_products/packaged_products.html.haml +79 -0
- data/app/views/workarea/admin/create_catalog_package_products/publish.html.haml +61 -0
- data/app/views/workarea/admin/create_catalog_package_products/setup.html.haml +68 -0
- data/app/views/workarea/admin/create_catalog_products/select.html.haml +34 -0
- data/app/views/workarea/storefront/cart_items/package.html.haml +59 -0
- data/app/views/workarea/storefront/products/package_show.html.haml +49 -0
- data/app/views/workarea/storefront/products/templates/_family.html.haml +42 -0
- data/app/views/workarea/storefront/products/templates/_package.html.haml +36 -0
- data/app/workers/workarea/update_package_products.rb +21 -0
- data/bin/rails +16 -0
- data/config/initializers/appends.rb +31 -0
- data/config/initializers/configuration.rb +6 -0
- data/config/initializers/seeds.rb +1 -0
- data/config/locales/en.yml +45 -0
- data/config/routes.rb +30 -0
- data/lib/tasks/sample_data.rake +16 -0
- data/lib/workarea/package_products.rb +10 -0
- data/lib/workarea/package_products/engine.rb +8 -0
- data/lib/workarea/package_products/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 +18 -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 +83 -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/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/db/seeds.rb +2 -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 +1 -0
- data/test/integration/workarea/admin/create_catalog_package_products_integration_test.rb +139 -0
- data/test/integration/workarea/storefront/package_cart_items_integration_test.rb +47 -0
- data/test/integration/workarea/storefront/products_integration_test.decorator +19 -0
- data/test/models/workarea/catalog/package_product_test.rb +68 -0
- data/test/models/workarea/search/storefront/package_product_test.rb +44 -0
- data/test/queries/workarea/search/product_entries_test.decorator +15 -0
- data/test/services/workarea/add_package_to_cart_test.rb +46 -0
- data/test/system/workarea/admin/activity_system_test.decorator +53 -0
- data/test/system/workarea/admin/package_product_copy_system_test.rb +27 -0
- data/test/system/workarea/admin/package_products_system_test.rb +101 -0
- data/test/system/workarea/admin/product_copy_system_test.decorator +28 -0
- data/test/system/workarea/admin/products_system_test.decorator +69 -0
- data/test/system/workarea/storefront/categories_with_packages_system_test.rb +172 -0
- data/test/system/workarea/storefront/family_product_system_test.rb +58 -0
- data/test/system/workarea/storefront/package_product_system_test.rb +42 -0
- data/test/test_helper.rb +10 -0
- data/test/view_models/workarea/admin/package_product_view_model_test.rb +41 -0
- data/test/view_models/workarea/storefront/package_product_view_model_test.rb +27 -0
- data/test/view_models/workarea/storefront/package_templates/package_view_model_test.rb +34 -0
- data/test/workers/workarea/update_package_products_test.rb +27 -0
- data/workarea-package_products.gemspec +24 -0
- metadata +189 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Storefront
|
5
|
+
class PackageCartItemsIntegrationTest < Workarea::IntegrationTest
|
6
|
+
include Storefront::IntegrationTest
|
7
|
+
|
8
|
+
def test_package
|
9
|
+
dwoos_product = create_product(variants: [{ sku: 'DWOOS1' }])
|
10
|
+
create_inventory(
|
11
|
+
id: dwoos_product.skus.first,
|
12
|
+
policy: 'displayable_when_out_of_stock',
|
13
|
+
available: 0
|
14
|
+
)
|
15
|
+
standard_product = create_product
|
16
|
+
create_inventory(id: standard_product.skus.first)
|
17
|
+
family_product = create_product(
|
18
|
+
template: 'family',
|
19
|
+
product_ids: [dwoos_product.id, standard_product.id]
|
20
|
+
)
|
21
|
+
dwoos_sku = dwoos_product.skus.first
|
22
|
+
standard_sku = standard_product.skus.first
|
23
|
+
|
24
|
+
post storefront.package_cart_items_path, params: {
|
25
|
+
product_id: family_product.id,
|
26
|
+
items: {
|
27
|
+
'0' => {
|
28
|
+
product_id: dwoos_product.id,
|
29
|
+
sku: dwoos_sku,
|
30
|
+
quantity: 1
|
31
|
+
},
|
32
|
+
'1' => {
|
33
|
+
product_id: standard_product.id,
|
34
|
+
sku: standard_sku,
|
35
|
+
quantity: 1
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
skus_in_cart = Order.last.items.map(&:sku)
|
40
|
+
|
41
|
+
assert_response(:success)
|
42
|
+
assert_includes(skus_in_cart, standard_sku)
|
43
|
+
refute_includes(skus_in_cart, dwoos_sku)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate Storefront::ProductsIntegrationTest, with: :package_products do
|
3
|
+
def test_rendering_via_params
|
4
|
+
category = create_category
|
5
|
+
product = create_product(product_ids: [create_product.id])
|
6
|
+
|
7
|
+
Workarea.config.product_templates.each do |template|
|
8
|
+
next if template == :test_product
|
9
|
+
product.update_attributes!(template: template)
|
10
|
+
|
11
|
+
get storefront.product_path(product, via: category.to_gid_param)
|
12
|
+
assert_select(
|
13
|
+
'form.product-details__add-to-cart-form input[name="via"][value=?]',
|
14
|
+
category.to_gid_param
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
module Workarea
|
3
|
+
module Catalog
|
4
|
+
# TODO: change to ProductTest decorator after base test is converted
|
5
|
+
class PackageProductTest < TestCase
|
6
|
+
setup :set_products
|
7
|
+
|
8
|
+
def set_products
|
9
|
+
@product_one = create_product(id: 'PROD1', variants: [{ sku: 'SKU1' }, { sku: 'SKU2' }])
|
10
|
+
@product_two = create_product(id: 'PROD2', variants: [{ sku: 'SKU3' }])
|
11
|
+
@product_three = create_product(id: 'PROD3', variants: [{ sku: 'SKU4' }])
|
12
|
+
@package = create_product(id: 'PACK', template: 'package', product_ids: %w(PROD1 PROD2), variants: [])
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_validations
|
16
|
+
@package.product_ids << ''
|
17
|
+
assert_equal(3, @package.product_ids.count)
|
18
|
+
@package.save
|
19
|
+
|
20
|
+
assert_equal(2, @package.product_ids.count)
|
21
|
+
assert_equal(%w(PROD1 PROD2), @package.product_ids)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_find_for_update_by_sku
|
25
|
+
results = Product.find_for_update_by_sku('SKU4')
|
26
|
+
assert_equal([@product_three], results)
|
27
|
+
|
28
|
+
results = Product.find_for_update_by_sku('SKU1')
|
29
|
+
assert_equal([@product_one, @package], results)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_packages_containing
|
33
|
+
results = Product.packages_containing('PROD1')
|
34
|
+
assert_equal([@package], results)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_package?
|
38
|
+
@product_one.template = 'package'
|
39
|
+
assert(@product_one.package?)
|
40
|
+
|
41
|
+
@product_one.template = 'generic'
|
42
|
+
@product_one.product_ids = [1, 2]
|
43
|
+
assert(@product_one.package?)
|
44
|
+
|
45
|
+
@product_one.product_ids = []
|
46
|
+
refute(@product_one.package?)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_family?
|
50
|
+
@product_one.template = 'family'
|
51
|
+
assert(@product_one.family?)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_active?
|
55
|
+
@product_one.active = true
|
56
|
+
@product_one.variants.clear
|
57
|
+
|
58
|
+
refute(@product_one.active?)
|
59
|
+
|
60
|
+
@product_one.active = true
|
61
|
+
@product_one.product_ids = [1, 2]
|
62
|
+
@product_one.variants.clear
|
63
|
+
|
64
|
+
assert(@product_one.active?)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Search
|
5
|
+
class Storefront
|
6
|
+
class PackageProductTest < TestCase
|
7
|
+
def packaged_products
|
8
|
+
@packaged_products ||= [
|
9
|
+
create_product(variants: [{ sku: 'SKU1' }]),
|
10
|
+
create_product(variants: [{ sku: 'SKU2' }]),
|
11
|
+
create_product(variants: [{ sku: 'SKU3' }])
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
def product
|
16
|
+
@product ||= Catalog::Product.new(
|
17
|
+
product_ids: packaged_products.map(&:id)
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def search_model
|
22
|
+
@search_model ||= PackageProduct.new(product)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_skus
|
26
|
+
assert_equal(3, search_model.skus.length)
|
27
|
+
assert_includes(search_model.skus, 'SKU1')
|
28
|
+
assert_includes(search_model.skus, 'SKU2')
|
29
|
+
assert_includes(search_model.skus, 'SKU3')
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_variant_count
|
33
|
+
assert_equal(3, search_model.variant_count)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_packaged_products_handles_nonexistent_ids
|
37
|
+
product.product_ids << 'foo'
|
38
|
+
|
39
|
+
assert_equal(3, search_model.send(:packaged_products).size)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
decorate Search::ProductEntriesTest, with: :package_products do
|
5
|
+
def test_package_product_entries
|
6
|
+
products = Array.new(2) { create_product }
|
7
|
+
products.first.product_ids = ['ABC', '123']
|
8
|
+
|
9
|
+
entries = Search::ProductEntries.new(products).entries
|
10
|
+
assert_equal(2, entries.size)
|
11
|
+
assert_equal(Search::Storefront::PackageProduct, entries.first.class)
|
12
|
+
assert_equal(Search::Storefront::Product, entries.last.class)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
class AddPackageToCartTest < TestCase
|
5
|
+
setup :set_products
|
6
|
+
|
7
|
+
def set_products
|
8
|
+
@products = [
|
9
|
+
create_product(
|
10
|
+
id: 'PROD1',
|
11
|
+
variants: [{ sku: 'SKU1', regular: 5.00 }]
|
12
|
+
),
|
13
|
+
create_product(
|
14
|
+
id: 'PROD2',
|
15
|
+
variants: [{ sku: 'SKU2', regular: 10.00 }]
|
16
|
+
)
|
17
|
+
]
|
18
|
+
end
|
19
|
+
|
20
|
+
def params
|
21
|
+
@params ||= ActionController::Parameters.new(
|
22
|
+
items: {
|
23
|
+
1 => { product_id: 'PROD1', sku: 'SKU1', quantity: 2 },
|
24
|
+
2 => { product_id: 'PROD2', sku: 'SKU2', quantity: 1 }
|
25
|
+
}
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_save
|
30
|
+
order = create_order
|
31
|
+
|
32
|
+
add_to_cart = AddPackageToCart.new(order, params)
|
33
|
+
|
34
|
+
result = add_to_cart.save
|
35
|
+
order.reload
|
36
|
+
|
37
|
+
assert(result)
|
38
|
+
assert_equal(2, order.items.count)
|
39
|
+
|
40
|
+
item = order.items.first
|
41
|
+
assert_equal('PROD1', item.product_id)
|
42
|
+
assert_equal('SKU1', item.sku)
|
43
|
+
assert_equal(2, item.quantity)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate Admin::ActivitySystemTest do
|
3
|
+
def test_shows_a_filterable_list_of_activity_in_the_admin
|
4
|
+
visit admin.create_catalog_products_path
|
5
|
+
click_button t('workarea.admin.create_catalog_products.select.button')
|
6
|
+
fill_in 'product[name]', with: 'Testing Product'
|
7
|
+
click_button 'save_setup'
|
8
|
+
|
9
|
+
visit admin.create_releases_path
|
10
|
+
fill_in 'release[name]', with: 'Foo'
|
11
|
+
click_button 'save_setup'
|
12
|
+
|
13
|
+
visit admin.activity_path
|
14
|
+
assert(page.has_content?('Ben Crouse'))
|
15
|
+
assert(
|
16
|
+
page.has_content?(
|
17
|
+
t(
|
18
|
+
'workarea.admin.activities.catalog_product_create_html',
|
19
|
+
name: 'Testing Product'
|
20
|
+
)
|
21
|
+
)
|
22
|
+
)
|
23
|
+
assert(
|
24
|
+
page.has_content?(
|
25
|
+
t(
|
26
|
+
'workarea.admin.activities.release_create_html',
|
27
|
+
name: 'Foo'
|
28
|
+
)
|
29
|
+
)
|
30
|
+
)
|
31
|
+
select 'release', from: 'type'
|
32
|
+
page.execute_script("$('#activity_form').submit()") # because autosubmit control
|
33
|
+
|
34
|
+
assert(
|
35
|
+
page.has_no_content?(
|
36
|
+
t(
|
37
|
+
'workarea.admin.activities.catalog_product_create_html',
|
38
|
+
name: 'Testing Product'
|
39
|
+
)
|
40
|
+
)
|
41
|
+
)
|
42
|
+
assert(page.has_content?('Ben Crouse'))
|
43
|
+
assert(
|
44
|
+
page.has_content?(
|
45
|
+
t(
|
46
|
+
'workarea.admin.activities.release_create_html',
|
47
|
+
name: 'Foo'
|
48
|
+
)
|
49
|
+
)
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Admin
|
5
|
+
class PackageProductCopySystemTest < Workarea::SystemTest
|
6
|
+
include Admin::IntegrationTest
|
7
|
+
|
8
|
+
def test_copy_package_product
|
9
|
+
product = create_product(template: 'package')
|
10
|
+
|
11
|
+
visit admin.catalog_product_path(product)
|
12
|
+
click_link t('workarea.admin.catalog_products.show.copy_product')
|
13
|
+
|
14
|
+
fill_in 'product[id]', with: 'FOOBAR'
|
15
|
+
|
16
|
+
click_button 'create_copy'
|
17
|
+
assert(page.has_content?('Success'))
|
18
|
+
assert_current_path(
|
19
|
+
admin.edit_create_catalog_package_product_path(
|
20
|
+
"#{product.slug}-1",
|
21
|
+
continue: true
|
22
|
+
)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Admin
|
5
|
+
class PackageProductsSystemTest < Workarea::SystemTest
|
6
|
+
include Admin::IntegrationTest
|
7
|
+
|
8
|
+
def test_adding_packaged_products
|
9
|
+
create_product(name: 'Foo')
|
10
|
+
create_product(name: 'Bar')
|
11
|
+
product = create_product(template: 'package')
|
12
|
+
visit admin.catalog_product_path(product)
|
13
|
+
|
14
|
+
click_link t('workarea.admin.catalog_products.cards.packaged_products.title')
|
15
|
+
assert(page.has_content?('Foo'))
|
16
|
+
assert(page.has_content?('Bar'))
|
17
|
+
|
18
|
+
click_link 'Foo'
|
19
|
+
assert(page.has_content?('Success'))
|
20
|
+
assert(page.has_selector?('.product-summary__remove'))
|
21
|
+
click_link t('workarea.admin.featured_products.select.sort_link')
|
22
|
+
|
23
|
+
assert(page.has_content?('Foo'))
|
24
|
+
assert(page.has_no_content?('Bar'))
|
25
|
+
click_link t('workarea.admin.featured_products.edit.browse_link')
|
26
|
+
|
27
|
+
assert(page.has_selector?('.product-summary__remove'))
|
28
|
+
click_link 'Foo'
|
29
|
+
assert(page.has_content?('Success'))
|
30
|
+
assert(page.has_no_selector?('.product-summary__remove'))
|
31
|
+
click_link t('workarea.admin.featured_products.select.sort_link')
|
32
|
+
|
33
|
+
assert(page.has_no_content?('Foo'))
|
34
|
+
assert(page.has_no_content?('Bar'))
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_creating_a_package_product
|
38
|
+
create_category(name: 'Test Category')
|
39
|
+
create_product(name: 'Foo')
|
40
|
+
create_product(name: 'Bar')
|
41
|
+
|
42
|
+
visit admin.catalog_products_path
|
43
|
+
|
44
|
+
click_link 'Add New Product'
|
45
|
+
|
46
|
+
choose 'product_type_package'
|
47
|
+
click_button 'select_product_type'
|
48
|
+
|
49
|
+
fill_in 'product[name]', with: 'Test Package'
|
50
|
+
click_button 'save_setup'
|
51
|
+
|
52
|
+
assert(page.has_content?('Success'))
|
53
|
+
assert(page.has_content?(t('workarea.admin.create_catalog_package_products.packaged_products.title', product_name: 'Test Package')))
|
54
|
+
|
55
|
+
click_link('Foo')
|
56
|
+
assert(page.has_content?('Success'))
|
57
|
+
click_link('Bar')
|
58
|
+
assert(page.has_content?('Success'))
|
59
|
+
|
60
|
+
click_link(t('workarea.admin.create_catalog_package_products.packaged_products.continue_to_images'))
|
61
|
+
assert(page.has_content?(t('workarea.admin.create_catalog_products.images.add_images', product_name: 'Test Package')))
|
62
|
+
|
63
|
+
attach_file 'images[][image]', product_image_file_path
|
64
|
+
click_button 'save_images'
|
65
|
+
|
66
|
+
assert(page.has_content?('Success'))
|
67
|
+
assert(page.has_content?(t('workarea.admin.create_catalog_products.details.add_details', product_name: 'Test Package')))
|
68
|
+
click_button 'save_details'
|
69
|
+
|
70
|
+
assert(page.has_content?('Success'))
|
71
|
+
assert(page.has_content?(t('workarea.admin.create_catalog_products.content.add_content', product_name: 'Test Package')))
|
72
|
+
|
73
|
+
page.execute_script(<<-js
|
74
|
+
$("body", $("iframe.wysihtml-sandbox").contents())
|
75
|
+
.text("Description")
|
76
|
+
js
|
77
|
+
)
|
78
|
+
|
79
|
+
click_button 'save_content'
|
80
|
+
|
81
|
+
assert(page.has_content?('Success'))
|
82
|
+
assert(page.has_content?(t('workarea.admin.create_catalog_products.categorization.categorize', product_name: 'Test Package')))
|
83
|
+
|
84
|
+
find('.select2-selection--multiple').click
|
85
|
+
assert(page.has_content?('Test Category'))
|
86
|
+
find('.select2-results__option', text: 'Test Category').click
|
87
|
+
|
88
|
+
click_button 'add_categories'
|
89
|
+
assert(page.has_content?('Success'))
|
90
|
+
assert(page.has_content?('Test Category'))
|
91
|
+
click_link t('workarea.admin.create_catalog_products.categorization.continue_to_publish')
|
92
|
+
|
93
|
+
assert(page.has_content?(t('workarea.admin.create_catalog_products.publish.when_does_it_go_live', product_name: 'Test Package')))
|
94
|
+
click_button 'publish'
|
95
|
+
|
96
|
+
assert(page.has_content?('Success'))
|
97
|
+
assert(page.has_content?(t('workarea.admin.catalog_products.cards.packaged_products.title')))
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
decorate Admin::ProductCopySystemTest, with: :package_products do
|
5
|
+
def test_copy_from_create_workflow
|
6
|
+
create_product(name: 'Original Product')
|
7
|
+
|
8
|
+
visit admin.create_catalog_products_path
|
9
|
+
click_button t('workarea.admin.create_catalog_products.select.button')
|
10
|
+
|
11
|
+
click_link t('workarea.admin.create_catalog_products.setup.copy_button')
|
12
|
+
|
13
|
+
find('.select2-selection--single').click
|
14
|
+
find('.select2-results__option', text: 'Original Product').click
|
15
|
+
|
16
|
+
fill_in 'product[id]', with: 'FOOBAR'
|
17
|
+
|
18
|
+
click_button 'create_copy'
|
19
|
+
assert(page.has_content?('Success'))
|
20
|
+
assert_current_path(
|
21
|
+
admin.edit_create_catalog_product_path(
|
22
|
+
'original-product-1',
|
23
|
+
continue: true
|
24
|
+
)
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|