Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6168 from thierrymarianne/test-cart
Added test for shopping cart events
- Loading branch information
Showing
2 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
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
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,77 @@ | ||
/* global describe, it, before, after, browser */ | ||
|
||
import fixtures from '../fixtures'; | ||
import * as checkout from '../helpers/checkout'; | ||
|
||
describe("The shopping cart", function () { | ||
runScenario(); | ||
}); | ||
|
||
function runScenario () { | ||
describe('Add product to cart as a guest', function () { | ||
|
||
let cartSelector = '.js-cart'; | ||
let cartProductCountSelector = '.cart-products-count'; | ||
let increaseProductQuantitySelector = '.bootstrap-touchspin-up'; | ||
let decreaseProductQuantitySelector = '.bootstrap-touchspin-down'; | ||
let removeProductFromCartSelector = '.remove-from-cart'; | ||
let cartItemSelector = '.cart-item'; | ||
|
||
before(function () { | ||
return Promise.all([ | ||
checkout.addSomeProductToCart() | ||
]).then(() => browser.url(fixtures.urls.cart)); | ||
}); | ||
|
||
after(function () { | ||
return browser.deleteCookie().url('/'); | ||
}); | ||
|
||
describe("The shopping cart UI", function () { | ||
it('should display the cart', function () { | ||
return browser.waitForVisible(cartSelector); | ||
}); | ||
|
||
it('should display the product quantity', function () { | ||
return browser.getText(cartProductCountSelector).then(function (text) { | ||
return text === '(1)'; | ||
}); | ||
}); | ||
|
||
describe('The quantity input spinner', function () { | ||
it('should increase the product quantity', function () { | ||
return browser | ||
.click(increaseProductQuantitySelector) | ||
.waitUntil(function async () { | ||
return browser.getText(cartProductCountSelector).then(function (text) { | ||
return text === '(2)'; | ||
}); | ||
}, 5000, 'The cart product quantity should have been increased.'); | ||
}); | ||
|
||
it('should decrease the product quantity', function () { | ||
return browser | ||
.click(decreaseProductQuantitySelector) | ||
.waitUntil(function async () { | ||
return browser.getText(cartProductCountSelector).then(function (text) { | ||
return text === '(1)'; | ||
}) | ||
}, 5000, 'The cart product quantity should have been decreased.'); | ||
}); | ||
}); | ||
|
||
describe('The remove from cart button', function () { | ||
it('should remove a product from the cart', function () { | ||
return browser | ||
.click(removeProductFromCartSelector) | ||
.waitForVisible(cartItemSelector, 2000, true) // Wait for cart item to be invisible | ||
.waitUntil(function async () { | ||
return browser.getText(cartProductCountSelector).then(function (text) { | ||
return text === '(0)'; | ||
}); | ||
}, 5000, 'The cart product quantity should have been zeroed.'); | ||
}); | ||
}) | ||
}); | ||
}); | ||
} |