-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dedupe shared code in checkout specs
- Loading branch information
1 parent
df1dc42
commit 78b5e66
Showing
4 changed files
with
62 additions
and
102 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
lib/solidus_stripe/testing_support/stripe_checkout_helper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
module StripeCheckoutHelper | ||
def initialize_checkout | ||
FactoryBot.create(:store) | ||
zone.members << Spree::ZoneMember.create!(zoneable: country) | ||
FactoryBot.create(:free_shipping_method) | ||
|
||
Spree::PaymentMethod::StripeCreditCard.create!( | ||
name: "Stripe", | ||
preferred_secret_key: "sk_test_VCZnDv3GLU15TRvn8i2EsaAN", | ||
preferred_publishable_key: "pk_test_Cuf0PNtiAkkMpTVC2gwYDMIg", | ||
preferred_v3_elements: preferred_v3_elements, | ||
preferred_v3_intents: preferred_v3_intents | ||
) | ||
|
||
FactoryBot.create(:product, name: "DL-44") | ||
|
||
visit spree.root_path | ||
click_link "DL-44" | ||
click_button "Add To Cart" | ||
|
||
expect(page).to have_current_path("/cart") | ||
click_button "Checkout" | ||
|
||
expect(page).to have_current_path("/checkout/registration") | ||
click_link "Create a new account" | ||
within("#new_spree_user") do | ||
fill_in "Email", with: "[email protected]" | ||
fill_in "Password", with: "superStrongPassword" | ||
fill_in "Password Confirmation", with: "superStrongPassword" | ||
end | ||
click_button "Create" | ||
|
||
# Address | ||
expect(page).to have_current_path("/checkout/address") | ||
|
||
within("#billing") do | ||
fill_in_name | ||
fill_in "Street Address", with: "YT-1300" | ||
fill_in "City", with: "Mos Eisley" | ||
select "United States of America", from: "Country" | ||
select country.states.first.name, from: "order_bill_address_attributes_state_id" | ||
fill_in "Zip", with: "12010" | ||
fill_in "Phone", with: "(555) 555-5555" | ||
end | ||
click_on "Save and Continue" | ||
|
||
# Delivery | ||
expect(page).to have_current_path("/checkout/delivery") | ||
expect(page).to have_content("UPS Ground") | ||
click_on "Save and Continue" | ||
|
||
# Payment | ||
expect(page).to have_current_path("/checkout/payment") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,57 +9,7 @@ | |
let(:card_3d_secure) { "4000 0025 0000 3155" } | ||
|
||
before do | ||
FactoryBot.create(:store) | ||
zone.members << Spree::ZoneMember.create!(zoneable: country) | ||
FactoryBot.create(:free_shipping_method) | ||
|
||
Spree::PaymentMethod::StripeCreditCard.create!( | ||
name: "Stripe", | ||
preferred_secret_key: "sk_test_VCZnDv3GLU15TRvn8i2EsaAN", | ||
preferred_publishable_key: "pk_test_Cuf0PNtiAkkMpTVC2gwYDMIg", | ||
preferred_v3_elements: preferred_v3_elements, | ||
preferred_v3_intents: preferred_v3_intents | ||
) | ||
|
||
FactoryBot.create(:product, name: "DL-44") | ||
|
||
visit spree.root_path | ||
click_link "DL-44" | ||
click_button "Add To Cart" | ||
|
||
expect(page).to have_current_path("/cart") | ||
click_button "Checkout" | ||
|
||
expect(page).to have_current_path("/checkout/registration") | ||
click_link "Create a new account" | ||
within("#new_spree_user") do | ||
fill_in "Email", with: "[email protected]" | ||
fill_in "Password", with: "superStrongPassword" | ||
fill_in "Password Confirmation", with: "superStrongPassword" | ||
end | ||
click_button "Create" | ||
|
||
# Address | ||
expect(page).to have_current_path("/checkout/address") | ||
|
||
within("#billing") do | ||
fill_in_name | ||
fill_in "Street Address", with: "YT-1300" | ||
fill_in "City", with: "Mos Eisley" | ||
select "United States of America", from: "Country" | ||
select country.states.first.name, from: "order_bill_address_attributes_state_id" | ||
fill_in "Zip", with: "12010" | ||
fill_in "Phone", with: "(555) 555-5555" | ||
end | ||
click_on "Save and Continue" | ||
|
||
# Delivery | ||
expect(page).to have_current_path("/checkout/delivery") | ||
expect(page).to have_content("UPS Ground") | ||
click_on "Save and Continue" | ||
|
||
# Payment | ||
expect(page).to have_current_path("/checkout/payment") | ||
initialize_checkout | ||
end | ||
|
||
# This will fetch a token from Stripe.com and then pass that to the webserver. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,57 +9,8 @@ | |
let(:country) { FactoryBot.create(:country) } | ||
|
||
before do | ||
FactoryBot.create(:store) | ||
zone.members << Spree::ZoneMember.create!(zoneable: country) | ||
FactoryBot.create(:free_shipping_method) | ||
initialize_checkout | ||
|
||
Spree::PaymentMethod::StripeCreditCard.create!( | ||
name: "Stripe", | ||
preferred_secret_key: "sk_test_VCZnDv3GLU15TRvn8i2EsaAN", | ||
preferred_publishable_key: "pk_test_Cuf0PNtiAkkMpTVC2gwYDMIg", | ||
preferred_v3_elements: preferred_v3_elements, | ||
preferred_v3_intents: preferred_v3_intents | ||
) | ||
|
||
FactoryBot.create(:product, name: "DL-44") | ||
|
||
visit spree.root_path | ||
click_link "DL-44" | ||
click_button "Add To Cart" | ||
|
||
expect(page).to have_current_path("/cart") | ||
click_button "Checkout" | ||
|
||
expect(page).to have_current_path("/checkout/registration") | ||
click_link "Create a new account" | ||
within("#new_spree_user") do | ||
fill_in "Email", with: "[email protected]" | ||
fill_in "Password", with: "superStrongPassword" | ||
fill_in "Password Confirmation", with: "superStrongPassword" | ||
end | ||
click_button "Create" | ||
|
||
# Address | ||
expect(page).to have_current_path("/checkout/address") | ||
|
||
within("#billing") do | ||
fill_in_name | ||
fill_in "Street Address", with: "YT-1300" | ||
fill_in "City", with: "Mos Eisley" | ||
select "United States of America", from: "Country" | ||
select country.states.first.name, from: "order_bill_address_attributes_state_id" | ||
fill_in "Zip", with: "12010" | ||
fill_in "Phone", with: "(555) 555-5555" | ||
end | ||
click_on "Save and Continue" | ||
|
||
# Delivery | ||
expect(page).to have_current_path("/checkout/delivery") | ||
expect(page).to have_content("UPS Ground") | ||
click_on "Save and Continue" | ||
|
||
# Payment | ||
expect(page).to have_current_path("/checkout/payment") | ||
fill_in_card | ||
click_button "Save and Continue" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters