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

Added test for shopping cart events #6168

Merged
merged 1 commit into from Sep 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/Selenium/fixtures.js
Expand Up @@ -29,7 +29,8 @@ module.exports = {
aCategoryWithProducts: '/en/3-women',
identity: '/en/identity',
adminLogin: '/admin-dev',
guestTracking: '/en/guest-tracking'
guestTracking: '/en/guest-tracking',
cart: '/en/cart'
},
customer: {
email: 'pub@prestashop.com',
Expand Down
77 changes: 77 additions & 0 deletions tests/Selenium/specs/cart.js
@@ -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.');
});
})
});
});
}