From 14d928c39dda1a5403cc43810d794ba2c263a535 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 20 Apr 2020 14:40:56 +0200 Subject: [PATCH] Fix feature specs where UI has changed --- app/views/shared/menu/_joyride.html.haml | 2 +- spec/features/consumer/shopping/cart_spec.rb | 2 +- .../shopping/embedded_shopfronts_spec.rb | 15 +++------------ .../consumer/shopping/variant_overrides_spec.rb | 2 +- spec/support/request/shop_workflow.rb | 16 +++++++++++++--- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/app/views/shared/menu/_joyride.html.haml b/app/views/shared/menu/_joyride.html.haml index 6d732e0294..eb1875f383 100644 --- a/app/views/shared/menu/_joyride.html.haml +++ b/app/views/shared/menu/_joyride.html.haml @@ -1,4 +1,4 @@ -.joyride-tip-guide{"ng-class" => "{ in: open }", "ng-show" => "open"} +.cart-dropdown.joyride-tip-guide{"ng-class" => "{ in: open }", "ng-show" => "open"} %span.joyride-nub.top .joyride-content-wrapper %h5 diff --git a/spec/features/consumer/shopping/cart_spec.rb b/spec/features/consumer/shopping/cart_spec.rb index ace11e775a..6a02206e1d 100644 --- a/spec/features/consumer/shopping/cart_spec.rb +++ b/spec/features/consumer/shopping/cart_spec.rb @@ -34,7 +34,7 @@ feature "full-page cart", js: true do click_link "Continue shopping" expect(page).to have_no_link "Continue shopping" - expect(page).to have_button "Edit your cart" + expect(page).to have_link "Shop" expect(page).to have_no_content distributor.preferred_shopfront_message end end diff --git a/spec/features/consumer/shopping/embedded_shopfronts_spec.rb b/spec/features/consumer/shopping/embedded_shopfronts_spec.rb index 290c6af516..20c7bfccb8 100644 --- a/spec/features/consumer/shopping/embedded_shopfronts_spec.rb +++ b/spec/features/consumer/shopping/embedded_shopfronts_spec.rb @@ -46,9 +46,8 @@ feature "Using embedded shopfront functionality", js: true do it "allows shopping and checkout" do on_embedded_page do fill_in "variants[#{variant.id}]", with: 1 - wait_until_enabled 'input.add_to_cart' - first("input.add_to_cart:not([disabled='disabled'])").click + edit_cart expect(page).to have_text 'Your shopping cart' find('a#checkout-link').click @@ -91,11 +90,11 @@ feature "Using embedded shopfront functionality", js: true do it "redirects to embedded hub on logout when embedded" do on_embedded_page do - wait_for_shop_loaded + wait_for_cart find('ul.right li#login-link a').click login_with_modal - wait_for_shop_loaded + wait_for_cart wait_until { page.find('ul.right li.user-menu.has-dropdown').value.present? } logout_via_navigation @@ -106,14 +105,6 @@ feature "Using embedded shopfront functionality", js: true do private - # When you have pending changes and try to navigate away from a page, it asks you "Are you sure?". - # When we click the "Update" button to save changes, we need to wait - # until it is actually saved and "loading" disappears before doing anything else. - def wait_for_shop_loaded - page.has_no_content? "Loading" - page.has_no_css? "input[value='Updating cart...']" - end - def login_with_modal page.has_selector? 'div.login-modal', visible: true diff --git a/spec/features/consumer/shopping/variant_overrides_spec.rb b/spec/features/consumer/shopping/variant_overrides_spec.rb index 8b37f5d22e..a4279786da 100644 --- a/spec/features/consumer/shopping/variant_overrides_spec.rb +++ b/spec/features/consumer/shopping/variant_overrides_spec.rb @@ -86,7 +86,7 @@ feature "shopping with variant overrides defined", js: true do it "shows the correct prices in the shopping cart" do fill_in "variants[#{product1_variant1.id}]", with: "2" - add_to_cart + edit_cart expect(page).to have_selector "tr.line-item.variant-#{product1_variant1.id} .cart-item-price", text: with_currency(61.11) expect(page).to have_field "order[line_items_attributes][0][quantity]", with: '2' diff --git a/spec/support/request/shop_workflow.rb b/spec/support/request/shop_workflow.rb index ff5909f267..cde1437b04 100644 --- a/spec/support/request/shop_workflow.rb +++ b/spec/support/request/shop_workflow.rb @@ -1,7 +1,17 @@ module ShopWorkflow - def add_to_cart - wait_until_enabled 'input.add_to_cart' - first("input.add_to_cart:not([disabled='disabled'])").click + def wait_for_cart + first("#cart").click + within '.cart-dropdown' do + expect(page).to_not have_link "Updating cart..." + end + end + + def edit_cart + wait_for_cart + within '.cart-dropdown' do + expect(page).to have_link "Edit your cart" + end + first("a.add_to_cart").click end def have_price(price)