Skip to content

Commit

Permalink
Merge pull request #33 from fatmaBouchekoua/fix-9405
Browse files Browse the repository at this point in the history
Fix 9405 as the behavior has changed
  • Loading branch information
mbadrani committed Sep 6, 2018
2 parents b447907 + 8577402 commit e455f4e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
34 changes: 19 additions & 15 deletions test/mocha/campaigns/PR/9405.js
@@ -1,22 +1,26 @@
const {ProductPageFO} = require('../../selectors/FO/productPage');
const {HomePage} = require('../../selectors/FO/homePage');
const {ShoppingCartPage} = require('../../selectors/FO/shoppingCartPage');
const authentication = require('../common_scenarios/authentication');
let quantity = '0';

scenario('This scenario is based on the bug described on his PR: https://github.com/PrestaShop/PrestaShop/pull/9405', client => {
scenario('This scenario is based on the bug described on his PR: https://github.com/PrestaShop/PrestaShop/pull/9405', () => {
authentication.openShop('9405');
test('should set the language of shop to "English"', () => client.switchShopLanguageInFo('en'));
test('should go to the first product page', () => client.waitForAndClick(ProductPageFO.first_product));
test('should set the quantity input by clicking on "arrow up button"', () => client.waitForAndClick(ShoppingCartPage.arrow_button_up));
test('should click on "ADD TO CART" button', () => client.waitForAndClick(ShoppingCartPage.add_to_cart_button));
test('should click on "PROCEED TO CHECKOUT" button', () => client.waitForAndClick(ShoppingCartPage.proceed_to_checkout_button, 2000, {visible: true}));
test('should set the quantity equal to ' + quantity, async () => {
await client.eval(ShoppingCartPage.quantity_input, quantity);
await client.waitForAndClick(ShoppingCartPage.quantity_input);
await client.keyboardPress('Enter');
});
test('should check that the quantity is equal to ' + quantity, () => client.checkTextValue(ShoppingCartPage.cart_products_count, quantity, 'contain', 2000));
test('should click on the product name', () => client.waitForAndClick(ShoppingCartPage.product_name));
test('should click on "ADD TO CART" button', () => client.waitForAndClick(ShoppingCartPage.add_to_cart_button));
test('should check the existence of the "block cart modal"', () => client.isExisting(ShoppingCartPage.block_cart));
scenario('Check the existence of the "block cart modal"', client => {
test('should set the language of shop to "English"', () => client.switchShopLanguageInFo('en'));
test('should go to the first product page', () => client.waitForAndClick(ProductPageFO.first_product));
test('should set the quantity input by clicking on "arrow up button"', () => client.waitForAndClick(ShoppingCartPage.arrow_button_up));
test('should click on "ADD TO CART" button', () => client.waitForAndClick(ShoppingCartPage.add_to_cart_button));
test('should click on "PROCEED TO CHECKOUT" button', () => client.waitForAndClick(ShoppingCartPage.proceed_to_checkout_button, 2000, {visible: true}));
test('should set the quantity equal to ' + quantity, async () => {
await client.eval(ShoppingCartPage.quantity_input, quantity);
await client.waitForAndClick(ShoppingCartPage.quantity_input);
await client.keyboardPress('Enter');
});
test('should check that the quantity is equal to ' + quantity, () => client.checkTextValue(ShoppingCartPage.cart_products_count, quantity, 'contain', 2000));
test('should go to the "Home" page', () => client.waitForAndClick(HomePage.logo_home_page));
test('should go to the first product page', () => client.waitForAndClick(ProductPageFO.first_product));
test('should click on "ADD TO CART" button', () => client.waitForAndClick(ShoppingCartPage.add_to_cart_button));
test('should check the existence of the "block cart modal"', () => client.isExisting(ShoppingCartPage.block_cart, 3000));
}, 'common_client');
}, 'common_client', true);
6 changes: 4 additions & 2 deletions test/mocha/clients/common_client.js
Expand Up @@ -244,12 +244,14 @@ class CommonClient {
});
}

async isExisting(selector) {
async isExisting(selector, wait = 0) {
await page.waitFor(wait);
const exists = await page.$(selector) !== null;
expect(exists).to.be.true;
}

async isNotExisting(selector) {
async isNotExisting(selector, wait = 0) {
await page.waitFor(wait);
const exists = await page.$(selector) === null;
expect(exists).to.be.true;
}
Expand Down

0 comments on commit e455f4e

Please sign in to comment.