-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests around unit price in backoffice
3 cases: - creating a new product - creating a new variant - editing an existing variant
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
feature ' | ||
As an admin | ||
I want to check the unit price of my products/variants | ||
' do | ||
include AuthenticationHelper | ||
include WebHelper | ||
|
||
let!(:stock_location) { create(:stock_location, backorderable_default: false) } | ||
|
||
before do | ||
allow(OpenFoodNetwork::FeatureToggle).to receive(:enabled?).with(:unit_price, anything) { true } | ||
end | ||
|
||
describe "product", js: true do | ||
scenario "creating a new product", :debug do | ||
login_as_admin_and_visit spree.admin_products_path | ||
click_link 'New Product' | ||
select "Weight (kg)", from: 'product_variant_unit_with_scale' | ||
fill_in 'product_unit_value_with_description', with: '1' | ||
fill_in 'product[price]', with: '1' | ||
|
||
expect(find("#variant_unit_price", :visible => false).value).to eq '$1.00 / kg' | ||
end | ||
end | ||
|
||
describe "variant", js: true do | ||
scenario "creating a new variant" do | ||
product = create(:simple_product, variant_unit: "weight", variant_unit_scale: "1") | ||
login_as_admin_and_visit spree.admin_product_variants_path product | ||
click_link 'New Variant' | ||
fill_in 'unit_value_human', with: '1' | ||
fill_in 'variant[price]', with: '1' | ||
|
||
expect(find("#variant_unit_price", :visible => false).value).to eq '$1,000.00 / kg' | ||
end | ||
|
||
scenario "editing a variant" do | ||
product = create(:simple_product, variant_unit: "weight", variant_unit_scale: "1") | ||
variant = product.variants.first | ||
variant.update(price: 1.0) | ||
login_as_admin_and_visit spree.edit_admin_product_variant_path(product, variant) | ||
|
||
expect(find("#variant_unit_price", :visible => false).value).to eq '$1,000.00 / kg' | ||
end | ||
end | ||
end |