mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Avoid race conditions in feature specs
This commit is contained in:
@@ -254,6 +254,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
|
||||
variant.update_attributes! on_hand: 0
|
||||
|
||||
# -- Messaging
|
||||
expect(page).to have_input "variants[#{variant.id}]"
|
||||
fill_in "variants[#{variant.id}]", with: '1'
|
||||
wait_until { !cart_dirty }
|
||||
|
||||
|
||||
@@ -36,9 +36,8 @@ feature 'Shops', js: true do
|
||||
it "should show closed shops after clicking the button" do
|
||||
create(:simple_product, distributors: [d1, d2])
|
||||
visit shops_path
|
||||
click_link "Show closed shops"
|
||||
page.should have_selector 'hub.inactive'
|
||||
page.should have_selector 'hub.inactive', text: d2.name
|
||||
click_link_and_ensure("Show closed shops", -> { page.has_selector? 'hub.inactive' })
|
||||
page.should have_selector 'hub.inactive', text: d2.name
|
||||
end
|
||||
|
||||
it "should link to the hub page" do
|
||||
@@ -52,4 +51,14 @@ feature 'Shops', js: true do
|
||||
open_enterprise_modal producer
|
||||
modal_should_be_open_for producer
|
||||
end
|
||||
|
||||
def click_link_and_ensure(link_text, check)
|
||||
# Buttons appear to be unresponsive for a while, so keep clicking them until content appears
|
||||
using_wait_time 0.5 do
|
||||
10.times do
|
||||
click_link link_text
|
||||
break if check.call
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user