Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Update store selector feature test for new style store selector.

Matthew Kennedy22c35f5a5173
diff --git a/backend/app/helpers/spree/admin/stores_helper.rb b/backend/app/helpers/spree/admin/stores_helper.rb
index 4c050180a1..7a9eeda6c8 100644
--- a/backend/app/helpers/spree/admin/stores_helper.rb
+++ b/backend/app/helpers/spree/admin/stores_helper.rb
@@ -23,7 +23,7 @@ module Spree
end
link_to icon + store.unique_name, store.formatted_url + request.path,
- class: "#{classes} text-dark p-3 dropdown-item"
+ class: "#{classes} text-dark p-3 dropdown-item", id: store.code
end
end
end
diff --git a/backend/spec/features/admin/store_selector_spec.rb b/backend/spec/features/admin/store_selector_spec.rb
index 59976d7889..e274e8955d 100644
--- a/backend/spec/features/admin/store_selector_spec.rb
+++ b/backend/spec/features/admin/store_selector_spec.rb
@@ -1,19 +1,38 @@
require 'spec_helper'
-describe 'Admin store selector', type: :feature, js: true do
+describe 'Admin store switcher', type: :feature, js: true do
stub_authorization!
let!(:admin_user) { create(:admin_user) }
+ let!(:store_one) { Spree::Store.default }
+ let!(:store_two) { create(:store, url: 'www.example-one.com') }
+ let!(:store_three) { create(:store, url: 'www.example-two.com') }
- let!(:store) { create(:store, url: "www.example1.com") }
+ context 'on the orders page of admin' do
+ before do
+ visit spree.admin_path
+ end
- before do
- visit spree.admin_path
+ it 'allows to change the url to the seleted store and returns you to orders page' do
+ find('a#storeSelectorDropdown').click
+
+ expect(page).to have_selector(:css, "a[href='#{store_one.formatted_url}/admin/orders']")
+ expect(page).to have_selector(:css, "a[href='#{store_two.formatted_url}/admin/orders']")
+ expect(page).to have_selector(:css, "a[href='#{store_three.formatted_url}/admin/orders']")
+ end
end
- it "should allow to change the url to the seleted store" do
- expect(current_url).not_to include("#{store.formatted_url}")
- find("select#store_select").find(:xpath, 'option[2]').select_option
- expect(current_url).to eq "#{store.formatted_url}/admin"
+ context 'on the products page of admin' do
+ before do
+ visit spree.admin_products_path
+ end
+
+ it 'allows to change the store store and returns you to products page' do
+ find('a#storeSelectorDropdown').click
+
+ expect(page).to have_selector(:css, "a[href='#{store_one.formatted_url}/admin/products']")
+ expect(page).to have_selector(:css, "a[href='#{store_two.formatted_url}/admin/products']")
+ expect(page).to have_selector(:css, "a[href='#{store_three.formatted_url}/admin/products']")
+ end
end
-end
\ No newline at end of file
+end