Skip to content

Commit

Permalink
Fix failing specs [OFN-12666]
Browse files Browse the repository at this point in the history
  • Loading branch information
wandji20 committed Jul 24, 2024
1 parent 1c865af commit a7ca6f3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
12 changes: 9 additions & 3 deletions spec/javascripts/unit/admin/bulk_product_update_spec.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -797,14 +797,20 @@ describe "AdminProductEditCtrl", ->
spyOn DisplayProperties, 'setShowVariants'

it "adds first and subsequent variants", ->
product = {id: 123, variants: []}
product = {id: 123, variants: [
{
id: 1, price: 10.0, unit_value: 1, tax_category_id: null, unit_description: '1kg',
on_demand: false, on_hand: null, display_as: null, display_name: null, category_id: 2
}
]}
$scope.addVariant(product)
$scope.addVariant(product)
expect(product).toEqual
id: 123
variants: [
{id: -1, price: null, unit_value: null, tax_category_id: null, unit_description: null, on_demand: false, on_hand: null, display_as: null, display_name: null, category_id: null}
{id: -2, price: null, unit_value: null, tax_category_id: null, unit_description: null, on_demand: false, on_hand: null, display_as: null, display_name: null, category_id: null}
{id: 1, price: 10.0, unit_value: 1, tax_category_id: null, unit_description: '1kg', on_demand: false, on_hand: null, display_as: null, display_name: null, category_id: 2}
{id: -1, price: null, unit_value: null, tax_category_id: null, unit_description: null, on_demand: false, on_hand: null, display_as: null, display_name: null, category_id: 2}
{id: -2, price: null, unit_value: null, tax_category_id: null, unit_description: null, on_demand: false, on_hand: null, display_as: null, display_name: null, category_id: 2}
]

it "shows the variant(s)", ->
Expand Down
5 changes: 4 additions & 1 deletion spec/services/sets/product_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@
[
{ id: product.variants.first.id.to_s }, # default variant unchanged
# omit ID for new variant
{ sku: "new sku", price: "5.00", unit_value: "5", supplier_id: supplier.id },
{
sku: "new sku", price: "5.00", unit_value: "5",
supplier_id: supplier.id, primary_taxon_id: create(:taxon).id
},
]
}
let(:supplier) { create(:supplier_enterprise) }
Expand Down
6 changes: 4 additions & 2 deletions spec/system/admin/products_v3/actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
login_as user
end

let(:producer_search_selector) { 'input[placeholder="Search for producers"]' }
let(:categories_search_selector) { 'input[placeholder="Search for categories"]' }
let(:producer_search_selector) { 'input[placeholder="Select producer"]' }
let(:categories_search_selector) { 'input[placeholder="Select category"]' }
let(:tax_categories_search_selector) { 'input[placeholder="Search for tax categories"]' }

describe "with no products" do
Expand Down Expand Up @@ -520,6 +520,7 @@ def expect_other_columns_visible
expect(page).to have_select(
'_products_0_variants_attributes_0_supplier_id',
options: [
'Select producer',
supplier_managed1.name, supplier_managed2.name, supplier_permitted.name
], selected: supplier_managed1.name
)
Expand All @@ -529,6 +530,7 @@ def expect_other_columns_visible
expect(page).to have_select(
'_products_1_variants_attributes_0_supplier_id',
options: [
'Select producer',
supplier_managed1.name, supplier_managed2.name, supplier_permitted.name
], selected: supplier_permitted.name
)
Expand Down
9 changes: 7 additions & 2 deletions spec/system/admin/products_v3/create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
include AuthenticationHelper
include WebHelper

let!(:supplier) { create(:supplier_enterprise) }
let!(:taxon) { create(:taxon) }

describe "creating a new product" do
let!(:stock_location) { create(:stock_location, backorderable_default: false) }
let!(:supplier) { create(:supplier_enterprise) }
let!(:distributor) { create(:distributor_enterprise) }
let!(:shipping_category) { create(:shipping_category) }
let!(:taxon) { create(:taxon) }

before { visit_products_page_as_admin }

Expand Down Expand Up @@ -81,6 +82,10 @@
find('input[id$="_display_as"]').fill_in with: "2 grams"
find('button[aria-label="On Hand"]').click
find('input[id$="_price"]').fill_in with: "11.1"

select supplier.name, from: 'Producer'
select taxon.name, from: 'Category'

if stock == "on_hand"
find('input[id$="_on_hand"]').fill_in with: "66"
elsif stock == "on_demand"
Expand Down

0 comments on commit a7ca6f3

Please sign in to comment.