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.

Adds more specs

Robert Nowakowski347dba9b2a64
diff --git a/api/spec/controllers/spree/api/v1/users_controller_spec.rb b/api/spec/controllers/spree/api/v1/users_controller_spec.rb
index 5c29f286a0..588e67e1da 100644
--- a/api/spec/controllers/spree/api/v1/users_controller_spec.rb
+++ b/api/spec/controllers/spree/api/v1/users_controller_spec.rb
@@ -121,6 +121,8 @@ module Spree
let!(:second_user) { create(:user, bill_address: second_bill_address, email: '[email protected]') }
before do
+ first_user.addresses << first_bill_address
+ second_user.addresses << second_bill_address
allow(Spree::LegacyUser).to receive(:find_by).with(hash_including(:spree_api_key)) { current_api_user }
end
diff --git a/backend/spec/features/admin/promotions/user_rule_spec.rb b/backend/spec/features/admin/promotions/user_rule_spec.rb
index a8291a95b8..40e8f155d2 100644
--- a/backend/spec/features/admin/promotions/user_rule_spec.rb
+++ b/backend/spec/features/admin/promotions/user_rule_spec.rb
@@ -6,6 +6,8 @@ describe 'Promotion with user rule', type: :feature, js: true do
let!(:first_user) { create(:user, email: '[email protected]') }
let!(:second_user) { create(:user, email: '[email protected]') }
let!(:third_user) { create(:user, email: '[email protected]') }
+ let!(:fourth_user) { create(:user, email: '[email protected]') }
+ let!(:fifth_user) { create(:user, email: '[email protected]') }
before do
visit spree.new_admin_promotion_path
@@ -23,6 +25,9 @@ describe 'Promotion with user rule', type: :feature, js: true do
find('.user_picker').fill_in with: 'first'
expect(page).to have_content('[email protected]')
+ expect(page).not_to have_content('[email protected]')
+ expect(page).not_to have_content('[email protected]')
+
within('#select2-drop') do
first('.select2-result').click
end
@@ -32,4 +37,31 @@ describe 'Promotion with user rule', type: :feature, js: true do
expect(page).to have_content('Promotion "User promotion" has been successfully updated!')
end
+
+ it 'user dropdown shows user emails that matches user query #1' do
+ fill_in 'Name', with: 'User promotion'
+ click_button 'Create'
+
+ select2 'User', from: 'Add rule of type', match: :first
+ within('#rule_fields') { click_button 'Add' }
+
+ find('.user_picker').fill_in with: 'example'
+
+ expect(page).to have_content('[email protected]')
+ expect(page).to have_content('[email protected]')
+ expect(page).to have_content('[email protected]')
+ end
+
+ it 'user dropdown shows user emails that matches user query #2' do
+ fill_in 'Name', with: 'User promotion'
+ click_button 'Create'
+
+ select2 'User', from: 'Add rule of type', match: :first
+ within('#rule_fields') { click_button 'Add' }
+
+ find('.user_picker').fill_in with: 'test'
+
+ expect(page).to have_content('[email protected]')
+ expect(page).to have_content('[email protected]')
+ end
end