diff --git a/tests/puppeteer/campaigns/data/FO/cart.js b/tests/puppeteer/campaigns/data/FO/cart.js index ac1bdfa97cba3..8427e29405da8 100644 --- a/tests/puppeteer/campaigns/data/FO/cart.js +++ b/tests/puppeteer/campaigns/data/FO/cart.js @@ -10,5 +10,6 @@ module.exports = { quantity: '1', price: '€34.46', }, + cartTotalTTC: 57.41, }, }; diff --git a/tests/puppeteer/campaigns/data/demo/orders.js b/tests/puppeteer/campaigns/data/demo/orders.js index 2b52a0c494b29..e5a2d7f65e267 100644 --- a/tests/puppeteer/campaigns/data/demo/orders.js +++ b/tests/puppeteer/campaigns/data/demo/orders.js @@ -1,7 +1,7 @@ module.exports = { Orders: { firstOrder: {id: '1', ref: 'XKBKNABJK'}, - secondOrder: {id: '2', ref: 'XKBKNABJK'}, + secondOrder: {id: '2', ref: 'OHSATSERP'}, thirdOrder: {id: '3', ref: 'UOYEVOLI'}, fourthOrder: {id: '4', ref: 'FFATNOMMJ'}, }, diff --git a/tests/puppeteer/campaigns/sanity/01_installShop/01_installShop.js b/tests/puppeteer/campaigns/sanity/01_installShop/01_installShop.js index dc7d173eca72a..5bfa79d803582 100644 --- a/tests/puppeteer/campaigns/sanity/01_installShop/01_installShop.js +++ b/tests/puppeteer/campaigns/sanity/01_installShop/01_installShop.js @@ -87,15 +87,18 @@ describe('Install Prestashop', async () => { }); it('should fill database configuration form and check database connection', async function () { await this.pageObjects.installPage.fillDatabaseForm(); - await this.pageObjects.installPage.checkDatabaseConnected(); + const result = await this.pageObjects.installPage.isDatabaseConnected(); + await expect(result).to.be.true; }); it('should finish installation and check that installation is successful', async function () { await this.pageObjects.installPage.nextStep(); - await this.pageObjects.installPage.checkInstallationSuccessful(); + const result = await this.pageObjects.installPage.isInstallationSuccessful(); + await expect(result).to.be.true; }); it('should go to FO and check that Prestashop logo exists', async function () { page = await this.pageObjects.installPage.goToFOAfterInstall(); this.pageObjects = await init(); - await this.pageObjects.homePage.checkHomePage(); + const result = await this.pageObjects.homePage.isHomePage(); + await expect(result).to.be.true; }); }); diff --git a/tests/puppeteer/campaigns/sanity/02_productsBO/01_filterProducts.js b/tests/puppeteer/campaigns/sanity/02_productsBO/01_filterProducts.js index 58bdbcba5d84e..61d07a9e866ae 100644 --- a/tests/puppeteer/campaigns/sanity/02_productsBO/01_filterProducts.js +++ b/tests/puppeteer/campaigns/sanity/02_productsBO/01_filterProducts.js @@ -40,8 +40,10 @@ describe('Filter in Products Page', async () => { // Steps loginCommon.loginBO(); it('should go to Products page', async function () { - await this.pageObjects.boBasePage.goToSubMenu(this.pageObjects.boBasePage.productsParentLink, - this.pageObjects.boBasePage.productsLink); + await this.pageObjects.boBasePage.goToSubMenu( + this.pageObjects.boBasePage.productsParentLink, + this.pageObjects.boBasePage.productsLink, + ); const pageTitle = await this.pageObjects.productsPage.getPageTitle(); await expect(pageTitle).to.contains(this.pageObjects.productsPage.pageTitle); }); diff --git a/tests/puppeteer/campaigns/sanity/02_productsBO/02_CRUDStandardProductInBO.js b/tests/puppeteer/campaigns/sanity/02_productsBO/02_CRUDStandardProductInBO.js index cab8c07f58c9d..0a1255d4ab884 100644 --- a/tests/puppeteer/campaigns/sanity/02_productsBO/02_CRUDStandardProductInBO.js +++ b/tests/puppeteer/campaigns/sanity/02_productsBO/02_CRUDStandardProductInBO.js @@ -49,8 +49,10 @@ describe('Create, read, update and delete Standard product in BO', async () => { // Steps loginCommon.loginBO(); it('should go to Products page', async function () { - await this.pageObjects.boBasePage.goToSubMenu(this.pageObjects.boBasePage.productsParentLink, - this.pageObjects.boBasePage.productsLink); + await this.pageObjects.boBasePage.goToSubMenu( + this.pageObjects.boBasePage.productsParentLink, + 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); @@ -72,14 +74,15 @@ describe('Create, read, update and delete Standard product in BO', async () => { page = await this.pageObjects.addProductPage.previewProduct(); this.pageObjects = await init(); const result = await this.pageObjects.foProductPage.checkProduct(productData); + page = await this.pageObjects.foProductPage.closePage(browser, 1); + this.pageObjects = await init(); + // Check that all Product attribute are correct await Promise.all([ expect(result.name).to.be.true, expect(result.price).to.be.true, expect(result.quantity_wanted).to.be.true, expect(result.description).to.be.true, ]); - page = await this.pageObjects.foProductPage.closePage(browser, 1); - this.pageObjects = await init(); }); it('should edit Product', async function () { const createProductMessage = await this.pageObjects.addProductPage.createEditProduct(editedProductData, false); @@ -89,14 +92,15 @@ describe('Create, read, update and delete Standard product in BO', async () => { page = await this.pageObjects.addProductPage.previewProduct(); this.pageObjects = await init(); const result = await this.pageObjects.foProductPage.checkProduct(editedProductData); + page = await this.pageObjects.foProductPage.closePage(browser, 1); + this.pageObjects = await init(); + // Check that all Product attribute are correct await Promise.all([ expect(result.name).to.be.true, expect(result.price).to.be.true, expect(result.quantity_wanted).to.be.true, expect(result.description).to.be.true, ]); - page = await this.pageObjects.foProductPage.closePage(browser, 1); - this.pageObjects = await init(); }); it('should delete Product and be on product list page', async function () { const testResult = await this.pageObjects.addProductPage.deleteProduct(); diff --git a/tests/puppeteer/campaigns/sanity/02_productsBO/03_CRUDStandardProductWithCombinationsInBO.js b/tests/puppeteer/campaigns/sanity/02_productsBO/03_CRUDStandardProductWithCombinationsInBO.js index eba2e78e7b8b2..39ca03db6a57a 100644 --- a/tests/puppeteer/campaigns/sanity/02_productsBO/03_CRUDStandardProductWithCombinationsInBO.js +++ b/tests/puppeteer/campaigns/sanity/02_productsBO/03_CRUDStandardProductWithCombinationsInBO.js @@ -49,8 +49,10 @@ describe('Create, read, update and delete Standard product with combinations in // Steps loginCommon.loginBO(); it('should go to Products page', async function () { - await this.pageObjects.boBasePage.goToSubMenu(this.pageObjects.boBasePage.productsParentLink, - this.pageObjects.boBasePage.productsLink); + await this.pageObjects.boBasePage.goToSubMenu( + this.pageObjects.boBasePage.productsParentLink, + 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); @@ -72,14 +74,15 @@ describe('Create, read, update and delete Standard product with combinations in page = await this.pageObjects.addProductPage.previewProduct(); this.pageObjects = await init(); const result = await this.pageObjects.foProductPage.checkProduct(productWithCombinations); + page = await this.pageObjects.foProductPage.closePage(browser, 1); + this.pageObjects = await init(); + // Check that all Product attribute are correct await Promise.all([ expect(result.name).to.be.true, expect(result.price).to.be.true, expect(result.quantity_wanted).to.be.true, expect(result.description).to.be.true, ]); - page = await this.pageObjects.foProductPage.closePage(browser, 1); - this.pageObjects = await init(); }); it('should edit Product', async function () { const createProductMessage = await this.pageObjects.addProductPage.createEditProduct(editedProductWithCombinations, @@ -90,14 +93,15 @@ describe('Create, read, update and delete Standard product with combinations in page = await this.pageObjects.addProductPage.previewProduct(); this.pageObjects = await init(); const result = await this.pageObjects.foProductPage.checkProduct(editedProductWithCombinations); + page = await this.pageObjects.foProductPage.closePage(browser, 1); + this.pageObjects = await init(); + // Check that all Product attribute are correct await Promise.all([ expect(result.name).to.be.true, expect(result.price).to.be.true, expect(result.quantity_wanted).to.be.true, expect(result.description).to.be.true, ]); - page = await this.pageObjects.foProductPage.closePage(browser, 1); - this.pageObjects = await init(); }); it('should delete Product and be on product list page', async function () { const testResult = await this.pageObjects.addProductPage.deleteProduct(); diff --git a/tests/puppeteer/campaigns/sanity/02_productsBO/04_deleteProduct.js b/tests/puppeteer/campaigns/sanity/02_productsBO/04_deleteProduct.js index 9fde5e7b2e928..0f006804074f1 100644 --- a/tests/puppeteer/campaigns/sanity/02_productsBO/04_deleteProduct.js +++ b/tests/puppeteer/campaigns/sanity/02_productsBO/04_deleteProduct.js @@ -45,8 +45,10 @@ describe('Create Standard product in BO and Delete it with DropDown Menu', async // Steps loginCommon.loginBO(); it('should go to Products page', async function () { - await this.pageObjects.boBasePage.goToSubMenu(this.pageObjects.boBasePage.productsParentLink, - this.pageObjects.boBasePage.productsLink); + await this.pageObjects.boBasePage.goToSubMenu( + this.pageObjects.boBasePage.productsParentLink, + this.pageObjects.boBasePage.productsLink, + ); const pageTitle = await this.pageObjects.productsPage.getPageTitle(); await expect(pageTitle).to.contains(this.pageObjects.productsPage.pageTitle); }); diff --git a/tests/puppeteer/campaigns/sanity/02_productsBO/05_deleteProductsWithBulkActions.js b/tests/puppeteer/campaigns/sanity/02_productsBO/05_deleteProductsWithBulkActions.js index c1fc8d35a6aa3..efe443b89e916 100644 --- a/tests/puppeteer/campaigns/sanity/02_productsBO/05_deleteProductsWithBulkActions.js +++ b/tests/puppeteer/campaigns/sanity/02_productsBO/05_deleteProductsWithBulkActions.js @@ -50,8 +50,10 @@ describe('Create Standard product in BO and Delete it with Bulk Actions', async // Steps loginCommon.loginBO(); it('should go to Products page', async function () { - await this.pageObjects.boBasePage.goToSubMenu(this.pageObjects.boBasePage.productsParentLink, - this.pageObjects.boBasePage.productsLink); + await this.pageObjects.boBasePage.goToSubMenu( + this.pageObjects.boBasePage.productsParentLink, + this.pageObjects.boBasePage.productsLink, + ); const pageTitle = await this.pageObjects.productsPage.getPageTitle(); await expect(pageTitle).to.contains(this.pageObjects.productsPage.pageTitle); }); diff --git a/tests/puppeteer/campaigns/sanity/03_ordersBO/01_filterOrders.js b/tests/puppeteer/campaigns/sanity/03_ordersBO/01_filterOrders.js index 40698d3f6f8ce..45f911568fc54 100644 --- a/tests/puppeteer/campaigns/sanity/03_ordersBO/01_filterOrders.js +++ b/tests/puppeteer/campaigns/sanity/03_ordersBO/01_filterOrders.js @@ -8,9 +8,10 @@ const loginCommon = require('@commonTests/loginBO'); const LoginPage = require('@pages/BO/login'); const DashboardPage = require('@pages/BO/dashboard'); const BOBasePage = require('@pages/BO/BObasePage'); -const OrderPage = require('@pages/BO/order'); +const OrdersPage = require('@pages/BO/orders'); const {Orders, Statuses} = require('@data/demo/orders'); +let numberOfOrders; let browser; let page; // creating pages objects in a function @@ -19,7 +20,7 @@ const init = async function () { loginPage: new LoginPage(page), dashboardPage: new DashboardPage(page), boBasePage: new BOBasePage(page), - orderPage: new OrderPage(page), + ordersPage: new OrdersPage(page), }; }; @@ -43,48 +44,79 @@ describe('Filter the Orders table by ID, REFERENCE, STATUS', async () => { it('should go to the Orders page', async function () { await this.pageObjects.boBasePage.goToSubMenu( this.pageObjects.boBasePage.ordersParentLink, - this.pageObjects.orderPage.ordersLink, + this.pageObjects.boBasePage.ordersLink, ); - const pageTitle = await this.pageObjects.orderPage.getPageTitle(); - await expect(pageTitle).to.contains(this.pageObjects.orderPage.pageTitle); + const pageTitle = await this.pageObjects.ordersPage.getPageTitle(); + await expect(pageTitle).to.contains(this.pageObjects.ordersPage.pageTitle); + }); + it('should reset all filters and get number of orders', async function () { + await this.pageObjects.ordersPage.resetFilter(); + numberOfOrders = await parseInt( + await this.pageObjects.ordersPage.getTextContent(this.pageObjects.ordersPage.ordersNumberSpan), + 10, + ); + await expect(numberOfOrders).to.be.above(0); }); it('should filter the Orders table by ID and check the result', async function () { - await this.pageObjects.orderPage.filterTableByInput( - this.pageObjects.orderPage.orderFilterIdInput, + await this.pageObjects.ordersPage.filterOrders( + 'input', + 'id_order', Orders.firstOrder.id, - this.pageObjects.orderPage.searchButton, ); - const result = await this.pageObjects.boBasePage.checkTextValue( - this.pageObjects.orderPage.orderfirstLineIdTD, + const result = await this.pageObjects.ordersPage.checkTextValue( + this.pageObjects.ordersPage.orderfirstLineIdTD.replace('%ROW', '1'), Orders.firstOrder.id, ); await expect(result).to.be.true; - await this.pageObjects.orderPage.waitForSelectorAndClick(this.pageObjects.orderPage.resetButton); + }); + it('should reset all filters', async function () { + await this.pageObjects.ordersPage.resetFilter(); + const numberOfOrdersAfterReset = await parseInt( + await this.pageObjects.ordersPage.getTextContent(this.pageObjects.ordersPage.ordersNumberSpan), + 10, + ); + await expect(numberOfOrdersAfterReset).to.be.equal(numberOfOrders); }); it('should filter the Orders table by REFERENCE and check the result', async function () { - await this.pageObjects.orderPage.filterTableByInput( - this.pageObjects.orderPage.orderFilterReferenceInput, + await this.pageObjects.ordersPage.filterOrders( + 'input', + 'reference', Orders.fourthOrder.ref, - this.pageObjects.orderPage.searchButton, ); const result = await this.pageObjects.boBasePage.checkTextValue( - this.pageObjects.orderPage.orderfirstLineReferenceTD, + this.pageObjects.ordersPage.orderfirstLineReferenceTD.replace('%ROW', '1'), Orders.fourthOrder.ref, ); await expect(result).to.be.true; - await this.pageObjects.orderPage.waitForSelectorAndClick(this.pageObjects.orderPage.resetButton); + }); + it('should reset all filters', async function () { + await this.pageObjects.ordersPage.resetFilter(); + const numberOfOrdersAfterReset = await parseInt( + await this.pageObjects.ordersPage.getTextContent(this.pageObjects.ordersPage.ordersNumberSpan), + 10, + ); + await expect(numberOfOrdersAfterReset).to.be.equal(numberOfOrders); }); it('should filter the Orders table by STATUS and check the result', async function () { - await this.pageObjects.orderPage.filterTableBySelect( - this.pageObjects.orderPage.orderFilterStatusSelect, - Statuses.paymentError.index, + await this.pageObjects.ordersPage.filterOrders( + 'select', + 'order_state', + Statuses.paymentError.status, ); - const result = await this.pageObjects.orderPage.checkTextValue( - this.pageObjects.orderPage.orderfirstLineStatusTD, + const result = await this.pageObjects.ordersPage.checkTextValue( + this.pageObjects.ordersPage.orderfirstLineStatusTD.replace('%ROW', '1'), Statuses.paymentError.status, ); await expect(result).to.be.true; }); + it('should reset all filters', async function () { + await this.pageObjects.ordersPage.resetFilter(); + const numberOfOrdersAfterReset = await parseInt( + await this.pageObjects.ordersPage.getTextContent(this.pageObjects.ordersPage.ordersNumberSpan), + 10, + ); + await expect(numberOfOrdersAfterReset).to.be.equal(numberOfOrders); + }); it('should logout from the BO', async function () { await this.pageObjects.boBasePage.logoutBO(); const pageTitle = await this.pageObjects.loginPage.getPageTitle(); diff --git a/tests/puppeteer/campaigns/sanity/03_ordersBO/02_editOrder.js b/tests/puppeteer/campaigns/sanity/03_ordersBO/02_editOrder.js index e98ad77452bf8..ab14c26555b05 100644 --- a/tests/puppeteer/campaigns/sanity/03_ordersBO/02_editOrder.js +++ b/tests/puppeteer/campaigns/sanity/03_ordersBO/02_editOrder.js @@ -9,6 +9,7 @@ const LoginPage = require('@pages/BO/login'); const DashboardPage = require('@pages/BO/dashboard'); const BOBasePage = require('@pages/BO/BObasePage'); const OrderPage = require('@pages/BO/order'); +const OrdersPage = require('@pages/BO/orders'); const {Statuses} = require('@data/demo/orders'); let browser; @@ -20,6 +21,7 @@ const init = async function () { dashboardPage: new DashboardPage(page), boBasePage: new BOBasePage(page), orderPage: new OrderPage(page), + ordersPage: new OrdersPage(page), }; }; @@ -41,15 +43,17 @@ describe('Edit Order BO', async () => { // Steps loginCommon.loginBO(); it('should go to the Orders page', async function () { - await this.pageObjects.boBasePage.goToSubMenu(this.pageObjects.boBasePage.ordersParentLink, - this.pageObjects.orderPage.ordersLink); - const pageTitle = await this.pageObjects.orderPage.getPageTitle(); - await expect(pageTitle).to.contains(this.pageObjects.orderPage.pageTitle); + await this.pageObjects.boBasePage.goToSubMenu( + this.pageObjects.boBasePage.ordersParentLink, + this.pageObjects.boBasePage.ordersLink, + ); + const pageTitle = await this.pageObjects.ordersPage.getPageTitle(); + await expect(pageTitle).to.contains(this.pageObjects.ordersPage.pageTitle); }); it('should go to the first order page', async function () { - await this.pageObjects.boBasePage.waitForSelectorAndClick(this.pageObjects.orderPage.orderfirstLineIdTD); + await this.pageObjects.ordersPage.goToOrder('1'); const pageTitle = await this.pageObjects.orderPage.getPageTitle(); - await expect(pageTitle).to.contains(this.pageObjects.orderPage.orderPageTitle); + await expect(pageTitle).to.contains(this.pageObjects.orderPage.pageTitle); }); it('should modify the product quantity and check the validation', async function () { const result = await this.pageObjects.orderPage.modifyProductQuantity('1', '5'); diff --git a/tests/puppeteer/campaigns/sanity/04_catalogFO/01_filterProducts.js b/tests/puppeteer/campaigns/sanity/04_catalogFO/01_filterProducts.js index 3f112bd388ff6..31370763719f1 100644 --- a/tests/puppeteer/campaigns/sanity/04_catalogFO/01_filterProducts.js +++ b/tests/puppeteer/campaigns/sanity/04_catalogFO/01_filterProducts.js @@ -37,7 +37,8 @@ describe('Filter Products by categories in Home page', async () => { // Steps it('should open the shop page', async () => { await this.pageObjects.homePage.goTo(global.FO.URL); - await this.pageObjects.homePage.checkHomePage(); + const result = await this.pageObjects.homePage.isHomePage(); + await expect(result).to.be.true; }); it('should check and get the products number', async () => { await this.pageObjects.homePage.waitForSelectorAndClick(this.pageObjects.homePage.allProductLink); diff --git a/tests/puppeteer/campaigns/sanity/04_catalogFO/02_checkProduct.js b/tests/puppeteer/campaigns/sanity/04_catalogFO/02_checkProduct.js index 7934f58f244f7..60d44303d75b9 100644 --- a/tests/puppeteer/campaigns/sanity/04_catalogFO/02_checkProduct.js +++ b/tests/puppeteer/campaigns/sanity/04_catalogFO/02_checkProduct.js @@ -38,10 +38,13 @@ describe('Check the Product page', async () => { // Steps it('should open the shop page', async function () { await this.pageObjects.homePage.goTo(global.FO.URL); - await this.pageObjects.homePage.checkHomePage(); + const result = await this.pageObjects.homePage.isHomePage(); + await expect(result).to.be.true; }); it('should go to the first product page', async function () { await this.pageObjects.homePage.goToProductPage('1'); + const pageTitle = await this.pageObjects.productPage.getPageTitle(); + await expect(pageTitle.toUpperCase()).to.contains(ProductData.firstProductData.name); }); it('should check the product page', async function () { const result = await this.pageObjects.productPage.checkProduct(ProductData.firstProductData); diff --git a/tests/puppeteer/campaigns/sanity/05_cartFO/01_editCheckCart.js b/tests/puppeteer/campaigns/sanity/05_cartFO/01_editCheckCart.js index 23cabda43f6d6..2c1fdd2aaf427 100644 --- a/tests/puppeteer/campaigns/sanity/05_cartFO/01_editCheckCart.js +++ b/tests/puppeteer/campaigns/sanity/05_cartFO/01_editCheckCart.js @@ -46,31 +46,34 @@ describe('Check the Product page', async () => { // Steps it('should open the shop page', async function () { await this.pageObjects.homePage.goTo(global.FO.URL); - await this.pageObjects.homePage.checkHomePage(); + const isHomePage = await this.pageObjects.homePage.isHomePage(); + await expect(isHomePage).to.be.true; }); it('should go to the first product page', async function () { await this.pageObjects.homePage.goToProductPage('1'); + const pageTitle = await this.pageObjects.productPage.getPageTitle(); + await expect(pageTitle).to.contains(CartData.customCartData.firstProduct.name); }); - it('should add product to the cart', async function () { + it('should add product to cart and check that the number of products was updated in cart header', async function () { await this.pageObjects.productPage.addProductToTheCart(); - }); - it('should check that the number of products in Cart was updated in header', async function () { // getNumberFromText is used to get the notifications number in the cart - const notificationsNumber = await this.pageObjects.homePage - .getNumberFromText(this.pageObjects.homePage.cartProductsCount); + const notificationsNumber = await this.pageObjects.homePage.getNumberFromText( + this.pageObjects.homePage.cartProductsCount, + ); await expect(notificationsNumber).to.be.equal(1); }); it('should go to the home page', async function () { await this.pageObjects.homePage.goToHomePage(); - await this.pageObjects.homePage.checkHomePage(); + const isHomePage = await this.pageObjects.homePage.isHomePage(); + await expect(isHomePage).to.be.true; }); it('should go to the second product page', async function () { await this.pageObjects.homePage.goToProductPage('2'); + const pageTitle = await this.pageObjects.productPage.getPageTitle(); + await expect(pageTitle).to.contains(CartData.customCartData.secondProduct.name); }); - it('should add product to the cart', async function () { + it('should add product to cart and check that the number of products was updated in cart header', async function () { await this.pageObjects.productPage.addProductToTheCart(); - }); - it('should check that the number of products in Cart was updated in header', async function () { // getNumberFromText is used to get the notifications number in the cart const notificationsNumber = await this.pageObjects.homePage .getNumberFromText(this.pageObjects.homePage.cartProductsCount); @@ -94,24 +97,28 @@ describe('Check the Product page', async () => { }); it('should get the Total TTC', async function () { // getNumberFromText is used to get the Total TTC price - totalTTC = await this.pageObjects.cartPage.getNumberFromText(this.pageObjects.cartPage.cartTotalTTC); + totalTTC = await this.pageObjects.cartPage.getPriceFromText(this.pageObjects.cartPage.cartTotalTTC); + await expect(totalTTC).to.be.equal(CartData.customCartData.cartTotalTTC); }); - it('should get the product number', async function () { + it('should get the product number and check that is equal to 2', async function () { // getNumberFromText is used to get the products number itemsNumber = await this.pageObjects.cartPage.getNumberFromText(this.pageObjects.cartPage.itemsNumber); + await expect(itemsNumber).to.be.equal(2); }); it('should edit the quantity of the first product ordered', async function () { await this.pageObjects.cartPage.editProductQuantity('1', '3'); + // getNumberFromText is used to get the new Total TTC price + const totalPrice = await this.pageObjects.cartPage.getPriceFromText(this.pageObjects.cartPage.cartTotalTTC, 2000); + await expect(totalPrice).to.be.above(totalTTC); + // getNumberFromText is used to get the new products number + const productsNumber = await this.pageObjects.cartPage.getNumberFromText(this.pageObjects.cartPage.itemsNumber); + await expect(productsNumber).to.be.above(itemsNumber); }); it('should edit the quantity of the second product ordered', async function () { await this.pageObjects.cartPage.editProductQuantity('2', '2'); - }); - it('should check that the Total order price is changed', async function () { // getNumberFromText is used to get the new Total TTC price - const totalPrice = await this.pageObjects.cartPage.getNumberFromText(this.pageObjects.cartPage.cartTotalTTC, 2000); + const totalPrice = await this.pageObjects.cartPage.getPriceFromText(this.pageObjects.cartPage.cartTotalTTC, 2000); await expect(totalPrice).to.be.above(totalTTC); - }); - it('should check that the Items number is changed', async function () { // getNumberFromText is used to get the new products number const productsNumber = await this.pageObjects.cartPage.getNumberFromText(this.pageObjects.cartPage.itemsNumber); await expect(productsNumber).to.be.above(itemsNumber); diff --git a/tests/puppeteer/campaigns/sanity/06_checkoutFO/01_orderProduct.js b/tests/puppeteer/campaigns/sanity/06_checkoutFO/01_orderProduct.js index 40d04791c5f1b..eeeb8f2f2ac0f 100644 --- a/tests/puppeteer/campaigns/sanity/06_checkoutFO/01_orderProduct.js +++ b/tests/puppeteer/campaigns/sanity/06_checkoutFO/01_orderProduct.js @@ -46,7 +46,8 @@ describe('Order a product and check order confirmation', async () => { // Steps it('should open the shop page', async function () { await this.pageObjects.homePage.goTo(global.FO.URL); - await this.pageObjects.homePage.checkHomePage(); + const result = await this.pageObjects.homePage.isHomePage(); + await expect(result).to.be.true; }); it('should go to login page', async function () { await this.pageObjects.homePage.goToLoginPage(); @@ -60,7 +61,8 @@ describe('Order a product and check order confirmation', async () => { }); it('should go to home page', async function () { await this.pageObjects.homePage.goToHomePage(); - await this.pageObjects.homePage.checkHomePage(); + const result = await this.pageObjects.homePage.isHomePage(); + await expect(result).to.be.true; }); it('should add first product to cart and Proceed to checkout', async function () { await this.pageObjects.homePage.addProductToCartByQuickView('1', '1'); diff --git a/tests/puppeteer/pages/BO/order.js b/tests/puppeteer/pages/BO/order.js index c6f9bf5cab37b..07ca1c5d7a445 100644 --- a/tests/puppeteer/pages/BO/order.js +++ b/tests/puppeteer/pages/BO/order.js @@ -5,27 +5,18 @@ module.exports = class Order extends BOBasePage { constructor(page) { super(page); - this.pageTitle = 'Orders •'; - this.orderPageTitle = 'Order'; - - // Orders page - this.orderFilterIdInput = '#table-order th:nth-child(2) > input'; - this.orderFilterReferenceInput = '#table-order th:nth-child(3) > input'; - this.orderFilterStatusSelect = '#table-order th:nth-child(9) > select'; - this.searchButton = '#submitFilterButtonorder'; - this.resetButton = '#table-order button.btn.btn-warning'; - this.orderfirstLineIdTD = '#table-order td:nth-child(2)'; - this.orderfirstLineReferenceTD = '#table-order td:nth-child(3)'; - this.orderfirstLineStatusTD = '#table-order td:nth-child(9)'; + this.pageTitle = 'Order'; // Order page - this.editProductButton = '#orderProducts tr:nth-child(%ID) .edit_product_change_link'; - this.editProductQuantityInput = '#orderProducts tr:nth-child(%ID) span.product_quantity_edit > input'; - this.productQuantitySpan = '#orderProducts tr:nth-child(%ID) span.product_quantity_show.badge'; - this.UpdateProductButton = '#orderProducts tr:nth-child(%ID) .submitProductChange'; + this.orderProductsTable = '#orderProducts'; + this.orderProductsRowTable = `${this.orderProductsTable} tr:nth-child(%ID)`; + this.editProductButton = `${this.orderProductsRowTable} .edit_product_change_link`; + this.editProductQuantityInput = `${this.orderProductsRowTable} span.product_quantity_edit > input`; + this.productQuantitySpan = `${this.orderProductsRowTable} span.product_quantity_show.badge`; + this.UpdateProductButton = `${this.orderProductsRowTable} .submitProductChange`; this.orderStatusesSelect = '#id_order_state_chosen'; - this.orderStatusInput = '#id_order_state_chosen input[type="text"]'; - this.orderStatusSearchResult = '#id_order_state_chosen li:nth-child(1)'; + this.orderStatusesSearchInput = `${this.orderStatusesSelect} input[type='text']`; + this.orderStatusSearchResult = `${this.orderStatusesSelect} li:nth-child(1)`; this.updateStatusButton = '#submit_state'; this.statusValidation = '#status tr:nth-child(1) > td:nth-child(2)'; } @@ -34,30 +25,6 @@ module.exports = class Order extends BOBasePage { Methods */ - /** - * Filter table with an input - * @param selector, input to filter with - * @param value, text to enter in the filter input - * @param searchButton - * @returns {Promise} - */ - async filterTableByInput(selector, value, searchButton) { - await this.page.waitForSelector(selector); - await this.page.type(selector, value); - await this.page.click(searchButton); - } - - /** - * Filter table with a select option - * @param selector - * @param value, value to select in the filter select - * @returns {Promise} - */ - async filterTableBySelect(selector, value) { - await this.page.waitForSelector(selector); - await this.page.select(selector, value); - } - /** * Modify the product quantity * @param id, product id @@ -79,7 +46,7 @@ module.exports = class Order extends BOBasePage { */ async modifyOrderStatus(status) { await this.waitForSelectorAndClick(this.orderStatusesSelect); - await this.page.type(this.orderStatusInput, status); + await this.page.type(this.orderStatusesSearchInput, status); await this.page.click(this.orderStatusSearchResult); await this.page.click(this.updateStatusButton); return this.checkTextValue(this.statusValidation, status); diff --git a/tests/puppeteer/pages/BO/orders.js b/tests/puppeteer/pages/BO/orders.js new file mode 100644 index 0000000000000..fddea02eaf164 --- /dev/null +++ b/tests/puppeteer/pages/BO/orders.js @@ -0,0 +1,80 @@ +require('module-alias/register'); +const BOBasePage = require('@pages/BO/BObasePage'); + +module.exports = class Order extends BOBasePage { + constructor(page) { + super(page); + + this.pageTitle = 'Orders •'; + this.orderPageTitle = 'Order'; + + // Orders page + this.ordersForm = '#form-order'; + this.ordersNumberSpan = `${this.ordersForm} span.badge`; + this.ordersTable = '#table-order'; + this.orderFilterColumnInput = `${this.ordersTable} input[name='orderFilter_%FILTERBY']`; + this.orderFilterColumnSelect = `${this.ordersTable} select[name='orderFilter_os!id_%FILTERBY']`; + this.searchButton = `${this.ordersTable} #submitFilterButtonorder`; + this.resetButton = `${this.ordersTable} button.btn.btn-warning`; + this.orderRow = `${this.ordersTable} tbody tr:nth-child(%ROW)`; + this.orderfirstLineIdTD = `${this.orderRow} td:nth-child(2)`; + this.orderfirstLineReferenceTD = `${this.orderRow} td:nth-child(3)`; + this.orderfirstLineStatusTD = `${this.orderRow} td:nth-child(9)`; + } + + /* + Methods + */ + /** + * Filter Orders + * @param filterType + * @param filterBy + * @param value + * @return {Promise} + */ + async filterOrders(filterType, filterBy, value = '') { + switch (filterType) { + case 'input': + await this.setValue(this.orderFilterColumnInput.replace('%FILTERBY', filterBy), value); + // click on search + await Promise.all([ + this.page.waitForNavigation({waitUntil: 'networkidle0'}), + this.page.click(this.searchButton), + ]); + break; + case 'select': + await Promise.all([ + this.page.waitForNavigation({waitUntil: 'networkidle0'}), + this.selectByVisibleText(this.orderFilterColumnSelect.replace('%FILTERBY', filterBy), value), + ]); + break; + default: + // Do nothing + } + } + + /** + * Reset filter in orders + * @return {Promise} + */ + async resetFilter() { + if (await this.elementVisible(this.resetButton, 2000)) { + await Promise.all([ + this.page.waitForNavigation({waitUntil: 'networkidle0'}), + this.page.click(this.resetButton), + ]); + } + } + + /** + * Go to orders Page + * @param orderRow + * @return {Promise} + */ + async goToOrder(orderRow) { + await Promise.all([ + this.page.waitForNavigation({waitUntil: 'networkidle0'}), + this.page.click(this.orderfirstLineIdTD.replace('%ROW', orderRow)), + ]); + } +}; diff --git a/tests/puppeteer/pages/FO/cart.js b/tests/puppeteer/pages/FO/cart.js index e37bea9eb0c8b..e2bcf413edc69 100644 --- a/tests/puppeteer/pages/FO/cart.js +++ b/tests/puppeteer/pages/FO/cart.js @@ -8,15 +8,13 @@ module.exports = class Cart extends FOBasePage { this.pageTitle = 'Cart'; // Selectors for cart page - this.productName = '#main li:nth-of-type(%NUMBER) div.product-line-info > a'; - this.productPrice = '#main li:nth-of-type(%NUMBER) div.current-price > span'; - this.productQuantity = '#main li:nth-of-type(%NUMBER) div.input-group input.js-cart-line-product-quantity'; + this.productItem = '#main li:nth-of-type(%NUMBER)'; + this.productName = `${this.productItem} div.product-line-info > a`; + this.productPrice = `${this.productItem} div.current-price > span`; + this.productQuantity = `${this.productItem} div.input-group input.js-cart-line-product-quantity`; this.proceedToCheckoutButton = '#main div.checkout a'; this.cartTotalTTC = '.cart-summary-totals span.value'; this.itemsNumber = '#cart-subtotal-products span.label.js-subtotal'; - - // Selectors for checkout page - this.checkoutStepOneTitle = '#checkout-personal-information-step > h1'; } /** @@ -37,8 +35,10 @@ module.exports = class Cart extends FOBasePage { * Click on Proceed to checkout button */ async clickOnProceedToCheckout() { - await this.waitForSelectorAndClick(this.proceedToCheckoutButton); - await this.page.waitForSelector(this.checkoutStepOneTitle); + await Promise.all([ + this.page.waitForNavigation({waitUntil: 'networkidle0'}), + this.page.click(this.proceedToCheckoutButton), + ]); } /** @@ -48,5 +48,20 @@ module.exports = class Cart extends FOBasePage { */ async editProductQuantity(productID, quantity) { await this.setValue(this.productQuantity.replace('%NUMBER', productID), quantity); + // click on price to see that its changed + await this.page.click(this.productPrice.replace('%NUMBER', productID)); + } + + /** + * To get a number from text + * @param selector + * @param timeout + * @return integer + */ + async getPriceFromText(selector, timeout = 0) { + await this.page.waitFor(timeout); + const text = await this.getTextContent(selector); + const number = Number(text.replace(/[^0-9.-]+/g,'')); + return parseFloat(number); } }; diff --git a/tests/puppeteer/pages/FO/home.js b/tests/puppeteer/pages/FO/home.js index 5214ed5d49f8e..5b7b04f54df5c 100644 --- a/tests/puppeteer/pages/FO/home.js +++ b/tests/puppeteer/pages/FO/home.js @@ -25,8 +25,8 @@ module.exports = class Home extends FOBasePage { /** * Check home page */ - async checkHomePage() { - await this.page.waitForSelector(this.homePageSection); + async isHomePage() { + return this.elementVisible(this.homePageSection, 3000); } /** @@ -34,7 +34,10 @@ module.exports = class Home extends FOBasePage { * @param id, product id */ async goToProductPage(id) { - await this.waitForSelectorAndClick(this.productImg.replace('%NUMBER', id), 5000); + await Promise.all([ + this.page.waitForNavigation({waitUntil: 'networkidle0'}), + this.page.click(this.productImg.replace('%NUMBER', id)), + ]); } /** diff --git a/tests/puppeteer/pages/Install/install.js b/tests/puppeteer/pages/Install/install.js index 6e84a12532285..1882fffa94428 100755 --- a/tests/puppeteer/pages/Install/install.js +++ b/tests/puppeteer/pages/Install/install.js @@ -129,33 +129,35 @@ module.exports = class Install extends CommonPage { /** * Check if database exist (if not, it will be created) * and check if all set properly to submit form + * @return {Promise} */ - async checkDatabaseConnected() { + async isDatabaseConnected() { await this.page.click(this.testDbConnectionButton); // Create database 'prestashop' if not exist if (await this.elementVisible(this.createDbButton, 3000)) { await this.page.click(this.createDbButton); } - await this.page.waitForSelector(this.dbResultCheckOkBlock, {visible: true}); + return this.elementVisible(this.dbResultCheckOkBlock, 3000); } /** * Check if prestashop is installed properly */ - async checkInstallationSuccessful() { - await this.page.waitForSelector(this.installationProgressBar, {visible: true}); - await this.page.waitFor(this.installationProgressBar, {visible: true}); - await this.page.waitFor(this.generateSettingsFileStep, {visible: true}); - await this.page.waitFor(this.installDatabaseStep, {visible: true}); - await this.page.waitFor(this.installDefaultDataStep, {visible: true, timeout: 360000}); - await this.page.waitFor(this.populateDatabaseStep, {visible: true, timeout: 360000}); - await this.page.waitFor(this.configureShopStep, {visible: true, timeout: 360000}); - await this.page.waitFor(this.installModulesStep, {visible: true}); - await this.page.waitFor(this.installModulesAddons, {visible: true, timeout: 360000}); - await this.page.waitFor(this.installThemeStep, {visible: true}); - await this.page.waitFor(this.installFixturesStep, {visible: true}); - await this.page.waitForSelector(this.finalStepPageTitle, {visible: true, timeout: 90000}); - await this.checkStepTitle(this.finalStepPageTitle, this.finalStepEnTitle); + async isInstallationSuccessful() { + await Promise.all([ + this.page.waitForSelector(this.installationProgressBar, {visible: true}), + this.page.waitForSelector(this.generateSettingsFileStep, {visible: true}), + this.page.waitForSelector(this.installDatabaseStep, {visible: true, timeout: 60000}), + this.page.waitForSelector(this.installDefaultDataStep, {visible: true, timeout: 120000}), + this.page.waitForSelector(this.populateDatabaseStep, {visible: true, timeout: 180000}), + this.page.waitForSelector(this.configureShopStep, {visible: true, timeout: 240000}), + this.page.waitForSelector(this.installModulesStep, {visible: true, timeout: 360000}), + this.page.waitForSelector(this.installModulesAddons, {visible: true, timeout: 360000}), + this.page.waitForSelector(this.installThemeStep, {visible: true, timeout: 360000}), + this.page.waitForSelector(this.installFixturesStep, {visible: true, timeout: 360000}), + this.page.waitForSelector(this.finalStepPageTitle, {visible: true, timeout: 360000}), + ]); + return this.checkStepTitle(this.finalStepPageTitle, this.finalStepEnTitle); } /**