From 03172570ad3dd513807e188e3e11f181dd367f12 Mon Sep 17 00:00:00 2001 From: Boubker BRIBRI Date: Mon, 23 Dec 2019 13:17:20 +0100 Subject: [PATCH 1/4] Fix steps names --- .../BO/catalog/monitoring/01_deleteEmptyCategory.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/01_deleteEmptyCategory.js b/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/01_deleteEmptyCategory.js index 95b1dcb816fbb..f1a5cb096f956 100644 --- a/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/01_deleteEmptyCategory.js +++ b/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/01_deleteEmptyCategory.js @@ -34,7 +34,7 @@ const init = async function () { /* Create new category Check existence of new category in monitoring page -Delete category and check deletion in category page +Delete category and check deletion in categories page */ describe('Create empty category and delete it from monitoring page', async () => { // before and after functions @@ -66,7 +66,7 @@ describe('Create empty category and delete it from monitoring page', async () => await expect(numberOfCategories).to.be.above(0); }); - describe('Create Category and subcategory in BO and check it in FO', async () => { + describe('Create empty category in BO', async () => { it('should go to add new category page', async function () { await this.pageObjects.categoriesPage.goToAddNewCategoryPage(); const pageTitle = await this.pageObjects.addCategoryPage.getPageTitle(); From 7c0df6efaa83e14edf2d729161be98bc533f758c Mon Sep 17 00:00:00 2001 From: Boubker BRIBRI Date: Mon, 23 Dec 2019 13:17:44 +0100 Subject: [PATCH 2/4] Add new test monitoring products --- .../monitoring/02_monitoringProducts.js | 195 ++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 tests/puppeteer/campaigns/functional/BO/catalog/monitoring/02_monitoringProducts.js diff --git a/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/02_monitoringProducts.js b/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/02_monitoringProducts.js new file mode 100644 index 0000000000000..0ee65a92d7692 --- /dev/null +++ b/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/02_monitoringProducts.js @@ -0,0 +1,195 @@ +require('module-alias/register'); +// Using chai +const {expect} = require('chai'); +const helper = require('@utils/helpers'); +const loginCommon = require('@commonTests/loginBO'); +// Importing pages +const BOBasePage = require('@pages/BO/BObasePage'); +const LoginPage = require('@pages/BO/login'); +const DashboardPage = require('@pages/BO/dashboard'); +const ProductsPage = require('@pages/BO/catalog/products'); +const AddProductPage = require('@pages/BO/catalog/products/add'); +const MonitoringPage = require('@pages/BO/catalog/monitoring'); +const ProductFaker = require('@data/faker/product'); + +let browser; +let page; +let numberOfProducts = 0; +let numberOfProductsIngrid = 0; +const productWithoutCombinations = new ProductFaker( + {type: 'Standard product', productHasCombinations: false}, +); +const productWithoutCombinationsWithoutQuantity = new ProductFaker( + {type: 'Standard product', productHasCombinations: false, quantity: '0'}, +); +const productWithCombinationsWithoutQuantity = new ProductFaker( + {type: 'Standard product', productHasCombinations: true, quantity: '0'}, +); +const productWithoutPrice = new ProductFaker( + {type: 'Standard product', productHasCombinations: false, price: '0'}, +); + +// Init objects needed +const init = async function () { + return { + boBasePage: new BOBasePage(page), + loginPage: new LoginPage(page), + dashboardPage: new DashboardPage(page), + productsPage: new ProductsPage(page), + addProductPage: new AddProductPage(page), + monitoringPage: new MonitoringPage(page), + }; +}; + +/* +Create new product +Check existence of new product in monitoring page +Delete product and check deletion in products page + */ +describe('Create different products and delete them from monitoring page', async () => { + // before and after functions + before(async function () { + browser = await helper.createBrowser(); + page = await helper.newTab(browser); + this.pageObjects = await init(); + }); + after(async () => { + await helper.closeBrowser(browser); + }); + // Login into BO + loginCommon.loginBO(); + + const tests = [ + { + args: { + productType: 'without image', + productToCreate: productWithoutCombinations, + gridToVerify: 'product_without_image', + enabled: true, + }, + }, + { + args: { + productType: 'disabled', + productToCreate: productWithoutCombinations, + gridToVerify: 'disabled_product', + enabled: false, + }, + }, + { + args: { + productType: 'without combinations and without available quantities', + productToCreate: productWithoutCombinationsWithoutQuantity, + gridToVerify: 'no_qty_product_without_combination', + enabled: true, + }, + }, + { + args: { + productType: 'with combinations and without available quantities', + productToCreate: productWithCombinationsWithoutQuantity, + gridToVerify: 'no_qty_product_with_combination', + enabled: true, + }, + }, + { + args: { + productType: 'without price', + productToCreate: productWithoutPrice, + gridToVerify: 'product_without_price', + enabled: true, + }, + }, + ]; + tests.forEach((test) => { + describe(`Create product ${test.args.productType} in BO`, async () => { + it('should go to catalog > products page', async function () { + await this.pageObjects.boBasePage.goToSubMenu( + this.pageObjects.boBasePage.catalogParentLink, + this.pageObjects.boBasePage.productsLink, + ); + await this.pageObjects.boBasePage.closeSfToolBar(); + const pageTitle = await this.pageObjects.productsPage.getPageTitle(); + await expect(pageTitle).to.contains(this.pageObjects.productsPage.pageTitle); + }); + + it('should reset all filters and get number of products in BO', async function () { + numberOfProducts = await this.pageObjects.productsPage.resetAndGetNumberOfLines(); + await expect(numberOfProducts).to.be.above(0); + }); + + it('should create product and check the products number', async function () { + await this.pageObjects.productsPage.goToAddProductPage(); + const createProductMessage = await this.pageObjects.addProductPage.createEditProduct( + test.args.productToCreate, + test.args.enabled, + ); + await expect(createProductMessage).to.equal(this.pageObjects.addProductPage.settingUpdatedMessage); + }); + }); + + describe('Check created product in monitoring page', async () => { + it('should go to catalog > monitoring page', async function () { + await this.pageObjects.addProductPage.goToSubMenu( + this.pageObjects.boBasePage.catalogParentLink, + this.pageObjects.boBasePage.monitoringLink, + ); + const pageTitle = await this.pageObjects.monitoringPage.getPageTitle(); + await expect(pageTitle).to.contains(this.pageObjects.monitoringPage.pageTitle); + numberOfProductsIngrid = await this.pageObjects.monitoringPage.resetAndGetNumberOfLines( + test.args.gridToVerify, + ); + await expect(numberOfProductsIngrid).to.be.at.least(1); + }); + + it(`should filter products ${test.args.productType} grid and check existence of new product`, async function () { + await this.pageObjects.monitoringPage.filterTable( + test.args.gridToVerify, + 'input', + 'name', + test.args.productToCreate.name, + ); + const textColumn = await this.pageObjects.monitoringPage.getTextColumnFromTable( + test.args.gridToVerify, + 1, + 'name', + ); + await expect(textColumn).to.contains(test.args.productToCreate.name); + }); + + it(`should reset filter in products ${test.args.productType} grid`, async function () { + numberOfProductsIngrid = await this.pageObjects.monitoringPage.resetAndGetNumberOfLines(test.args.gridToVerify); + await expect(numberOfProductsIngrid).to.be.at.least(1); + }); + }); + + describe('Delete product from monitoring page', async () => { + it(`should filter products ${test.args.productType} grid`, async function () { + await this.pageObjects.monitoringPage.filterTable( + test.args.gridToVerify, + 'input', + 'name', + test.args.productToCreate.name, + ); + const textColumn = await this.pageObjects.monitoringPage.getTextColumnFromTable( + test.args.gridToVerify, + 1, + 'name', + ); + await expect(textColumn).to.contains(test.args.productToCreate.name); + }); + + it('should delete product', async function () { + const textResult = await this.pageObjects.monitoringPage.deleteProductInGrid(test.args.gridToVerify, 1); + await expect(textResult).to.equal(this.pageObjects.productsPage.productDeletedSuccessfulMessage); + const pageTitle = await this.pageObjects.productsPage.getPageTitle(); + await expect(pageTitle).to.contains(this.pageObjects.productsPage.pageTitle); + }); + + it('should reset filter check number of products', async function () { + const numberOfProductsAfterDelete = await this.pageObjects.productsPage.resetAndGetNumberOfLines(); + await expect(numberOfProductsAfterDelete).to.be.equal(numberOfProducts); + }); + }); + }); +}); From f79497a6a20305617da1581c2039a59074a1909f Mon Sep 17 00:00:00 2001 From: Boubker BRIBRI Date: Mon, 23 Dec 2019 13:24:16 +0100 Subject: [PATCH 3/4] Update var name --- .../monitoring/02_monitoringProducts.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/02_monitoringProducts.js b/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/02_monitoringProducts.js index 0ee65a92d7692..5cd68c6b0d0fb 100644 --- a/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/02_monitoringProducts.js +++ b/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/02_monitoringProducts.js @@ -64,7 +64,7 @@ describe('Create different products and delete them from monitoring page', async args: { productType: 'without image', productToCreate: productWithoutCombinations, - gridToVerify: 'product_without_image', + gridName: 'product_without_image', enabled: true, }, }, @@ -72,7 +72,7 @@ describe('Create different products and delete them from monitoring page', async args: { productType: 'disabled', productToCreate: productWithoutCombinations, - gridToVerify: 'disabled_product', + gridName: 'disabled_product', enabled: false, }, }, @@ -80,7 +80,7 @@ describe('Create different products and delete them from monitoring page', async args: { productType: 'without combinations and without available quantities', productToCreate: productWithoutCombinationsWithoutQuantity, - gridToVerify: 'no_qty_product_without_combination', + gridName: 'no_qty_product_without_combination', enabled: true, }, }, @@ -88,7 +88,7 @@ describe('Create different products and delete them from monitoring page', async args: { productType: 'with combinations and without available quantities', productToCreate: productWithCombinationsWithoutQuantity, - gridToVerify: 'no_qty_product_with_combination', + gridName: 'no_qty_product_with_combination', enabled: true, }, }, @@ -96,7 +96,7 @@ describe('Create different products and delete them from monitoring page', async args: { productType: 'without price', productToCreate: productWithoutPrice, - gridToVerify: 'product_without_price', + gridName: 'product_without_price', enabled: true, }, }, @@ -137,20 +137,20 @@ describe('Create different products and delete them from monitoring page', async const pageTitle = await this.pageObjects.monitoringPage.getPageTitle(); await expect(pageTitle).to.contains(this.pageObjects.monitoringPage.pageTitle); numberOfProductsIngrid = await this.pageObjects.monitoringPage.resetAndGetNumberOfLines( - test.args.gridToVerify, + test.args.gridName, ); await expect(numberOfProductsIngrid).to.be.at.least(1); }); it(`should filter products ${test.args.productType} grid and check existence of new product`, async function () { await this.pageObjects.monitoringPage.filterTable( - test.args.gridToVerify, + test.args.gridName, 'input', 'name', test.args.productToCreate.name, ); const textColumn = await this.pageObjects.monitoringPage.getTextColumnFromTable( - test.args.gridToVerify, + test.args.gridName, 1, 'name', ); @@ -158,7 +158,7 @@ describe('Create different products and delete them from monitoring page', async }); it(`should reset filter in products ${test.args.productType} grid`, async function () { - numberOfProductsIngrid = await this.pageObjects.monitoringPage.resetAndGetNumberOfLines(test.args.gridToVerify); + numberOfProductsIngrid = await this.pageObjects.monitoringPage.resetAndGetNumberOfLines(test.args.gridName); await expect(numberOfProductsIngrid).to.be.at.least(1); }); }); @@ -166,13 +166,13 @@ describe('Create different products and delete them from monitoring page', async describe('Delete product from monitoring page', async () => { it(`should filter products ${test.args.productType} grid`, async function () { await this.pageObjects.monitoringPage.filterTable( - test.args.gridToVerify, + test.args.gridName, 'input', 'name', test.args.productToCreate.name, ); const textColumn = await this.pageObjects.monitoringPage.getTextColumnFromTable( - test.args.gridToVerify, + test.args.gridName, 1, 'name', ); @@ -180,7 +180,7 @@ describe('Create different products and delete them from monitoring page', async }); it('should delete product', async function () { - const textResult = await this.pageObjects.monitoringPage.deleteProductInGrid(test.args.gridToVerify, 1); + const textResult = await this.pageObjects.monitoringPage.deleteProductInGrid(test.args.gridName, 1); await expect(textResult).to.equal(this.pageObjects.productsPage.productDeletedSuccessfulMessage); const pageTitle = await this.pageObjects.productsPage.getPageTitle(); await expect(pageTitle).to.contains(this.pageObjects.productsPage.pageTitle); From f30623fa8257778452b35f35705d031cff33fb76 Mon Sep 17 00:00:00 2001 From: Boubker BRIBRI Date: Tue, 31 Dec 2019 10:16:29 +0100 Subject: [PATCH 4/4] Add spaces in test --- .../BO/catalog/monitoring/02_monitoringProducts.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/02_monitoringProducts.js b/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/02_monitoringProducts.js index 5cd68c6b0d0fb..eea3b406e5e52 100644 --- a/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/02_monitoringProducts.js +++ b/tests/puppeteer/campaigns/functional/BO/catalog/monitoring/02_monitoringProducts.js @@ -101,6 +101,7 @@ describe('Create different products and delete them from monitoring page', async }, }, ]; + tests.forEach((test) => { describe(`Create product ${test.args.productType} in BO`, async () => { it('should go to catalog > products page', async function () { @@ -108,6 +109,7 @@ describe('Create different products and delete them from monitoring page', async this.pageObjects.boBasePage.catalogParentLink, this.pageObjects.boBasePage.productsLink, ); + await this.pageObjects.boBasePage.closeSfToolBar(); const pageTitle = await this.pageObjects.productsPage.getPageTitle(); await expect(pageTitle).to.contains(this.pageObjects.productsPage.pageTitle); @@ -124,6 +126,7 @@ describe('Create different products and delete them from monitoring page', async test.args.productToCreate, test.args.enabled, ); + await expect(createProductMessage).to.equal(this.pageObjects.addProductPage.settingUpdatedMessage); }); }); @@ -134,11 +137,14 @@ describe('Create different products and delete them from monitoring page', async this.pageObjects.boBasePage.catalogParentLink, this.pageObjects.boBasePage.monitoringLink, ); + const pageTitle = await this.pageObjects.monitoringPage.getPageTitle(); await expect(pageTitle).to.contains(this.pageObjects.monitoringPage.pageTitle); + numberOfProductsIngrid = await this.pageObjects.monitoringPage.resetAndGetNumberOfLines( test.args.gridName, ); + await expect(numberOfProductsIngrid).to.be.at.least(1); }); @@ -149,11 +155,13 @@ describe('Create different products and delete them from monitoring page', async 'name', test.args.productToCreate.name, ); + const textColumn = await this.pageObjects.monitoringPage.getTextColumnFromTable( test.args.gridName, 1, 'name', ); + await expect(textColumn).to.contains(test.args.productToCreate.name); }); @@ -171,11 +179,13 @@ describe('Create different products and delete them from monitoring page', async 'name', test.args.productToCreate.name, ); + const textColumn = await this.pageObjects.monitoringPage.getTextColumnFromTable( test.args.gridName, 1, 'name', ); + await expect(textColumn).to.contains(test.args.productToCreate.name); });