mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-13 23:37:47 +00:00
Add specs for producers and shops search by URL
This commit is contained in:
@@ -27,45 +27,54 @@ feature %q{
|
||||
|
||||
producer1.set_producer_property 'Local', 'Victoria'
|
||||
producer2.set_producer_property 'Fair Trade', 'FT123'
|
||||
|
||||
visit producers_path
|
||||
end
|
||||
|
||||
|
||||
it "filters by taxon" do
|
||||
toggle_filters
|
||||
|
||||
toggle_filter 'Vegetables'
|
||||
|
||||
page.should_not have_content producer1.name
|
||||
page.should have_content producer2.name
|
||||
|
||||
toggle_filter 'Vegetables'
|
||||
toggle_filter 'Fruit'
|
||||
|
||||
page.should have_content producer1.name
|
||||
page.should_not have_content producer2.name
|
||||
it "searches by URL" do
|
||||
visit producers_path(anchor: "/?query=xyzzy")
|
||||
expect(page).to have_content "Sorry, no results found for xyzzy"
|
||||
end
|
||||
|
||||
it "shows all producers with expandable details" do
|
||||
page.should have_content producer1.name
|
||||
expand_active_table_node producer1.name
|
||||
context "on the producers page" do
|
||||
before do
|
||||
visit producers_path
|
||||
end
|
||||
|
||||
# -- Taxons
|
||||
page.should have_content 'Fruit'
|
||||
it "filters by taxon" do
|
||||
toggle_filters
|
||||
|
||||
# -- Properties
|
||||
page.should have_content 'Organic' # Product property
|
||||
page.should have_content 'Local' # Producer property
|
||||
end
|
||||
toggle_filter 'Vegetables'
|
||||
|
||||
it "doesn't show invisible producers" do
|
||||
page.should_not have_content invisible_producer.name
|
||||
end
|
||||
page.should_not have_content producer1.name
|
||||
page.should have_content producer2.name
|
||||
|
||||
it "links to places to buy produce" do
|
||||
expand_active_table_node producer1.name
|
||||
page.should have_link shop.name
|
||||
toggle_filter 'Vegetables'
|
||||
toggle_filter 'Fruit'
|
||||
|
||||
page.should have_content producer1.name
|
||||
page.should_not have_content producer2.name
|
||||
end
|
||||
|
||||
it "shows all producers with expandable details" do
|
||||
page.should have_content producer1.name
|
||||
expand_active_table_node producer1.name
|
||||
|
||||
# -- Taxons
|
||||
page.should have_content 'Fruit'
|
||||
|
||||
# -- Properties
|
||||
page.should have_content 'Organic' # Product property
|
||||
page.should have_content 'Local' # Producer property
|
||||
end
|
||||
|
||||
it "doesn't show invisible producers" do
|
||||
page.should_not have_content invisible_producer.name
|
||||
end
|
||||
|
||||
it "links to places to buy produce" do
|
||||
expand_active_table_node producer1.name
|
||||
page.should have_link shop.name
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -14,56 +14,70 @@ feature 'Shops', js: true do
|
||||
|
||||
before do
|
||||
producer.set_producer_property 'Organic', 'NASAA 12345'
|
||||
visit shops_path
|
||||
end
|
||||
|
||||
it "shows hubs" do
|
||||
page.should have_content distributor.name
|
||||
expand_active_table_node distributor.name
|
||||
page.should have_content "OUR PRODUCERS"
|
||||
it "searches by URL" do
|
||||
visit shops_path(anchor: "/?query=xyzzy")
|
||||
expect(page).to have_content "Sorry, no results found for xyzzy"
|
||||
end
|
||||
|
||||
it "does not show invisible hubs" do
|
||||
page.should_not have_content invisible_distributor.name
|
||||
end
|
||||
|
||||
it "should not show hubs that are not in an order cycle" do
|
||||
create(:simple_product, distributors: [d1, d2])
|
||||
visit shops_path
|
||||
page.should have_no_selector 'hub.inactive'
|
||||
page.should have_no_selector 'hub', text: d2.name
|
||||
end
|
||||
context "on the shops path" do
|
||||
before do
|
||||
visit shops_path
|
||||
end
|
||||
|
||||
it "should show closed shops after clicking the button" do
|
||||
create(:simple_product, distributors: [d1, d2])
|
||||
visit shops_path
|
||||
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
|
||||
follow_active_table_node distributor.name
|
||||
expect(page).to have_current_path enterprise_shop_path(distributor)
|
||||
end
|
||||
|
||||
describe "hub producer modal" do
|
||||
let!(:product) { create(:simple_product, supplier: producer, taxons: [taxon]) }
|
||||
let!(:taxon) { create(:taxon, name: 'Fruit') }
|
||||
let!(:order_cycle) { create(:simple_order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [product.variants.first]) }
|
||||
|
||||
it "should show hub producer modals" do
|
||||
it "shows hubs" do
|
||||
page.should have_content distributor.name
|
||||
expand_active_table_node distributor.name
|
||||
expect(page).to have_content producer.name
|
||||
open_enterprise_modal producer
|
||||
modal_should_be_open_for producer
|
||||
page.should have_content "OUR PRODUCERS"
|
||||
end
|
||||
|
||||
within ".reveal-modal" do
|
||||
expect(page).to have_content 'Fruit' # Taxon
|
||||
expect(page).to have_content 'Organic' # Producer property
|
||||
it "does not show invisible hubs" do
|
||||
page.should_not have_content invisible_distributor.name
|
||||
end
|
||||
|
||||
it "should not show hubs that are not in an order cycle" do
|
||||
create(:simple_product, distributors: [d1, d2])
|
||||
visit shops_path
|
||||
page.should have_no_selector 'hub.inactive'
|
||||
page.should have_no_selector 'hub', text: d2.name
|
||||
end
|
||||
|
||||
it "should show closed shops after clicking the button" do
|
||||
create(:simple_product, distributors: [d1, d2])
|
||||
visit shops_path
|
||||
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
|
||||
follow_active_table_node distributor.name
|
||||
expect(page).to have_current_path enterprise_shop_path(distributor)
|
||||
end
|
||||
|
||||
describe "hub producer modal" do
|
||||
let!(:product) { create(:simple_product, supplier: producer, taxons: [taxon]) }
|
||||
let!(:taxon) { create(:taxon, name: 'Fruit') }
|
||||
let!(:order_cycle) { create(:simple_order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [product.variants.first]) }
|
||||
|
||||
it "should show hub producer modals" do
|
||||
expand_active_table_node distributor.name
|
||||
expect(page).to have_content producer.name
|
||||
open_enterprise_modal producer
|
||||
modal_should_be_open_for producer
|
||||
|
||||
within ".reveal-modal" do
|
||||
expect(page).to have_content 'Fruit' # Taxon
|
||||
expect(page).to have_content 'Organic' # Producer property
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user