Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix feature spec #200

Open
wants to merge 1 commit into
base: 1-3-stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ gem 'sqlite3'
gem 'pg'
gem 'database_cleaner', '1.0.1'

gem 'rake', '10.1.0'

group :test do
gem 'yarjuf'
gem 'require_all'
Expand Down
2 changes: 2 additions & 0 deletions Versionfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file is needed to make `rake test_app` generates propper path for Gemfile
# See https://github.com/degica/liquidus/blob/master/core/lib/generators/spree/dummy/dummy_generator.rb#L99
71 changes: 55 additions & 16 deletions spec/features/paypal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,54 @@ def fill_in_billing
def switch_to_paypal_login
# If you go through a payment once in the sandbox, it remembers your preferred setting.
# It defaults to the *wrong* setting for the first time, so we need to have this method.
unless page.has_selector?("#login_email")
find("#loadLogin").click
sleep 3
if page.has_selector?(".baslLoginButtonContainer a")
login_button = find(".baslLoginButtonContainer a")
sleep 3 # wait for click handler ready
login_button.click
end
end

def pay_with_paypal_account
if page.has_selector?("#injectedUnifiedLogin iframe")
frame = find("#injectedUnifiedLogin iframe")
sleep 3 # wait for the frame contents ready
within_frame(frame) do
fill_in "login_email", :with => "[email protected]"
fill_in "login_password", :with => "thequickbrownfox"
sleep 5
click_button "Log In"
end
end
sleep 3
find('#button.reviewButton', wait: 120) # wait for the next button appears
sleep 5 # wait for click handler ready
click_button "Pay Now"
end

def confirm_success
find('.flash.notice', wait: 60)
page.should have_content("Your order has been processed successfully", wait: 60)
end

def check_minicart(&block)
minicart = find('#transactionCart', wait: 60)
sleep 3 # wait for dropdown ready
if minicart.has_selector?('.arrow', wait: 10)
sleep 5 # wait for click handler ready
find('.arrow').click # show the details
sleep 3 # wait for dropdown items shown
find('.detail-items', wait: 60) # wait for the dropdown appears
within(find('.detail-items')) do
block.call
end
else
within(minicart) do
block.call
end
end
end

it "pays for an order successfully" do
visit spree.root_path
click_link 'iPad'
Expand All @@ -54,11 +98,8 @@ def switch_to_paypal_login
click_button "Save and Continue"
find("#paypal_button").click
switch_to_paypal_login
fill_in "login_email", :with => "[email protected]"
fill_in "login_password", :with => "thequickbrownfox"
click_button "Log In"
find("#continue_abovefold").click # Because there's TWO continue buttons.
page.should have_content("Your order has been processed successfully")
pay_with_paypal_account
confirm_success

Spree::Payment.last.source.transaction_id.should_not be_blank
end
Expand Down Expand Up @@ -86,7 +127,8 @@ def switch_to_paypal_login
# Delivery step doesn't require any action
click_button "Save and Continue"
find("#paypal_button").click
within("#miniCart") do

check_minicart do
page.should have_content("$5 off")
page.should have_content("$10 on")
end
Expand Down Expand Up @@ -118,7 +160,7 @@ def switch_to_paypal_login
# Delivery step doesn't require any action
click_button "Save and Continue"
find("#paypal_button").click
within("#miniCart") do
check_minicart do
page.should have_content('iPad')
page.should_not have_content('iPod')
end
Expand Down Expand Up @@ -150,8 +192,8 @@ def switch_to_paypal_login
# Delivery step doesn't require any action
click_button "Save and Continue"
find("#paypal_button").click
within("#miniCart") do
page.should have_content('Current purchase')
check_minicart do
page.should have_content('$10.00 USD')
end
end
end
Expand Down Expand Up @@ -199,11 +241,8 @@ def switch_to_paypal_login
click_button "Save and Continue"
find("#paypal_button").click
switch_to_paypal_login
fill_in "login_email", :with => "[email protected]"
fill_in "login_password", :with => "thequickbrownfox"
click_button "Log In"
find("#continue_abovefold").click # Because there's TWO continue buttons.
page.should have_content("Your order has been processed successfully")
pay_with_paypal_account
confirm_success

visit '/admin'
click_link Spree::Order.last.number
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# require 'capybara/poltergeist'

# Capybara.javascript_driver = :poltergeist
Capybara.default_wait_time = 15
Capybara.default_max_wait_time = 15

Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }

Expand Down