Skip to content

Commit

Permalink
spec fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
damianlegawiec committed Apr 30, 2024
1 parent 5053784 commit ca5a9b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ else
gem 'sqlite3', '~> 1.4'
end

gem 'webdrivers'

gemspec
21 changes: 6 additions & 15 deletions spec/features/admin/stripe_elements_payment_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe 'Admin Panel Stripe elements payment', type: :feature do
describe 'Admin Panel Stripe elements payment', type: :feature, js: true do
stub_authorization!

let!(:country) { create(:country, states_required: true) }
Expand Down Expand Up @@ -53,14 +53,8 @@
it 'shows an error with an invalid card expiration' do
fill_in_stripe_payment(false, false, false, true)

if Spree.version.to_f >= 4.1 || Spree.version.to_f >= 3.7
expect(page).to have_content('Credit card Month is not a number')
expect(page).to have_content('Credit card Year is not a number')
expect(page).to have_current_path spree.admin_order_payments_path(order.number)
else
expect(page).to have_content("Your card's expiration year is invalid.")
expect(page).to have_current_path spree.new_admin_order_payment_path(order.number)
end
expect(page).to have_content('Credit card Month is not a number')
expect(page).to have_content('Credit card Year is not a number')
end

def fill_in_stripe_payment(invalid_name = false, invalid_number = false, invalid_code = false, invalid_expiration = false)
Expand All @@ -78,18 +72,15 @@ def fill_in_card_number(invalid_number)
end

def fill_in_card_expiration(invalid_expiration)
valid_expiry = Spree.version.to_f >= 4.2 ? "01/#{Time.current.year + 1}" : "01 / #{Time.current.year + 1}"
invalid_expiry = Spree.version.to_f >= 4.2 ? '01/' : '01 / '
card_expiry = invalid_expiration ? '01/' : "01/#{Time.current.year + 1}"

card_expiry = invalid_expiration ? invalid_expiry : valid_expiry
fill_in_field('Expiration *', "#card_expiry#{stripe_elements_payment_method.id}", card_expiry)
find('#card_expiry1').fill_in with: card_expiry
end

def fill_in_cvc(invalid_code)
value = invalid_code ? '1' : '123'
label = Spree.version.to_f >= 4.2 ? 'Card Varification Code (CVC) *' : 'Card Code *'

fill_in label, with: value
find('#card_code1').fill_in with: value
end

def fill_in_field(field_name, field_id, number)
Expand Down

0 comments on commit ca5a9b5

Please sign in to comment.