-
-
Notifications
You must be signed in to change notification settings - Fork 729
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7260 from jibees/7069-add-automated-tests-for-uni…
…t-price-in-backoffice Add automated tests for unit price in backoffice
- Loading branch information
Showing
4 changed files
with
57 additions
and
4 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
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
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
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" 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 'Value', with: '1' | ||
fill_in 'Price', with: '1' | ||
|
||
expect(find_field("Unit Price", disabled: true).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 'Weight (g)', with: '1' | ||
fill_in 'Price', with: '1' | ||
|
||
expect(find_field("Unit Price", disabled: true).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_field("Unit Price", disabled: true).value).to eq '$1,000.00 / kg' | ||
end | ||
end | ||
end |