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.

[SD-915] Adds specs for creating promotion with user rule

Robert Nowakowski60e6c58ff70d
diff --git a/backend/spec/features/admin/promotions/user_rule_spec.rb b/backend/spec/features/admin/promotions/user_rule_spec.rb
new file mode 100644
index 0000000000..a8291a95b8
--- /dev/null
+++ b/backend/spec/features/admin/promotions/user_rule_spec.rb
@@ -0,0 +1,35 @@
+require 'spec_helper'
+
+describe 'Promotion with user rule', type: :feature, js: true do
+ stub_authorization!
+
+ let!(:first_user) { create(:user, email: '[email protected]') }
+ let!(:second_user) { create(:user, email: '[email protected]') }
+ let!(:third_user) { create(:user, email: '[email protected]') }
+
+ before do
+ visit spree.new_admin_promotion_path
+ end
+
+ it 'creates new promotion with user rule' do
+ fill_in 'Name', with: 'User promotion'
+ click_button 'Create'
+
+ expect(page).to have_content('Promotion "User promotion" has been successfully created!')
+
+ select2 'User', from: 'Add rule of type', match: :first
+ within('#rule_fields') { click_button 'Add' }
+
+ find('.user_picker').fill_in with: 'first'
+ expect(page).to have_content('[email protected]')
+
+ within('#select2-drop') do
+ first('.select2-result').click
+ end
+
+ wait_for { !page.has_button?('Update') }
+ within('#rules_container') { click_button 'Update' }
+
+ expect(page).to have_content('Promotion "User promotion" has been successfully updated!')
+ end
+end