Skip to content

Commit

Permalink
Convert credit cards fill_in into fill_in_with_force
Browse files Browse the repository at this point in the history
These input are controlled by a js plugin (payment.js) that
messes up with Capybara and gives us a lot of flaky specs.

By using this hacky solution we are sure input are filled correctly,
see also solidusio#2911.
  • Loading branch information
kennyadsl committed Apr 4, 2019
1 parent 5068030 commit 7716d9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions backend/spec/features/admin/orders/payments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ def create_payment(opts = {})
end

it "is able to create a new credit card payment with valid information", js: true do
fill_in "Card Number", with: "4111 1111 1111 1111"
fill_in_with_force "Card Number", with: "4111 1111 1111 1111"
fill_in "Name", with: "Test User"
fill_in "Expiration", with: "09 / #{Time.current.year + 1}"
fill_in_with_force "Expiration", with: "09 / #{Time.current.year + 1}"
fill_in "Card Code", with: "007"
# Regression test for https://github.com/spree/spree/issues/4277
expect(page).to have_css('.ccType[value="visa"]', visible: false)
Expand Down Expand Up @@ -290,9 +290,9 @@ def create_payment(opts = {})

it "is able to create a new payment", js: true do
choose payment_method.name
fill_in "Card Number", with: "4111 1111 1111 1111"
fill_in_with_force "Card Number", with: "4111 1111 1111 1111"
fill_in "Name", with: "Test User"
fill_in "Expiration", with: "09 / #{Time.current.year + 1}"
fill_in_with_force "Expiration", with: "09 / #{Time.current.year + 1}"
fill_in "Card Code", with: "007"
click_button "Continue"
expect(page).to have_content("Payment has been successfully created!")
Expand All @@ -319,9 +319,9 @@ def create_payment(opts = {})

it "displays an error" do
choose payment_method.name
fill_in "Card Number", with: "4111 1111 1111 1111"
fill_in_with_force "Card Number", with: "4111 1111 1111 1111"
fill_in "Name", with: "Test User"
fill_in "Expiration", with: "09 / #{Time.current.year + 1}"
fill_in_with_force "Expiration", with: "09 / #{Time.current.year + 1}"
fill_in "Card Code", with: "007"
click_button "Continue"
expect(page).to have_content I18n.t('spree.insufficient_stock_for_order')
Expand Down
8 changes: 4 additions & 4 deletions frontend/spec/features/checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@

choose "Credit Card"
fill_in "Name on card", with: 'Spree Commerce'
fill_in "Card Number", with: '4111 1111 1111 1111'
fill_in "card_expiry", with: '04 / 20'
fill_in_with_force "Card Number", with: '4111 1111 1111 1111'
fill_in_with_force "card_expiry", with: '04 / 20'
fill_in "Card Code", with: '123'
click_button "Save and Continue"

Expand Down Expand Up @@ -680,8 +680,8 @@
end

def fill_in_credit_card(number:)
fill_in "Card Number", with: number
fill_in "Expiration", with: "12 / 24"
fill_in_with_force "Card Number", with: number
fill_in_with_force "Expiration", with: "12 / 24"
fill_in "Card Code", with: "123"
end

Expand Down

0 comments on commit 7716d9c

Please sign in to comment.