Skip to content

Commit

Permalink
Adds payment method test cases w/transaction fees
Browse files Browse the repository at this point in the history
  • Loading branch information
filipefurtad0 committed Jan 29, 2022
1 parent 2f85f75 commit bddb642
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions spec/system/consumer/split_checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
name: "Shipping with Fee", description: "blue",
calculator: Calculator::FlatRate.new(preferred_amount: 4.56))
}
let!(:payment_method) { create(:payment_method, distributors: [distributor]) }
let!(:check_without_fee) { create(:payment_method, distributors: [distributor], name: "Euro") }
let!(:check_with_fee) {
create(:payment_method, distributors: [distributor],
calculator: Calculator::FlatRate.new(preferred_amount: 5.67), name: "Crypto") }

before do
allow(Flipper).to receive(:enabled?).with(:split_checkout).and_return(true)
Expand Down Expand Up @@ -226,15 +229,36 @@

context "payment step" do
let(:order) { create(:order_ready_for_payment, distributor: distributor) }
describe "selecting a Cash payment method" do

describe "selecting a free Cash payment method" do

before do
choose "Check"
before do
choose "Euro (Free)"
end

it "proceeds to the summary step" do
click_on "Next - Order summary"
expect(page).to have_content "Euro"
expect(page).to have_content "Back to Payment method"
end
end

it "selects cash and proceeds to the summary step" do
describe "selecting a Cash payment method with fee" do

before do
choose "Crypto (#{with_currency(5.67)})"
end

it "proceeds to the summary step and includes the transaction fee in the order totals " do
click_on "Next - Order summary"
expect(page).to have_content "Shopping @ #{distributor.name}"
expect(page).to have_content "Crypto"
expect(page).to have_selector "tr.total", text: with_currency(5.67)

#expect(order.total).to eq(10 + 5.67) # items + transaction fee
transaction_fee = Spree::Adjustment.where(label: "Transaction fee").pluck(:amount).first
order_total = order.total + transaction_fee
expect(page).to have_selector "#order_total", text: with_currency(order_total)
expect(page).to have_content "Back to Payment method"
end
end
end
Expand Down

0 comments on commit bddb642

Please sign in to comment.