Skip to content

Commit

Permalink
Fill credit card input with force in checkout spec
Browse files Browse the repository at this point in the history
This fixes the flaky spec described into #2910.

Capybara fill_in sometime does not fill the input with the whole
string. This commit will fill it with js bypassing the default
behavior.
  • Loading branch information
kennyadsl committed Oct 11, 2018
1 parent fac5b35 commit 361fc40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/spec/features/checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
choose "use_existing_card_no"

fill_in "Name on card", with: 'Spree Commerce'
fill_in "Card Number", with: '4111 1111 1111 1111'
fill_in_with_force "Card Number", with: '4111 1111 1111 1111'
fill_in "card_expiry", with: '04 / 20'
fill_in "Card Code", with: '123'

Expand Down
12 changes: 12 additions & 0 deletions frontend/spec/support/features/fill_in_with_force.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module FillInWithForce
def fill_in_with_force(locator, with:)
field_id = find_field(locator)[:id]
page.execute_script "document.getElementById('#{field_id}').value = '#{with}';"
end
end

RSpec.configure do |config|
config.include FillInWithForce, type: :feature
end

0 comments on commit 361fc40

Please sign in to comment.