Skip to content

Instantly share code, notes, and snippets.

@jasonfb
Created June 28, 2016 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonfb/986b99a459308ca2ade4212900d740f6 to your computer and use it in GitHub Desktop.
Save jasonfb/986b99a459308ca2ade4212900d740f6 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe "cart to registration page", :js => true do
let (:boxer_briefs_18_hour) { FactoryGirl.create(:boxer_briefs_18_hour) }
before(:each) do
FactoryGirl.create(:style_categories_taxonomy)
FactoryGirl.create(:active_home_page)
FactoryGirl.create(:gallery_bucket)
FactoryGirl.create(:promo_bucket)
FactoryGirl.create(:country, :name => "United States",
:iso_name => "US")
FactoryGirl.create(:country, :name => "Canada",
:iso_name => "CA")
style_categories_taxonomy = FactoryGirl.create(:style_categories_taxonomy)
underwear_taxon = FactoryGirl.create(:underwear_taxon, :taxonomy => style_categories_taxonomy)
boxer_briefs_taxon = FactoryGirl.create(:boxer_briefs_taxon, :taxonomy => style_categories_taxonomy)
underwear_taxon.children << boxer_briefs_taxon
style_categories_taxonomy.root.children << underwear_taxon
boxer_briefs_18_hour
boxer_briefs_18_hour.taxons << boxer_briefs_taxon
Spree::RelationType.create(name: "Up Sells", applies_to: "Spree::Product")
Spree::RelationType.create(name: "Cross Sells", applies_to: "Spree::Product")
option_color = FactoryGirl.create(:option_type, :position => 1)
option_size = FactoryGirl.create(:size , :position => 2)
boxer_briefs_18_hour.option_types << option_color
boxer_briefs_18_hour.option_types << option_size
boxer_briefs_18_hour.option_values << FactoryGirl.create(:option_value, name: "Blue Night", presentation: "Blue Night", option_type: option_color, position: 1)
boxer_briefs_18_hour.option_values << FactoryGirl.create(:size_option_value, name: "S", presentation: "S", option_type: option_size, position: 1)
boxer_briefs_18_hour.option_values << FactoryGirl.create(:option_value, name: "Bright White", presentation: "Bright White", option_type: option_color, position: 2)
boxer_briefs_18_hour.option_values << FactoryGirl.create(:size_option_value, name: "M", presentation: "M", option_type: option_size, position: 2)
build_variants(boxer_briefs_18_hour)
write_to_cache
end
describe "as someone not logged in" do
let(:order) { FactoryGirl.create(:order_below_100,
line_items: [ FactoryGirl.create(:boxer_brief_line_item,
quantity: 2,
variant: boxer_briefs_18_hour.variants.first ) ]
) }
let(:user) { FactoryGirl.create(:user) }
describe "with jerry-rigged authentication" do
before(:each) do
Settings.should_receive(:host).at_least(:once).and_return("127.0.0.1")
allow(SecureRandom).to receive(:urlsafe_base64)
.with(any_args)
.and_return(order.guest_token)
permanent_cookies = double(:permanent_cookies, :signed => {:guest_token => order.guest_token})
allow_any_instance_of(Spree::OrdersController)
.to receive(:cookies)
.and_return(double(:cookies,
:[] => {:vanity_id => "abc"},
:signed => {:guest_token => order.guest_token},
:permanent => permanent_cookies))
end
describe "for the legacy ATC experience" do
it "should let me add something to my cart" do
visit "/products/boxer-briefs"
wait_for_mw_app
wait_for_ajax
expect(page).to have_content "18 HOUR JERSEY"
wait_for_ajax
within('.available-colors') do
find(:xpath, "//a[@data-name='Blue Night']").click
end
within('.available-sizes') do
find(:xpath, '//a[@data-size="S"]').click
end
#
# if( page.evaluate_script("$('body').hasClass('minicart-experience')") == true)
# raise "minicart-experience applied in spec where it shouldn't be"
# end
within('.pdp-add-to-cart-container') do
find_button("Add to cart").click
end
sleep 1
wait_for_ajax
sleep 1
expect(page).to have_content("1x Blue Night 18 Hour Jersey has just been added to your cart")
sleep 5
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment