mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Refactoring all interactions with the home/hub table into UIHelper
This commit is contained in:
@@ -3,6 +3,7 @@ require 'spec_helper'
|
||||
feature "enterprises distributor info as rich text" do
|
||||
include AuthenticationWorkflow
|
||||
include WebHelper
|
||||
include UIComponentHelper
|
||||
|
||||
before(:each) do
|
||||
OpenFoodNetwork::FeatureToggle.stub(:features).and_return({eaterprises: false,
|
||||
@@ -111,7 +112,7 @@ feature "enterprises distributor info as rich text" do
|
||||
|
||||
login_to_consumer_section
|
||||
ActionMailer::Base.deliveries.clear
|
||||
click_link 'Green Grass'
|
||||
follow_active_table_node 'Green Grass'
|
||||
visit enterprise_path d
|
||||
|
||||
# -- Product details page
|
||||
|
||||
@@ -16,7 +16,7 @@ feature 'Home', js: true do
|
||||
|
||||
it "shows all hubs" do
|
||||
page.should have_content distributor.name
|
||||
open_active_table_row
|
||||
expand_active_table_node distributor.name
|
||||
page.should have_content "Shop at #{distributor.name}"
|
||||
end
|
||||
|
||||
@@ -28,8 +28,7 @@ feature 'Home', js: true do
|
||||
end
|
||||
|
||||
it "should link to the hub page" do
|
||||
open_active_table_row
|
||||
click_on "Shop at #{distributor.name}"
|
||||
follow_active_table_node distributor.name
|
||||
current_path.should == "/shop"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,9 +15,8 @@ feature "As a consumer I want to shop with a distributor", js: true do
|
||||
before do
|
||||
oc1
|
||||
create_enterprise_group_for distributor
|
||||
visit "/"
|
||||
open_active_table_row
|
||||
click_link "Shop at #{distributor.name}"
|
||||
visit root_path
|
||||
follow_active_table_node distributor.name
|
||||
end
|
||||
|
||||
it "shows a distributor with images" do
|
||||
|
||||
@@ -2,8 +2,7 @@ module ShopWorkflow
|
||||
def select_distributor
|
||||
# If no order cycles are available this is much faster
|
||||
visit "/"
|
||||
open_active_table_row
|
||||
click_link "Shop at #{distributor.name}"
|
||||
follow_active_table_node distributor.name
|
||||
end
|
||||
|
||||
# These methods are naughty and write to the DB directly
|
||||
|
||||
@@ -2,4 +2,13 @@ module UIComponentHelper
|
||||
def open_active_table_row
|
||||
find("hub:first-child .active_table_row:first-child").click()
|
||||
end
|
||||
|
||||
def expand_active_table_node(name)
|
||||
find(".active_table_node", text: name).click
|
||||
end
|
||||
|
||||
def follow_active_table_node(name)
|
||||
expand_active_table_node(name)
|
||||
find(".active_table_node a", text: "Shop at #{name}").click
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user