diff --git a/public/embedded-shop-preview.html b/public/embedded-shop-preview.html
new file mode 100644
index 0000000000..a3c53f6440
--- /dev/null
+++ b/public/embedded-shop-preview.html
@@ -0,0 +1,20 @@
+
+
Embedded Shop
+
+
+
+ This is a preview page for embedded shops.
+ Choose a shop to display by copying its permalink id into the URL after the question mark.
+ Example: embedded-shop-preview.html?bawbawfoodhub
+
+
+
+
+
+
+
diff --git a/spec/features/consumer/shopping/embedded_shopfronts_spec.rb b/spec/features/consumer/shopping/embedded_shopfronts_spec.rb
index 87b6a7e5ca..da99492945 100644
--- a/spec/features/consumer/shopping/embedded_shopfronts_spec.rb
+++ b/spec/features/consumer/shopping/embedded_shopfronts_spec.rb
@@ -7,8 +7,6 @@ feature "Using embedded shopfront functionality", js: true do
include CheckoutWorkflow
include UIComponentHelper
- Capybara.server_port = 9999
-
describe "using iframes" do
let(:distributor) { create(:distributor_enterprise, name: 'My Embedded Hub', permalink: 'test_enterprise', with_payment_and_shipping: true) }
let(:supplier) { create(:supplier_enterprise) }
@@ -24,9 +22,8 @@ feature "Using embedded shopfront functionality", js: true do
Spree::Config[:enable_embedded_shopfronts] = true
Spree::Config[:embedded_shopfronts_whitelist] = 'test.com'
- page.driver.browser.js_errors = false
allow_any_instance_of(ActionDispatch::Request).to receive(:referer).and_return('https://www.test.com')
- Capybara.current_session.driver.visit('spec/support/views/iframe_test.html')
+ visit "/embedded-shop-preview.html?#{distributor.permalink}"
end
after do
@@ -34,9 +31,7 @@ feature "Using embedded shopfront functionality", js: true do
end
it "displays modified shopfront layout" do
- expect(page).to have_selector 'iframe#test_iframe'
-
- within_frame 'test_iframe' do
+ on_embedded_page do
within 'nav.top-bar' do
expect(page).to have_selector 'ul.left', visible: false
expect(page).to have_selector 'ul.center', visible: false
@@ -48,7 +43,7 @@ feature "Using embedded shopfront functionality", js: true do
end
xit "allows shopping and checkout" do
- within_frame 'test_iframe' do
+ on_embedded_page do
fill_in "variants[#{variant.id}]", with: 1
wait_until_enabled 'input.add_to_cart'
@@ -97,7 +92,7 @@ feature "Using embedded shopfront functionality", js: true do
end
it "redirects to embedded hub on logout when embedded" do
- within_frame 'test_iframe' do
+ on_embedded_page do
find('ul.right li#login-link a').click
login_with_modal
@@ -110,6 +105,16 @@ feature "Using embedded shopfront functionality", js: true do
end
end
+ private
+
+ def on_embedded_page
+ expect(page).to have_selector "iframe"
+
+ within_frame :frame do
+ yield
+ end
+ end
+
def login_with_modal
expect(page).to have_selector 'div.login-modal', visible: true
diff --git a/spec/support/views/iframe_test.html b/spec/support/views/iframe_test.html
deleted file mode 100644
index fe71aa66e3..0000000000
--- a/spec/support/views/iframe_test.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-