From 6a53e5fd3d41e76378f5def4fdf666c36c2bb316 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 12 Jul 2018 17:46:18 +1000 Subject: [PATCH] Avoid alert by waiting until shop loaded --- .../consumer/shopping/embedded_shopfronts_spec.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/features/consumer/shopping/embedded_shopfronts_spec.rb b/spec/features/consumer/shopping/embedded_shopfronts_spec.rb index 4a162895f4..5a97040e32 100644 --- a/spec/features/consumer/shopping/embedded_shopfronts_spec.rb +++ b/spec/features/consumer/shopping/embedded_shopfronts_spec.rb @@ -91,10 +91,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 find('ul.right li#login-link a').click login_with_modal + wait_for_shop_loaded wait_until { page.find('ul.right li.user-menu.has-dropdown').value.present? } logout_via_navigation @@ -105,6 +106,14 @@ 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 expect(page).to have_selector 'div.login-modal', visible: true