Refactoring all interactions with the home/hub table into UIHelper

This commit is contained in:
Will Marshall
2014-04-29 15:22:04 +10:00
parent d7f8d2f5c7
commit ef6fe2b181
5 changed files with 16 additions and 9 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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