Replace sleep with wait, add cart_dirty spec helper

This commit is contained in:
Rohan Mitchell
2014-07-31 11:36:34 +10:00
parent 126e0a1f6d
commit a1dd5dabac
3 changed files with 8 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
%span.cart-span{"ng-controller" => "CartCtrl"}
%span.cart-span{"ng-controller" => "CartCtrl", "ng-class" => "{ dirty: Cart.dirty }"}
%a#cart.icon{cart: true}
%span.nav-branded
%i.ofn-i_027-shopping-cart

View File

@@ -139,7 +139,9 @@ feature "As a consumer I want to shop with a distributor", js: true do
it "should save group buy data to ze cart" do
fill_in "variants[#{product.master.id}]", with: 5
fill_in "variant_attributes[#{product.master.id}][max_quantity]", with: 9
sleep 5
wait_until { !cart_dirty }
li = Spree::Order.order(:created_at).last.line_items.order(:created_at).last
li.max_quantity.should == 9
li.quantity.should == 5

View File

@@ -68,6 +68,10 @@ module UIComponentHelper
find("#cart").click
end
def cart_dirty
page.find("span.cart-span")[:class].include? 'dirty'
end
def wait_for_ajax
counter = 0
while page.execute_script("return $.active").to_i > 0