forked from solidusio/solidus
-
Notifications
You must be signed in to change notification settings - Fork 3
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 solidusio#5701 from mamhoff/fix-flaky-admin-spec
Fix flaky admin stock items spec
- Loading branch information
Showing
2 changed files
with
21 additions
and
18 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 |
---|---|---|
|
@@ -5,21 +5,20 @@ | |
describe "Stock Items", :js, type: :feature do | ||
before { sign_in create(:admin_user, email: '[email protected]') } | ||
|
||
it "lists stock items and allows navigating through scopes" do | ||
non_backorderable = create(:stock_item, backorderable: false) | ||
non_backorderable.variant.update!(sku: 'MY-SKU-1234567890') | ||
backorderable = create(:stock_item, backorderable: true) | ||
out_of_stock = begin | ||
item = create(:stock_item, backorderable: false) | ||
item.reduce_count_on_hand_to_zero | ||
item | ||
end | ||
low_stock = begin | ||
item = create(:stock_item, backorderable: false) | ||
item.set_count_on_hand(SolidusAdmin::Config[:low_stock_value] - 1) | ||
item | ||
end | ||
# We don't want multiple stock items per variant, and stock locations are created implicitly otherwise, | ||
# and their default is to create stock items for all variants, which in this spec we do manually. | ||
let!(:stock_location) { create(:stock_location, name: 'default', propagate_all_variants: false) } | ||
|
||
let(:backorderable_variant) { create(:variant, sku: 'backorderable', stock_items: []) } | ||
let(:non_backorderable_variant) { create(:variant, sku: 'non-backorderable', stock_items: []) } | ||
let(:out_of_stock_variant) { create(:variant, sku: 'out-of-stock', stock_items: []) } | ||
let(:low_stock_variant) { create(:variant, sku: 'low-stock', stock_items: []) } | ||
let!(:backorderable) { create(:stock_item, variant: backorderable_variant, backorderable: true) } | ||
let!(:non_backorderable) { create(:stock_item, variant: non_backorderable_variant, backorderable: false) } | ||
let!(:out_of_stock) { create(:stock_item, variant: out_of_stock_variant, backorderable: false, on_hand: 0) } | ||
let!(:low_stock) { create(:stock_item, variant: low_stock_variant, backorderable: false, on_hand: SolidusAdmin::Config.low_stock_value - 1) } | ||
|
||
it "lists stock items and allows navigating through scopes" do | ||
visit "/admin/stock_items" | ||
|
||
# `All` default scope | ||
|
@@ -29,11 +28,11 @@ | |
expect(page).to have_content(low_stock.variant.sku) | ||
|
||
# Edit stock item | ||
find('td', text: 'MY-SKU-1234567890').click | ||
find('td', text: 'non-backorderable').click | ||
fill_in :quantity_adjustment, with: 1 | ||
click_on "Save" | ||
expect(find('tr', text: 'MY-SKU-1234567890')).to have_content('11') | ||
expect(find('tr', text: 'MY-SKU-1234567890')).to have_content('1 stock movement') | ||
expect(find('tr', text: 'non-backorderable')).to have_content('11') | ||
expect(find('tr', text: 'non-backorderable')).to have_content('1 stock movement') | ||
|
||
click_on 'Back Orderable' | ||
expect(page).to have_css('[aria-current="true"]', text: 'Back Orderable') | ||
|
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