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.

Add a test for tagging and saving stores

Matthew Kennedya64e94d3e30e
diff --git a/backend/spec/features/admin/configuration/payment_methods_spec.rb b/backend/spec/features/admin/configuration/payment_methods_spec.rb
index 19d6bde514..2d3da51147 100644
--- a/backend/spec/features/admin/configuration/payment_methods_spec.rb
+++ b/backend/spec/features/admin/configuration/payment_methods_spec.rb
@@ -3,8 +3,11 @@ require 'spec_helper'
describe 'Payment Methods', type: :feature do
stub_authorization!
+ let!(:store_1) { create(:store) }
+ let!(:store_2) { create(:store) }
+ let!(:store_3) { create(:store) }
+
before do
- create(:store)
visit spree.admin_payment_methods_path
end
@@ -26,7 +29,7 @@ describe 'Payment Methods', type: :feature do
end
end
- context 'admin creating a new payment method' do
+ context 'admin creating a new payment method', js: true do
it 'is able to create a new payment method' do
within find('#contentHeader') do
click_link 'admin_new_payment_methods_link'
@@ -36,10 +39,29 @@ describe 'Payment Methods', type: :feature do
fill_in 'payment_method_name', with: 'check90'
fill_in 'payment_method_description', with: 'check90 desc'
select 'PaymentMethod::Check', from: 'gtwy-type'
- select 'Spree', from: 'store_id'
click_button 'Create'
expect(page).to have_content('successfully created!')
end
+
+ it 'is able to create a new payment method with 2 stores' do
+ within find('#contentHeader') do
+ click_link 'admin_new_payment_methods_link'
+ end
+
+ expect(page).to have_content('New Payment Method')
+ fill_in 'payment_method_name', with: 'check90'
+ fill_in 'payment_method_description', with: 'check90 desc'
+ select 'PaymentMethod::Check', from: 'gtwy-type'
+
+ select2 store_1.unique_name, from: 'Stores'
+ select2 store_3.unique_name, from: 'Stores'
+
+ click_button 'Create'
+ expect(page).to have_content('successfully created!')
+ expect(page).to have_selector('li.select2-selection__choice', text: store_1.unique_name)
+ expect(page).not_to have_selector('li.select2-selection__choice', text: store_2.unique_name)
+ expect(page).to have_selector('li.select2-selection__choice', text: store_3.unique_name)
+ end
end
context 'admin editing a payment method', js: true do