diff --git a/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb b/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb index 10214d69dc..3628ea3b91 100644 --- a/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb +++ b/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb @@ -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 diff --git a/spec/features/consumer/home_spec.rb b/spec/features/consumer/home_spec.rb index 411bb701b7..67599d97a0 100644 --- a/spec/features/consumer/home_spec.rb +++ b/spec/features/consumer/home_spec.rb @@ -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 diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb index 54f0608540..4a91b1186a 100644 --- a/spec/features/consumer/shopping/shopping_spec.rb +++ b/spec/features/consumer/shopping/shopping_spec.rb @@ -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 diff --git a/spec/support/request/shop_workflow.rb b/spec/support/request/shop_workflow.rb index cc327ced7e..2f9bd3c5ff 100644 --- a/spec/support/request/shop_workflow.rb +++ b/spec/support/request/shop_workflow.rb @@ -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 diff --git a/spec/support/request/ui_component_helper.rb b/spec/support/request/ui_component_helper.rb index 0b8fed13fa..df322ec833 100644 --- a/spec/support/request/ui_component_helper.rb +++ b/spec/support/request/ui_component_helper.rb @@ -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