Skip to content

Commit

Permalink
Merge pull request #9328 from fouratachour/Displayeachkindofproduct
Browse files Browse the repository at this point in the history
Create a Standard, Pack, Combination and Virtual product and check it in the Front Office
  • Loading branch information
mbadrani committed Sep 14, 2018
2 parents 66815ab + af4b2b5 commit cc61ca6
Show file tree
Hide file tree
Showing 12 changed files with 231 additions and 20 deletions.
98 changes: 91 additions & 7 deletions tests/E2E/test/campaigns/common_scenarios/product.js
Expand Up @@ -175,15 +175,15 @@ module.exports = {
scenario('Check the sort of products by "' + sortBy.toUpperCase() + '"', client => {
test('should click on "Sort by ASC" icon', () => {
let sortSelector = sortBy === 'name' || sortBy === 'reference' ? ProductList.sort_button.replace("%B", sortBy) : sortBy === 'id_product' ? ProductList.sort_by_icon.replace("%B", sortBy).replace("%W", "desc") : ProductList.sort_by_icon.replace("%B", sortBy).replace("%W", "asc");
for (let j = 0; j < global.productsPageNumber; j++) {
for (let j = 0; j < global.productsNumber; j++) {
promise = client.getProductsInformation(selector, j);
}
return promise
.then(() => client.moveToObject(sortSelector))
.then(() => client.waitForExistAndClick(sortSelector));
});
test('should check that the products is well sorted by ASC', () => {
for (let j = 0; j < global.productsPageNumber; j++) {
for (let j = 0; j < global.productsNumber; j++) {
promise = client.getProductsInformation(selector, j, true);
}
return promise
Expand All @@ -196,7 +196,7 @@ module.exports = {
.then(() => client.waitForExistAndClick(ProductList.sort_by_icon.replace("%B", sortBy).replace("%W", "asc")));
});
test('should check that the products is well sorted by DESC', () => {
for (let j = 0; j < global.productsPageNumber; j++) {
for (let j = 0; j < global.productsNumber; j++) {
promise = client.getProductsInformation(selector, j, true);
}
return promise
Expand All @@ -216,7 +216,6 @@ module.exports = {
test('should check that the page value in the URL is equal to "' + pageNumber + '"', () => client.checkParamFromURL('page', pageNumber));
},


checkPaginationBO(nextOrPrevious, pageNumber, itemPerPage, close = false, paginateBetweenPages = false) {
scenario('Navigate between catalog pages and set the paginate limit equal to "' + itemPerPage + '"', client => {
let selectorButton = nextOrPrevious === 'Next' ? ProductList.pagination_next : ProductList.pagination_previous;
Expand All @@ -226,7 +225,7 @@ module.exports = {
test('should check that the number of products is less or equal to "' + itemPerPage + '"', () => {
return promise
.then(() => client.getProductPageNumber('product_catalog_list'))
.then(() => expect(global.productsPageNumber).to.be.at.most(itemPerPage));
.then(() => expect(global.productsNumber).to.be.at.most(itemPerPage));
});
if (paginateBetweenPages) {
/** @todo to be removed when the PR that creates a global variable to determine if we are in the debug mode or not will be merged **/
Expand All @@ -248,11 +247,10 @@ module.exports = {
test('should set the "Page value" input to "' + pageNumber + '"', () => {
return promise
.then(() => client.waitAndSetValue(ProductList.page_active_number, pageNumber))
.then(() => client.keys('Enter'))
.then(() => client.keys('Enter'));
});
test('should check that the current page is equal to "' + pageNumber + '"', () => client.checkAttributeValue(ProductList.page_active_number, 'value', pageNumber, 'contain', 3000));
}

if (close)
test('should set the "item per page" to 20 (back to normal)', () => client.waitAndSelectByValue(ProductList.item_per_page, 20));
}, 'product/product', close);
Expand All @@ -268,5 +266,91 @@ module.exports = {
test('should verify the appearance of the green validation', () => client.checkTextValue(AddProductPage.success_panel, 'Product successfully deleted.'));
test('should click on "Reset" button', () => client.waitForExistAndClick(AddProductPage.catalog_reset_filter));
}, 'product/check_product');
},

checkProductInListFO(AccessPageFO, productPage, productData) {
scenario('Check the created product in the Front Office', () => {

scenario('Login in the Front Office', client => {
test('should login successfully in the Front Office', () => client.signInFO(AccessPageFO));
}, 'product/product');

scenario('Open the created product', client => {
test('should set the language of shop to "English"', () => client.changeLanguage());
test('should click on "SEE ALL PRODUCTS" link', () => client.scrollWaitForExistAndClick(productPage.see_all_products));
for (let i = 0; i <= pagination; i++) {
for (let j = 0; j < 4 ; j++) {
test('should check the ' + productData[j].name + ' product existence in the ' + (Number(i) + 1) + ' page', () => {
return promise
.then(() => client.pause(4000))
.then(() => client.isVisible(productPage.productLink.replace('%PRODUCTNAME', productData[j].name + date_time)));
});
test('should open the product in new tab if exist', () => client.middleClick(productPage.productLink.replace('%PRODUCTNAME', productData[j].name + date_time)));
}
if (i !== pagination) {
test('should click on "NEXT" button', () => {
return promise
.then(() => client.isVisible(productPage.pagination_next))
.then(() => {
if (global.isVisible) {
client.clickPageNext(productPage.pagination_next);
}
});
});
}
}
}, 'product/product');
scenario('Check "standard" product information', client => {
test('should go to the "' + productData[0].name + '" product', () => client.switchWindow(4));
test('should check that the product name is equal to "' + (productData[0].name + date_time).toUpperCase() + '"', () => client.checkTextValue(productPage.product_name, (productData[0].name + date_time).toUpperCase()));
test('should check that the product price is equal to "€12.00"', () => client.checkTextValue(productPage.product_price, "€12.00", "contain"));
test('should check that the product reference is equal to "' + productData[0].reference + '"', () => {
return promise
.then(() => client.scrollTo(productPage.product_reference))
.then(() => client.checkTextValue(productPage.product_reference, productData[0].reference));
});
test('should check that the product quantity is equal to "5"', () => client.checkAttributeValue(productPage.product_quantity, 'data-stock', productData[0].quantity));
}, 'product/product');

scenario('Check "pack" product information', client => {
test('should go to the "' + productData[1].name + '" product', () => client.switchWindow(3));
test('should check that the product name is equal to "' + (productData[1].name + date_time).toUpperCase() + '"', () => client.checkTextValue(productPage.product_name, (productData[1].name + date_time).toUpperCase()));
test('should check that the product price is equal to "€12.00"', () => client.checkTextValue(productPage.product_price, "€12.00", "contain"));
test('should check that the first product pack name is equal to "standard"', () => client.checkTextValue(productPage.pack_product_name.replace('%P', 1), productData[0].name + date_time));
test('should check that the first product pack price is equal to "€12.80"', () => client.checkTextValue(productPage.pack_product_price.replace('%P', 1), '€12.00'));
test('should check that the first product pack quantity is equal to "1"', () => client.checkTextValue(productPage.pack_product_quantity.replace('%P', 1), 'x 1'));
test('should check that the product reference is equal to "' + productData[1].reference + '"', () => {
return promise
.then(() => client.scrollTo(productPage.product_reference))
.then(() => client.checkTextValue(productPage.product_reference, productData[1].reference));
});
test('should check that the product quantity is equal to "5"', () => client.checkAttributeValue(productPage.product_quantity, 'data-stock', productData[1].quantity));
}, 'product/product');

scenario('Check "combination" product information', client => {
test('should go to the "' + productData[2].name + '" product', () => client.switchWindow(2));
test('should check that the product name is equal to "' + (productData[2].name + date_time).toUpperCase() + '"', () => client.checkTextValue(productPage.product_name, (productData[2].name + date_time).toUpperCase()));
test('should check that the product price is equal to "€12.00"', () => client.checkTextValue(productPage.product_price, "€12.00", "contain"));
test('should check that the product reference is equal to "' + productData[2].reference + '"', () => {
return promise
.then(() => client.scrollTo(productPage.product_reference))
.then(() => client.checkTextValue(productPage.product_reference, productData[2].reference));
});
test('should check that the product quantity is equal to "5"', () => client.checkAttributeValue(productPage.product_quantity, 'data-stock', productData[2].quantity));
}, 'product/product');

scenario('Check "virtual" product information', client => {
test('should go to the "' + productData[3].name + '" product', () => client.switchWindow(1));
test('should check that the product name is equal to "' + (productData[3].name + date_time).toUpperCase() + '"', () => client.checkTextValue(productPage.product_name, (productData[3].name + date_time).toUpperCase()));
test('should check that the product price is equal to "€12.00"', () => client.checkTextValue(productPage.product_price, "€12.00", "contain"));
test('should check that the product reference is equal to "' + productData[3].reference + '"', () => {
return promise
.then(() => client.scrollTo(productPage.product_reference))
.then(() => client.checkTextValue(productPage.product_reference, productData[3].reference));
});
test('should check that the product quantity is equal to "5"', () => client.checkAttributeValue(productPage.product_quantity, 'data-stock', productData[3].quantity));
}, 'product/product');

}, 'product/product', true);
}
};
Expand Up @@ -24,7 +24,7 @@ scenario('Navigate between the catalog pages in the back office', () => {
return promise
.then(() => client.getProductPageNumber('product_catalog_list'))
.then(() => {
let productNumber = 20 - global.productsPageNumber;
let productNumber = 20 - global.productsNumber;
if (productNumber !== 0) {
for (let i = 0; i < productNumber + 1; i++) {
commonProduct.createProduct(AddProductPage, productData);
Expand Down
@@ -0,0 +1,108 @@
const {AccessPageBO} = require('../../../selectors/BO/access_page');
const {AccessPageFO} = require('../../../selectors/FO/access_page');
const {AddProductPage} = require('../../../selectors/BO/add_product_page');
const {ProductList} = require('../../../selectors/BO/add_product_page');
const {ProductSettings} = require('../../../selectors/BO/shopParameters/product_settings');
const {productPage} = require('../../../selectors/FO/product_page');
const {Menu} = require('../../../selectors/BO/menu.js');

const commonScenarios = require('../../common_scenarios/product');
const commonAttributeScenarios = require('../../common_scenarios/attribute');

let promise = Promise.resolve();

let attributeData = {
name: 'att',
public_name: 'att',
type: 'color',
values: {
1: 'red',
2: 'yellow',
3: 'green'
}
};

let productData = [{
name: 'Standard',
reference: 'reference',
quantity: '5',
price: '10',
image_name: 'standard.jpg',
type: "standard"
}, {
name: 'Pack',
reference: 'reference',
quantity: '5',
price: '10',
image_name: 'pack.jpeg',
type: "pack",
product: {
name: 'Standard',
quantity: '1'
}
}, {
name: 'Combination',
reference: 'reference',
quantity: '5',
price: '10',
image_name: 'combination.jpg',
attribute: {
name: 'att',
variation_quantity: '5'
}
}, {
name: 'Virtual',
reference: 'reference',
quantity: '5',
price: '10',
image_name: 'music.jpg',
type: 'virtual',
virtual: {
quantity: '5',
minimal_quantity: '1'
}
}];

scenario('Display each kind of product', () => {
scenario('Create a Standard, Pack, Combination and Virtual product ', client => {
scenario('Login in the Back Office', client => {
test('should open the browser', () => client.open());
test('should login successfully in the Back Office', () => client.signInBO(AccessPageBO));
}, 'product/product');
commonScenarios.createProduct(AddProductPage, productData[0]);
commonScenarios.createProduct(AddProductPage, productData[1]);
commonAttributeScenarios.createAttribute(attributeData);
commonScenarios.createProduct(AddProductPage, productData[2]);
commonScenarios.createProduct(AddProductPage, productData[3]);
}, 'product/product');

scenario('Check the product pagination in the Back Office', client => {
test('should go to "Products" page', () => client.goToSubtabMenuPage(Menu.Sell.Catalog.catalog_menu, Menu.Sell.Catalog.products_submenu));
test('should get the product number', () => {
return promise
.then(() => client.isVisible(ProductList.pagination_products))
.then(() => client.getProductsNumber(ProductList.pagination_products))
.then(() => client.isVisible(AddProductPage.symfony_toolbar, 3000))
.then(() => {
if (global.isVisible) {
client.waitForExistAndClick(AddProductPage.symfony_toolbar);
}
});
});
test('should close "catalog" menu', () => client.waitForVisibleAndClick(Menu.Sell.Catalog.catalog_menu));
test('should go to "Shop Parameters - Product Settings" page', () => {
return promise
.then(() => client.pause(3000))
.then(() => client.goToSubtabMenuPage(Menu.Configure.ShopParameters.shop_parameters_menu, Menu.Configure.ShopParameters.product_settings_submenu));
});
test('should get the pagination Products per page value and check the created product in the Front Office', () => {
return promise
.then(() => client.getAttributeInVar(ProductSettings.Pagination.products_per_page_input, "value", "pagination"))
.then(() => {
global.pagination = Number(Math.trunc(Number(global.productsNumber) / Number(global.tab['pagination'])));
commonScenarios.checkProductInListFO(AccessPageFO, productPage, productData);
});
});
}, 'product/product');

}, 'product/product');
Expand Up @@ -72,10 +72,10 @@ scenario('Catalog bulk action', () => {
.then(() => client.getProductPageNumber('product_catalog_list'))
.then(() => client.isVisible(ProductList.pagination_products))
.then(() =>{
if(global.isVisible){
return promise
.then(() => client.checkTextValue(ProductList.pagination_products, parseInt(global.productsPageNumber) + number, 'contain'));
}
if(global.isVisible){
return promise
.then(() => client.checkTextValue(ProductList.pagination_products, parseInt(global.productsNumber) + number, 'contain'));
}
});
});
}, 'catalogbulkaction');
Expand Down
19 changes: 15 additions & 4 deletions tests/E2E/test/clients/common_client.js
Expand Up @@ -297,7 +297,7 @@ class CommonClient {
* @returns {*}
*/
checkFile(folderPath, fileName, pause = 0) {
fs.stat(folderPath + fileName, function(err, stats) {
fs.stat(folderPath + fileName, function (err, stats) {
err === null && stats.isFile() ? global.existingFile = true : global.existingFile = false;
});

Expand Down Expand Up @@ -452,11 +452,11 @@ class CommonClient {
}

stringifyNumber(number) {
let special = ['zeroth','first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth', 'thirteenth', 'fourteenth', 'fifteenth', 'sixteenth', 'seventeenth', 'eighteenth', 'nineteenth'];
let special = ['zeroth', 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth', 'thirteenth', 'fourteenth', 'fifteenth', 'sixteenth', 'seventeenth', 'eighteenth', 'nineteenth'];
let deca = ['twent', 'thirt', 'fort', 'fift', 'sixt', 'sevent', 'eight', 'ninet'];
if (number < 20) return special[number];
if (number%10 === 0) return deca[Math.floor(number/10)-2] + 'ieth';
return deca[Math.floor(number/10)-2] + 'y-' + special[number%10];
if (number % 10 === 0) return deca[Math.floor(number / 10) - 2] + 'ieth';
return deca[Math.floor(number / 10) - 2] + 'y-' + special[number % 10];
}

/**
Expand Down Expand Up @@ -497,6 +497,17 @@ class CommonClient {
.refresh();
}

middleClick(selector, pause = 2000) {
if (global.isVisible) {
return this.client
.moveToObject(selector)
.pause(pause)
.middleClick(selector);
} else {
return this.client.pause(1000);
}
}

getParamFromURL(param, pause = 0) {
return this.client
.pause(pause)
Expand Down
13 changes: 10 additions & 3 deletions tests/E2E/test/clients/product/product.js
Expand Up @@ -167,7 +167,7 @@ class Product extends CommonClient {
return count;
}, selector)
.then((count) => {
global.productsPageNumber = count.value;
global.productsNumber = count.value;
});
}

Expand Down Expand Up @@ -222,7 +222,7 @@ class Product extends CommonClient {
this.client
.waitUntil(function () {
sort_mode === 'ASC' ? this.sortByAsc(type) : this.sortByDesc(type);
}, 1000 * global.productsPageNumber);
}, 1000 * global.productsNumber);
});
}

Expand All @@ -237,10 +237,17 @@ class Product extends CommonClient {
this.client
.waitUntil(function () {
expect(productsTable).to.deep.equal(productsSortedTable);
}, 1000 * global.productsPageNumber);
}, 1000 * global.productsNumber);
});
}

clickPageNext(selector) {
if (global.isVisible) {
return this.client
.scrollWaitForExistAndClick(selector);
}
}

UrlModification(globalVar, productName) {
return this.client
.pause(1000)
Expand Down
Binary file added tests/E2E/test/datas/combination.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/E2E/test/datas/music.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/E2E/test/datas/pack.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/E2E/test/datas/standard.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/E2E/test/selectors/BO/menu.js
Expand Up @@ -120,4 +120,4 @@ module.exports = {
}
}
}
};
};
1 change: 1 addition & 0 deletions tests/E2E/test/selectors/FO/product_page.js
Expand Up @@ -29,6 +29,7 @@ module.exports = {
product_availability_message: '//*[@id="product-availability"]',
product_summary: '(//*[@itemprop="description"]//p)[1]',
product_description: '//*[@id="description"]',
productLink: '//*[@id="js-product-list"]//div[contains(class, highlighted-informations)]//a[contains(text(), "%PRODUCTNAME")]',
product_detail_tab: '//*[@role="tablist"]//li[2]',
attachments_tab: '//*[@id="main"]//div[@class="product-information"]//a[@aria-controls="attachments"]',
product_footer_linkwidget:'//*[@id="main"]/div[2]//p[contains(text(),"%DISPLAYFOOTERPRODUCT")]',
Expand Down

0 comments on commit cc61ca6

Please sign in to comment.