diff --git a/.github/workflows/sanity.yml b/.github/workflows/sanity.yml index 016428325be63..330a13cb70749 100644 --- a/.github/workflows/sanity.yml +++ b/.github/workflows/sanity.yml @@ -106,7 +106,7 @@ jobs: uses: actions/upload-artifact@v4 if: failure() with: - name: sanity-${{ matrix.php }}-${{ matrix.browser }} + name: sanity-${{ matrix.php }}-${{ matrix.browser }}-${{ matrix.db }} path: | ./tests/UI/screenshots/ ./var/logs diff --git a/tests/UI/campaigns/functional/BO/02_orders/01_orders/createOrders/06_addProductToTheCart.ts b/tests/UI/campaigns/functional/BO/02_orders/01_orders/createOrders/06_addProductToTheCart.ts index 11e64e3c23522..4e8a611dec77f 100644 --- a/tests/UI/campaigns/functional/BO/02_orders/01_orders/createOrders/06_addProductToTheCart.ts +++ b/tests/UI/campaigns/functional/BO/02_orders/01_orders/createOrders/06_addProductToTheCart.ts @@ -10,7 +10,6 @@ import deleteNonOrderedShoppingCarts from '@commonTests/BO/orders/shoppingCarts' // Import BO pages import addProductPage from '@pages/BO/catalog/products/add'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import addOrderPage from '@pages/BO/orders/add'; import { @@ -18,6 +17,7 @@ import { boLoginPage, boOrdersPage, boProductsPage, + boProductsCreateTabPricingPage, boStockPage, type BrowserContext, dataCurrencies, @@ -288,15 +288,18 @@ describe('BO - Orders - Create order : Add a product to the cart', async () => { // Add specific price if (product === productWithSpecificPrice) { await addProductPage.goToTab(page, 'pricing'); - await pricingTab.clickOnAddSpecificPriceButton(page); + await boProductsCreateTabPricingPage.clickOnAddSpecificPriceButton(page); - createProductMessage = await pricingTab.setSpecificPrice(page, productWithSpecificPrice.specificPrice); + createProductMessage = await boProductsCreateTabPricingPage.setSpecificPrice( + page, + productWithSpecificPrice.specificPrice, + ); expect(createProductMessage).to.equal(addProductPage.successfulCreationMessage); } // Add eco tax if (product === productWithEcoTax) { await addProductPage.goToTab(page, 'pricing'); - await pricingTab.addEcoTax(page, productWithEcoTax.ecoTax); + await boProductsCreateTabPricingPage.addEcoTax(page, productWithEcoTax.ecoTax); updateProductMessage = await addProductPage.saveProduct(page); expect(updateProductMessage).to.equal(addProductPage.successfulUpdateMessage); diff --git a/tests/UI/campaigns/functional/BO/02_orders/01_orders/viewAndEditOrder/02_productBlock.ts b/tests/UI/campaigns/functional/BO/02_orders/01_orders/viewAndEditOrder/02_productBlock.ts index a1ead132ca758..57c6bbde788e1 100644 --- a/tests/UI/campaigns/functional/BO/02_orders/01_orders/viewAndEditOrder/02_productBlock.ts +++ b/tests/UI/campaigns/functional/BO/02_orders/01_orders/viewAndEditOrder/02_productBlock.ts @@ -12,7 +12,6 @@ import {createOrderByGuestTest} from '@commonTests/FO/classic/order'; import cartRulesPage from '@pages/BO/catalog/discounts'; import addCartRulePage from '@pages/BO/catalog/discounts/add'; import combinationsTab from '@pages/BO/catalog/products/add/combinationsTab'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import addProductPage from '@pages/BO/catalog/products/add'; import { @@ -21,6 +20,7 @@ import { boOrdersPage, boOrdersViewBlockProductsPage, boProductsPage, + boProductsCreateTabPricingPage, type BrowserContext, dataPaymentMethods, dataProducts, @@ -314,15 +314,18 @@ describe('BO - Orders - View and edit order : Check product block in view order // Add specific price if (product === productWithSpecificPrice) { await addProductPage.goToTab(page, 'pricing'); - await pricingTab.clickOnAddSpecificPriceButton(page); + await boProductsCreateTabPricingPage.clickOnAddSpecificPriceButton(page); - createProductMessage = await pricingTab.setSpecificPrice(page, productWithSpecificPrice.specificPrice); + createProductMessage = await boProductsCreateTabPricingPage.setSpecificPrice( + page, + productWithSpecificPrice.specificPrice, + ); expect(createProductMessage).to.equal(addProductPage.successfulCreationMessage); } // Add eco tax if (product === productWithEcoTax) { await addProductPage.goToTab(page, 'pricing'); - await pricingTab.addEcoTax(page, productWithEcoTax.ecoTax); + await boProductsCreateTabPricingPage.addEcoTax(page, productWithEcoTax.ecoTax); updateProductMessage = await addProductPage.saveProduct(page); expect(updateProductMessage).to.equal(addProductPage.successfulUpdateMessage); diff --git a/tests/UI/campaigns/functional/BO/02_orders/01_orders/viewAndEditOrder/11_checkInvoice.ts b/tests/UI/campaigns/functional/BO/02_orders/01_orders/viewAndEditOrder/11_checkInvoice.ts index 11f9debad9304..6026ccdb80444 100644 --- a/tests/UI/campaigns/functional/BO/02_orders/01_orders/viewAndEditOrder/11_checkInvoice.ts +++ b/tests/UI/campaigns/functional/BO/02_orders/01_orders/viewAndEditOrder/11_checkInvoice.ts @@ -9,7 +9,6 @@ import {createOrderByCustomerTest, createOrderSpecificProductTest} from '@common // Import BO pages import addProductPage from '@pages/BO/catalog/products/add'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import orderPageCustomerBlock from '@pages/BO/orders/view/customerBlock'; import orderPagePaymentBlock from '@pages/BO/orders/view/paymentBlock'; @@ -21,6 +20,7 @@ import { boOrdersViewBlockTabListPage, boProductsPage, boProductsCreateTabDetailsPage, + boProductsCreateTabPricingPage, type BrowserContext, dataAddresses, dataCarriers, @@ -257,15 +257,18 @@ describe('BO - Orders - View and edit order: Check invoice', async () => { // Add specific price if (product === productWithSpecificPrice) { await addProductPage.goToTab(page, 'pricing'); - await pricingTab.clickOnAddSpecificPriceButton(page); + await boProductsCreateTabPricingPage.clickOnAddSpecificPriceButton(page); - createProductMessage = await pricingTab.setSpecificPrice(page, productWithSpecificPrice.specificPrice); + createProductMessage = await boProductsCreateTabPricingPage.setSpecificPrice( + page, + productWithSpecificPrice.specificPrice, + ); expect(createProductMessage).to.equal(addProductPage.successfulCreationMessage); } // Add eco tax if (product === productWithEcoTax) { await addProductPage.goToTab(page, 'pricing'); - await pricingTab.addEcoTax(page, productWithEcoTax.ecoTax); + await boProductsCreateTabPricingPage.addEcoTax(page, productWithEcoTax.ecoTax); updateProductMessage = await addProductPage.saveProduct(page); expect(updateProductMessage).to.equal(addProductPage.successfulUpdateMessage); diff --git a/tests/UI/campaigns/functional/BO/03_catalog/01_products/03_CRUDProductWithCombinations.ts b/tests/UI/campaigns/functional/BO/03_catalog/01_products/03_CRUDProductWithCombinations.ts index 595ae73b7397b..0a6ead35e8abd 100644 --- a/tests/UI/campaigns/functional/BO/03_catalog/01_products/03_CRUDProductWithCombinations.ts +++ b/tests/UI/campaigns/functional/BO/03_catalog/01_products/03_CRUDProductWithCombinations.ts @@ -4,7 +4,6 @@ import testContext from '@utils/testContext'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; import combinationsTab from '@pages/BO/catalog/products/add/combinationsTab'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import {expect} from 'chai'; import { @@ -12,6 +11,7 @@ import { boDashboardPage, boLoginPage, boProductsPage, + boProductsCreateTabPricingPage, type BrowserContext, FakerProduct, foClassicProductPage, @@ -515,7 +515,7 @@ describe('BO - Catalog - Products : CRUD product with combinations', async () => it('should go to Pricing tab and edit retail price, enable the product then save', async function () { await testContext.addContextItem(this, 'testIdentifier', 'saveProduct', baseContext); - await pricingTab.setProductPricing(page, pricingData); + await boProductsCreateTabPricingPage.setProductPricing(page, pricingData); await createProductsPage.setProductStatus(page, true); diff --git a/tests/UI/campaigns/functional/BO/03_catalog/01_products/04_CRUDPackOfProducts.ts b/tests/UI/campaigns/functional/BO/03_catalog/01_products/04_CRUDPackOfProducts.ts index 8d0a0f0195424..816ec11945bde 100644 --- a/tests/UI/campaigns/functional/BO/03_catalog/01_products/04_CRUDPackOfProducts.ts +++ b/tests/UI/campaigns/functional/BO/03_catalog/01_products/04_CRUDPackOfProducts.ts @@ -4,13 +4,13 @@ import testContext from '@utils/testContext'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; import packTab from '@pages/BO/catalog/products/add/packTab'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import {expect} from 'chai'; import { boDashboardPage, boLoginPage, boProductsPage, + boProductsCreateTabPricingPage, type BrowserContext, dataEmployees, dataProducts, @@ -346,7 +346,7 @@ describe('BO - Catalog - Products : CRUD pack of products', async () => { it('should go to Pricing tab and edit retail price, enable the product then save', async function () { await testContext.addContextItem(this, 'testIdentifier', 'editRetailPrice', baseContext); - await pricingTab.setProductPricing(page, pricingData); + await boProductsCreateTabPricingPage.setProductPricing(page, pricingData); await createProductsPage.setProductStatus(page, true); diff --git a/tests/UI/campaigns/functional/BO/03_catalog/01_products/08_header.ts b/tests/UI/campaigns/functional/BO/03_catalog/01_products/08_header.ts index f2ffa8191f161..66c79862a40b9 100644 --- a/tests/UI/campaigns/functional/BO/03_catalog/01_products/08_header.ts +++ b/tests/UI/campaigns/functional/BO/03_catalog/01_products/08_header.ts @@ -6,7 +6,6 @@ import {deleteProductTest} from '@commonTests/BO/catalog/product'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import {expect} from 'chai'; import {faker} from '@faker-js/faker'; @@ -16,6 +15,7 @@ import { boProductsPage, boProductsCreateTabDescriptionPage, boProductsCreateTabDetailsPage, + boProductsCreateTabPricingPage, boProductsCreateTabStocksPage, type BrowserContext, FakerProduct, @@ -209,7 +209,7 @@ describe('BO - Catalog - Products : Header', async () => { it('should edit the retail price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'editRetailPrice', baseContext); - await pricingTab.setRetailPrice(page, false, productRetailPriceTaxIncluded); + await boProductsCreateTabPricingPage.setRetailPrice(page, false, productRetailPriceTaxIncluded); const message = await createProductsPage.saveProduct(page); expect(message).to.eq(createProductsPage.successfulUpdateMessage); diff --git a/tests/UI/campaigns/functional/BO/03_catalog/01_products/12_packTab.ts b/tests/UI/campaigns/functional/BO/03_catalog/01_products/12_packTab.ts index 1bba192c4e07b..5b97e861c8912 100644 --- a/tests/UI/campaigns/functional/BO/03_catalog/01_products/12_packTab.ts +++ b/tests/UI/campaigns/functional/BO/03_catalog/01_products/12_packTab.ts @@ -8,13 +8,13 @@ import {deleteProductTest} from '@commonTests/BO/catalog/product'; // Import BO pages import createProductsPage from '@pages/BO/catalog/products/add'; import packTab from '@pages/BO/catalog/products/add/packTab'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import { boDashboardPage, boLoginPage, boOrdersPage, boProductsPage, + boProductsCreateTabPricingPage, type BrowserContext, dataCustomers, dataOrderStatuses, @@ -290,7 +290,7 @@ describe('BO - Catalog - Products : Pack Tab', async () => { it('should set the retail price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'setRetailPrice', baseContext); - await pricingTab.setRetailPrice(page, true, productRetailPrice); + await boProductsCreateTabPricingPage.setRetailPrice(page, true, productRetailPrice); const message = await createProductsPage.saveProduct(page); expect(message).to.eq(createProductsPage.successfulUpdateMessage); diff --git a/tests/UI/campaigns/functional/BO/03_catalog/01_products/17_pricingTab.ts b/tests/UI/campaigns/functional/BO/03_catalog/01_products/17_pricingTab.ts index b6774c976e5b5..6d0ebc458b218 100644 --- a/tests/UI/campaigns/functional/BO/03_catalog/01_products/17_pricingTab.ts +++ b/tests/UI/campaigns/functional/BO/03_catalog/01_products/17_pricingTab.ts @@ -3,7 +3,6 @@ import testContext from '@utils/testContext'; // Import BO pages import createProductPage from '@pages/BO/catalog/products/add'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import createCatalogPriceRulePage from '@pages/BO/catalog/discounts/catalogPriceRules/add'; import cartRulesPage from '@pages/BO/catalog/discounts'; @@ -15,6 +14,7 @@ import { boDashboardPage, boLoginPage, boProductsPage, + boProductsCreateTabPricingPage, type BrowserContext, FakerCatalogPriceRule, FakerProduct, @@ -133,13 +133,13 @@ describe('BO - Catalog - Products : Pricing tab', async () => { it('should check summary block', async function () { await testContext.addContextItem(this, 'testIdentifier', 'checkSummaryBlock', baseContext); - const result = await pricingTab.getSummary(page); + const result = await boProductsCreateTabPricingPage.getSummary(page); await Promise.all([ expect(result.priceTaxExcludedValue).to.eq('€100.00 tax excl.'), expect(result.priceTaxIncludedValue).to.eq('€100.00 tax incl.'), expect(result.marginValue).to.eq('€100.00 margin'), expect(result.marginRateValue).to.eq('100.00% margin rate'), - expect(result.WholesalePriceValue).to.eq('€0.00 cost price'), + expect(result.wholesalePriceValue).to.eq('€0.00 cost price'), ]); }); @@ -172,7 +172,7 @@ describe('BO - Catalog - Products : Pricing tab', async () => { it('should edit the product price and the tax rule', async function () { await testContext.addContextItem(this, 'testIdentifier', 'editRetailPrice', baseContext); - await pricingTab.setTaxRule(page, 'FR Taux standard (20%)'); + await boProductsCreateTabPricingPage.setTaxRule(page, 'FR Taux standard (20%)'); const message = await createProductPage.saveProduct(page); expect(message).to.eq(createProductPage.successfulUpdateMessage); @@ -181,13 +181,13 @@ describe('BO - Catalog - Products : Pricing tab', async () => { it('should check summary block', async function () { await testContext.addContextItem(this, 'testIdentifier', 'checkSummaryBlock2', baseContext); - const result = await pricingTab.getSummary(page); + const result = await boProductsCreateTabPricingPage.getSummary(page); await Promise.all([ expect(result.priceTaxExcludedValue).to.eq('€100.00 tax excl.'), expect(result.priceTaxIncludedValue).to.eq('€120.00 tax incl.'), expect(result.marginValue).to.eq('€100.00 margin'), expect(result.marginRateValue).to.eq('100.00% margin rate'), - expect(result.WholesalePriceValue).to.eq('€0.00 cost price'), + expect(result.wholesalePriceValue).to.eq('€0.00 cost price'), ]); }); @@ -220,7 +220,7 @@ describe('BO - Catalog - Products : Pricing tab', async () => { it('should add a cost price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'addCostPrice', baseContext); - await pricingTab.setCostPrice(page, 35); + await boProductsCreateTabPricingPage.setCostPrice(page, 35); const message = await createProductPage.saveProduct(page); expect(message).to.eq(createProductPage.successfulUpdateMessage); @@ -229,21 +229,21 @@ describe('BO - Catalog - Products : Pricing tab', async () => { it('should check summary block', async function () { await testContext.addContextItem(this, 'testIdentifier', 'checkSummaryBlock3', baseContext); - const result = await pricingTab.getSummary(page); + const result = await boProductsCreateTabPricingPage.getSummary(page); await Promise.all([ expect(result.priceTaxExcludedValue).to.eq('€100.00 tax excl.'), expect(result.priceTaxIncludedValue).to.eq('€120.00 tax incl.'), expect(result.marginValue).to.eq('€65.00 margin'), expect(result.marginRateValue).to.eq('65.00% margin rate'), - expect(result.WholesalePriceValue).to.eq('€35.00 cost price'), + expect(result.wholesalePriceValue).to.eq('€35.00 cost price'), ]); }); it('should edit Retail price per unit section', async function () { await testContext.addContextItem(this, 'testIdentifier', 'editRetailPriceParUnit', baseContext); - await pricingTab.setDisplayRetailPricePerUnit(page, true); - await pricingTab.setRetailPricePerUnit(page, true, 10, 'per unit'); + await boProductsCreateTabPricingPage.setDisplayRetailPricePerUnit(page, true); + await boProductsCreateTabPricingPage.setRetailPricePerUnit(page, true, 10, 'per unit'); const message = await createProductPage.saveProduct(page); expect(message).to.eq(createProductPage.successfulUpdateMessage); @@ -252,16 +252,16 @@ describe('BO - Catalog - Products : Pricing tab', async () => { it('should check summary block', async function () { await testContext.addContextItem(this, 'testIdentifier', 'checkSummaryBlock4', baseContext); - const result = await pricingTab.getSummary(page); + const result = await boProductsCreateTabPricingPage.getSummary(page); await Promise.all([ expect(result.priceTaxExcludedValue).to.eq('€100.00 tax excl.'), expect(result.priceTaxIncludedValue).to.eq('€120.00 tax incl.'), expect(result.marginValue).to.eq('€65.00 margin'), expect(result.marginRateValue).to.eq('65.00% margin rate'), - expect(result.WholesalePriceValue).to.eq('€35.00 cost price'), + expect(result.wholesalePriceValue).to.eq('€35.00 cost price'), ]); - const unitPrice = await pricingTab.getUnitPriceValue(page); + const unitPrice = await boProductsCreateTabPricingPage.getUnitPriceValue(page); expect(unitPrice).to.eq('€10.00 per unit'); }); @@ -294,7 +294,7 @@ describe('BO - Catalog - Products : Pricing tab', async () => { it('should check Display On sale flag', async function () { await testContext.addContextItem(this, 'testIdentifier', 'checkDisplayOnSaleFlag', baseContext); - await pricingTab.setDisplayOnSaleFlag(page); + await boProductsCreateTabPricingPage.setDisplayOnSaleFlag(page); const message = await createProductPage.saveProduct(page); expect(message).to.eq(createProductPage.successfulUpdateMessage); @@ -329,9 +329,9 @@ describe('BO - Catalog - Products : Pricing tab', async () => { it('should add a specific price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'addSpecificPrice', baseContext); - await pricingTab.clickOnAddSpecificPriceButton(page); + await boProductsCreateTabPricingPage.clickOnAddSpecificPriceButton(page); - const message = await pricingTab.setSpecificPrice(page, specificPriceData.specificPrice); + const message = await boProductsCreateTabPricingPage.setSpecificPrice(page, specificPriceData.specificPrice); expect(message).to.equal(createProductPage.successfulCreationMessage); }); @@ -364,9 +364,9 @@ describe('BO - Catalog - Products : Pricing tab', async () => { it('should edit specific price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'editSpecificPrice', baseContext); - await pricingTab.clickOnEditSpecificPriceIcon(page, 1); + await boProductsCreateTabPricingPage.clickOnEditSpecificPriceIcon(page, 1); - const message = await pricingTab.setSpecificPrice(page, editSpecificPriceData.specificPrice); + const message = await boProductsCreateTabPricingPage.setSpecificPrice(page, editSpecificPriceData.specificPrice); expect(message).to.equal('Update successful'); }); @@ -399,8 +399,8 @@ describe('BO - Catalog - Products : Pricing tab', async () => { it('should delete specific price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'deleteSpecificPrice', baseContext); - const successMessage = await pricingTab.deleteSpecificPrice(page, 1); - expect(successMessage).to.eq(pricingTab.successfulDeleteMessage); + const successMessage = await boProductsCreateTabPricingPage.deleteSpecificPrice(page, 1); + expect(successMessage).to.eq(boProductsCreateTabPricingPage.successfulDeleteMessage); }); it('should preview product', async function () { @@ -432,8 +432,8 @@ describe('BO - Catalog - Products : Pricing tab', async () => { it('should click on show catalog price rule button then on manage catalog price rules', async function () { await testContext.addContextItem(this, 'testIdentifier', 'clickOnManageCatalogPriceRuleLink', baseContext); - await pricingTab.clickOnShowCatalogPriceRuleButton(page); - page = await pricingTab.clickOnManageCatalogPriceRuleLink(page); + await boProductsCreateTabPricingPage.clickOnShowCatalogPriceRuleButton(page); + page = await boProductsCreateTabPricingPage.clickOnManageCatalogPriceRuleLink(page); const pageTitle = await catalogPriceRulesPage.getPageTitle(page); expect(pageTitle).to.contains(catalogPriceRulesPage.pageTitle); @@ -461,9 +461,9 @@ describe('BO - Catalog - Products : Pricing tab', async () => { it('should click on show catalog price rule button and check the catalog price rule', async function () { await testContext.addContextItem(this, 'testIdentifier', 'clickOnShowCatalogPriceRuleButton', baseContext); - await pricingTab.clickOnShowCatalogPriceRuleButton(page); + await boProductsCreateTabPricingPage.clickOnShowCatalogPriceRuleButton(page); - const result = await pricingTab.getCatalogPriceRuleData(page, 1); + const result = await boProductsCreateTabPricingPage.getCatalogPriceRuleData(page, 1); await Promise.all([ expect(result.name).to.eq(newCatalogPriceRuleData.name), expect(result.currency).to.eq(newCatalogPriceRuleData.currency), @@ -478,7 +478,7 @@ describe('BO - Catalog - Products : Pricing tab', async () => { it('should click on hide catalog price rules button', async function () { await testContext.addContextItem(this, 'testIdentifier', 'clickOnHideCatalogPriceRuleButton', baseContext); - const isCatalogPriceRulesTableVisible = await pricingTab.clickOnHideCatalogPriceRulesButton(page); + const isCatalogPriceRulesTableVisible = await boProductsCreateTabPricingPage.clickOnHideCatalogPriceRulesButton(page); expect(isCatalogPriceRulesTableVisible).to.eq(false); }); }); diff --git a/tests/UI/campaigns/functional/BO/13_shopParameters/01_general/general/05_roundMode.ts b/tests/UI/campaigns/functional/BO/13_shopParameters/01_general/general/05_roundMode.ts index 3af271a4905c7..609a29333b0dd 100644 --- a/tests/UI/campaigns/functional/BO/13_shopParameters/01_general/general/05_roundMode.ts +++ b/tests/UI/campaigns/functional/BO/13_shopParameters/01_general/general/05_roundMode.ts @@ -5,7 +5,6 @@ import testContext from '@utils/testContext'; import {createProductTest, deleteProductTest} from '@commonTests/BO/catalog/product'; // Import BO pages -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import createProductsPage from '@pages/BO/catalog/products/add'; import {expect} from 'chai'; @@ -13,6 +12,7 @@ import { boDashboardPage, boLoginPage, boProductsPage, + boProductsCreateTabPricingPage, boShopParametersPage, type BrowserContext, FakerProduct, @@ -187,7 +187,7 @@ describe('BO - Shop Parameters - General : Round mode', async () => { it('should edit the product price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'editProductPrice1', baseContext); - await pricingTab.setProductPricing(page, pricingData); + await boProductsCreateTabPricingPage.setProductPricing(page, pricingData); const updateProductMessage = await createProductsPage.saveProduct(page); expect(updateProductMessage).to.equal(createProductsPage.successfulUpdateMessage); @@ -306,7 +306,7 @@ describe('BO - Shop Parameters - General : Round mode', async () => { it('should edit the product price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'editProductPrice2', baseContext); - await pricingTab.setProductPricing(page, pricingData); + await boProductsCreateTabPricingPage.setProductPricing(page, pricingData); const updateProductMessage = await createProductsPage.saveProduct(page); expect(updateProductMessage).to.equal(createProductsPage.successfulUpdateMessage); diff --git a/tests/UI/campaigns/functional/BO/13_shopParameters/03_productSettings/01_productsGeneral/04_quantityDiscountsBasedOn.ts b/tests/UI/campaigns/functional/BO/13_shopParameters/03_productSettings/01_productsGeneral/04_quantityDiscountsBasedOn.ts index 9bbca48548c58..e575d6e18f90d 100644 --- a/tests/UI/campaigns/functional/BO/13_shopParameters/03_productSettings/01_productsGeneral/04_quantityDiscountsBasedOn.ts +++ b/tests/UI/campaigns/functional/BO/13_shopParameters/03_productSettings/01_productsGeneral/04_quantityDiscountsBasedOn.ts @@ -4,7 +4,6 @@ import testContext from '@utils/testContext'; // Import pages // Import BO pages import addProductPage from '@pages/BO/catalog/products/add'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import combinationsTab from '@pages/BO/catalog/products/add/combinationsTab'; import {expect} from 'chai'; @@ -12,6 +11,7 @@ import { boDashboardPage, boLoginPage, boProductsPage, + boProductsCreateTabPricingPage, boProductSettingsPage, type BrowserContext, FakerProduct, @@ -188,9 +188,12 @@ describe('BO - Shop Parameters - Product Settings : Choose quantity discount bas it('should add specific price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'addSpecificPrice', baseContext); - await pricingTab.clickOnAddSpecificPriceButton(page); + await boProductsCreateTabPricingPage.clickOnAddSpecificPriceButton(page); - const createProductMessage = await pricingTab.setSpecificPrice(page, productWithCombinations.specificPrice); + const createProductMessage = await boProductsCreateTabPricingPage.setSpecificPrice( + page, + productWithCombinations.specificPrice, + ); expect(createProductMessage).to.equal(addProductPage.successfulCreationMessage); }); diff --git a/tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/04_indexingSetCronJob.ts b/tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/04_indexingSetCronJob.ts new file mode 100644 index 0000000000000..9ebe851defc92 --- /dev/null +++ b/tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/04_indexingSetCronJob.ts @@ -0,0 +1,181 @@ +import testContext from '@utils/testContext'; + +import {expect} from 'chai'; +import { + boDashboardPage, + boLoginPage, + boProductsCreatePage, + boProductsPage, + boSearchPage, + type BrowserContext, + FakerProduct, + type Page, + utilsPlaywright, +} from '@prestashop-core/ui-testing'; +import {deleteProductTest} from '@commonTests/BO/catalog/product'; + +const baseContext: string = 'functional_BO_shopParameters_search_search_indexingSetCronJob'; + +describe('BO - Shop Parameters - Search - Indexing: Set a cron job', async () => { + let browserContext: BrowserContext; + let page: Page; + let numIndexedProducts: number = 0; + + const product1: FakerProduct = new FakerProduct({status: true}); + const product2: FakerProduct = new FakerProduct({status: true}); + + describe('Indexing', async () => { + before(async function () { + browserContext = await utilsPlaywright.createBrowserContext(this.browser); + page = await utilsPlaywright.newTab(browserContext); + }); + + after(async () => { + await utilsPlaywright.closeBrowserContext(browserContext); + }); + + it('should login in BO', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'loginBO', baseContext); + + await boLoginPage.goTo(page, global.BO.URL); + await boLoginPage.successLogin(page, global.BO.EMAIL, global.BO.PASSWD); + + const pageTitle = await boDashboardPage.getPageTitle(page); + expect(pageTitle).to.contains(boDashboardPage.pageTitle); + }); + + it('should go to \'Shop Parameters > Search\' page', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goToSearchPage', baseContext); + + await boDashboardPage.goToSubMenu( + page, + boDashboardPage.shopParametersParentLink, + boDashboardPage.searchLink, + ); + + const pageTitle = await boSearchPage.getPageTitle(page); + expect(pageTitle).to.contains(boSearchPage.pageTitle); + }); + + it('should check Indexed products', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkIndexedProducts', baseContext); + + numIndexedProducts = await boSearchPage.getNumIndexedProducts(page); + expect(numIndexedProducts).to.be.gt(0); + + const numTotalProducts = await boSearchPage.getNumTotalProducts(page); + expect(numIndexedProducts).to.equal(numTotalProducts); + }); + [ + { + status: 'disable', + product: product1, + }, + { + status: 'cronRebuildJob', + product: product2, + }, + ].forEach((arg: {status: string, product: FakerProduct}, index: number) => { + it('should go to \'Catalog > Products\' page', async function () { + await testContext.addContextItem(this, 'testIdentifier', `goToProductsPage${index}`, baseContext); + + await boDashboardPage.goToSubMenu(page, boDashboardPage.catalogParentLink, boDashboardPage.productsLink); + await boProductsPage.closeSfToolBar(page); + + const pageTitle = await boProductsPage.getPageTitle(page); + expect(pageTitle).to.contains(boProductsPage.pageTitle); + }); + + it('should click on \'New product\' button and check new product modal', async function () { + await testContext.addContextItem(this, 'testIdentifier', `clickOnNewProductButton${index}`, baseContext); + + const isModalVisible = await boProductsPage.clickOnNewProductButton(page); + expect(isModalVisible).to.be.eq(true); + }); + + it(`should choose '${arg.product.type} product'`, async function () { + await testContext.addContextItem(this, 'testIdentifier', `chooseTypeOfProduct${index}`, baseContext); + + await boProductsPage.selectProductType(page, arg.product.type); + + const pageTitle = await boProductsCreatePage.getPageTitle(page); + expect(pageTitle).to.contains(boProductsCreatePage.pageTitle); + }); + + it('should go to new product page', async function () { + await testContext.addContextItem(this, 'testIdentifier', `goToNewProductPage${index}`, baseContext); + + await boProductsPage.clickOnAddNewProduct(page); + + const pageTitle = await boProductsCreatePage.getPageTitle(page); + expect(pageTitle).to.contains(boProductsCreatePage.pageTitle); + }); + + it('should create product', async function () { + await testContext.addContextItem(this, 'testIdentifier', `setProduct${index}`, baseContext); + + await boProductsCreatePage.closeSfToolBar(page); + + const createProductMessage = await boProductsCreatePage.setProduct(page, arg.product); + expect(createProductMessage).to.equal(boProductsCreatePage.successfulUpdateMessage); + }); + + it('should go to \'Shop Parameters > Search\' page', async function () { + await testContext.addContextItem(this, 'testIdentifier', `returnToSearchPage${index}`, baseContext); + + await boDashboardPage.goToSubMenu( + page, + boDashboardPage.shopParametersParentLink, + boDashboardPage.searchLink, + ); + + const pageTitle = await boSearchPage.getPageTitle(page); + expect(pageTitle).to.contains(boSearchPage.pageTitle); + }); + + if (arg.status === 'cronRebuildJob') { + it('should click on the rebuild index cron job link', async function () { + await testContext.addContextItem(this, 'testIdentifier', `${arg.status}${index}`, baseContext); + + await boSearchPage.clickRebuildEntireIndexCronJobLink(page); + await boSearchPage.reloadPage(page); + + const pageTitle = await boSearchPage.getPageTitle(page); + expect(pageTitle).to.contains(boSearchPage.pageTitle); + }); + } + + it('should check Indexed products', async function () { + await testContext.addContextItem(this, 'testIdentifier', `checkIndexedProductsAfterAddProduct${index}`, baseContext); + + const numIndexedProductsAfterAdd = await boSearchPage.getNumIndexedProducts(page); + expect(numIndexedProductsAfterAdd).to.be.gt(0); + expect(numIndexedProductsAfterAdd).to.equal(numIndexedProducts + (index + 1)); + + const numTotalProducts = await boSearchPage.getNumTotalProducts(page); + expect(numTotalProducts).to.equal(numIndexedProducts + (index + 1)); + }); + + if (arg.status === 'disable') { + it(`should ${arg.status} Indexing`, async function () { + await testContext.addContextItem(this, 'testIdentifier', `${arg.status}${index}`, baseContext); + + const textResult = await boSearchPage.setIndexing(page, false); + expect(textResult).to.be.eq(boSearchPage.settingsUpdateMessage); + }); + } + }); + + // Reset + it('should enable Indexing', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'resetIndexing', baseContext); + + const textResult = await boSearchPage.setIndexing(page, true); + expect(textResult).to.be.eq(boSearchPage.settingsUpdateMessage); + }); + }); + + // POST-TEST : Delete products + deleteProductTest(product1, `${baseContext}_post_0`); + deleteProductTest(product2, `${baseContext}_post_1`); +}); diff --git a/tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/03_quickEditStatus.ts b/tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/06_quickEditStatus.ts similarity index 100% rename from tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/03_quickEditStatus.ts rename to tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/06_quickEditStatus.ts diff --git a/tests/UI/campaigns/functional/FO/classic/08_menuAndNavigation/03_navigationAndDisplay/01_displayTags.ts b/tests/UI/campaigns/functional/FO/classic/08_menuAndNavigation/03_navigationAndDisplay/01_displayTags.ts index 0c1a907cde37a..740c87eb29a48 100644 --- a/tests/UI/campaigns/functional/FO/classic/08_menuAndNavigation/03_navigationAndDisplay/01_displayTags.ts +++ b/tests/UI/campaigns/functional/FO/classic/08_menuAndNavigation/03_navigationAndDisplay/01_displayTags.ts @@ -6,13 +6,13 @@ import {deleteProductTest} from '@commonTests/BO/catalog/product'; // Import pages import addProductPage from '@pages/BO/catalog/products/add'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import {expect} from 'chai'; import { boDashboardPage, boLoginPage, boProductsPage, + boProductsCreateTabPricingPage, boProductsCreateTabStocksPage, boProductSettingsPage, type BrowserContext, @@ -248,9 +248,9 @@ describe('FO - Navigation and display : Display tags', async () => { it('should add a specific price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'addSpecificPrice', baseContext); - await pricingTab.clickOnAddSpecificPriceButton(page); + await boProductsCreateTabPricingPage.clickOnAddSpecificPriceButton(page); - const message = await pricingTab.setSpecificPrice(page, specificPriceData.specificPrice); + const message = await boProductsCreateTabPricingPage.setSpecificPrice(page, specificPriceData.specificPrice); expect(message).to.equal(addProductPage.successfulCreationMessage); }); }); diff --git a/tests/UI/campaigns/functional/FO/classic/09_productPage/02_productPage/10_displayDiscount.ts b/tests/UI/campaigns/functional/FO/classic/09_productPage/02_productPage/10_displayDiscount.ts index 3dbcb13d5e233..3cb290f28a0f2 100644 --- a/tests/UI/campaigns/functional/FO/classic/09_productPage/02_productPage/10_displayDiscount.ts +++ b/tests/UI/campaigns/functional/FO/classic/09_productPage/02_productPage/10_displayDiscount.ts @@ -6,13 +6,13 @@ import {deleteProductTest} from '@commonTests/BO/catalog/product'; // Import BO pages import createProductPage from '@pages/BO/catalog/products/add'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import {expect} from 'chai'; import { boDashboardPage, boLoginPage, boProductsPage, + boProductsCreateTabPricingPage, type BrowserContext, FakerProduct, foClassicCategoryPage, @@ -133,7 +133,7 @@ describe('FO - Product page - Product page : Display discount', async () => { await testContext.addContextItem(this, 'testIdentifier', 'setRetailPrice', baseContext); await createProductPage.goToTab(page, 'pricing'); - await pricingTab.setRetailPrice(page, true, 20); + await boProductsCreateTabPricingPage.setRetailPrice(page, true, 20); const message = await createProductPage.saveProduct(page); expect(message).to.eq(createProductPage.successfulUpdateMessage); @@ -142,9 +142,9 @@ describe('FO - Product page - Product page : Display discount', async () => { it('should create new specific price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'setSpecificPrice', baseContext); - await pricingTab.clickOnAddSpecificPriceButton(page); + await boProductsCreateTabPricingPage.clickOnAddSpecificPriceButton(page); - const createProductMessage = await pricingTab.setSpecificPrice(page, newProductData.specificPrice); + const createProductMessage = await boProductsCreateTabPricingPage.setSpecificPrice(page, newProductData.specificPrice); expect(createProductMessage).to.equal(createProductPage.successfulCreationMessage); }); }); diff --git a/tests/UI/campaigns/functional/FO/classic/09_productPage/02_productPage/11_displayVolumeDiscount.ts b/tests/UI/campaigns/functional/FO/classic/09_productPage/02_productPage/11_displayVolumeDiscount.ts index 0766bc3beeb7d..34ff6d811b2d2 100644 --- a/tests/UI/campaigns/functional/FO/classic/09_productPage/02_productPage/11_displayVolumeDiscount.ts +++ b/tests/UI/campaigns/functional/FO/classic/09_productPage/02_productPage/11_displayVolumeDiscount.ts @@ -6,7 +6,6 @@ import {deleteProductTest} from '@commonTests/BO/catalog/product'; // Import BO pages import createProductPage from '@pages/BO/catalog/products/add'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; // Import FO pages import {blockCartModal} from '@pages/FO/classic/modal/blockCart'; @@ -16,6 +15,7 @@ import { boDashboardPage, boLoginPage, boProductsPage, + boProductsCreateTabPricingPage, type BrowserContext, FakerProduct, foClassicCartPage, @@ -143,7 +143,7 @@ describe('FO - Product page - Product page : Display volume discount', async () await testContext.addContextItem(this, 'testIdentifier', 'setRetailPrice', baseContext); await createProductPage.goToTab(page, 'pricing'); - await pricingTab.setRetailPrice(page, false, 20); + await boProductsCreateTabPricingPage.setRetailPrice(page, false, 20); const message = await createProductPage.saveProduct(page); expect(message).to.eq(createProductPage.successfulUpdateMessage); @@ -152,9 +152,9 @@ describe('FO - Product page - Product page : Display volume discount', async () it('should create new specific price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'setSpecificPrice', baseContext); - await pricingTab.clickOnAddSpecificPriceButton(page); + await boProductsCreateTabPricingPage.clickOnAddSpecificPriceButton(page); - const createProductMessage = await pricingTab.setSpecificPrice(page, newProductData.specificPrice); + const createProductMessage = await boProductsCreateTabPricingPage.setSpecificPrice(page, newProductData.specificPrice); expect(createProductMessage).to.equal(createProductPage.successfulCreationMessage); }); }); @@ -261,9 +261,12 @@ describe('FO - Product page - Product page : Display volume discount', async () it('should create a second specific price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'createSecondSpecificPrice', baseContext); - await pricingTab.clickOnAddSpecificPriceButton(page); + await boProductsCreateTabPricingPage.clickOnAddSpecificPriceButton(page); - const createProductMessage = await pricingTab.setSpecificPrice(page, secondSpecificPriceData.specificPrice); + const createProductMessage = await boProductsCreateTabPricingPage.setSpecificPrice( + page, + secondSpecificPriceData.specificPrice, + ); expect(createProductMessage).to.equal(createProductPage.successfulCreationMessage); }); diff --git a/tests/UI/campaigns/functional/FO/hummingbird/08_menuAndNavigation/03_navigationAndDisplay/01_displayTags.ts b/tests/UI/campaigns/functional/FO/hummingbird/08_menuAndNavigation/03_navigationAndDisplay/01_displayTags.ts index fecbfcbc5b749..974b43f3225d3 100644 --- a/tests/UI/campaigns/functional/FO/hummingbird/08_menuAndNavigation/03_navigationAndDisplay/01_displayTags.ts +++ b/tests/UI/campaigns/functional/FO/hummingbird/08_menuAndNavigation/03_navigationAndDisplay/01_displayTags.ts @@ -7,13 +7,13 @@ import {enableHummingbird, disableHummingbird} from '@commonTests/BO/design/humm // Import BO pages import addProductPage from '@pages/BO/catalog/products/add'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import {expect} from 'chai'; import { boDashboardPage, boLoginPage, boProductsPage, + boProductsCreateTabPricingPage, boProductsCreateTabStocksPage, boProductSettingsPage, type BrowserContext, @@ -261,9 +261,9 @@ describe('FO - Navigation and display : Display tags', async () => { it('should add a specific price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'addSpecificPrice', baseContext); - await pricingTab.clickOnAddSpecificPriceButton(page); + await boProductsCreateTabPricingPage.clickOnAddSpecificPriceButton(page); - const message = await pricingTab.setSpecificPrice(page, specificPriceData.specificPrice); + const message = await boProductsCreateTabPricingPage.setSpecificPrice(page, specificPriceData.specificPrice); expect(message).to.equal(addProductPage.successfulCreationMessage); }); }); diff --git a/tests/UI/campaigns/functional/FO/hummingbird/09_productPage/02_productPage/16_displayDiscountAndVolumeDiscount.ts b/tests/UI/campaigns/functional/FO/hummingbird/09_productPage/02_productPage/16_displayDiscountAndVolumeDiscount.ts index f1f006954e16f..658c004d846ba 100644 --- a/tests/UI/campaigns/functional/FO/hummingbird/09_productPage/02_productPage/16_displayDiscountAndVolumeDiscount.ts +++ b/tests/UI/campaigns/functional/FO/hummingbird/09_productPage/02_productPage/16_displayDiscountAndVolumeDiscount.ts @@ -7,7 +7,6 @@ import {enableHummingbird, disableHummingbird} from '@commonTests/BO/design/humm // Import BO pages import createProductPage from '@pages/BO/catalog/products/add'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; // Import FO pages import blockCartModal from '@pages/FO/hummingbird/modal/blockCart'; @@ -17,6 +16,7 @@ import { boDashboardPage, boLoginPage, boProductsPage, + boProductsCreateTabPricingPage, type BrowserContext, FakerProduct, foHummingbirdCartPage, @@ -146,7 +146,7 @@ describe('FO - Product page - Product page : Display discount', async () => { await testContext.addContextItem(this, 'testIdentifier', 'setRetailPrice', baseContext); await createProductPage.goToTab(page, 'pricing'); - await pricingTab.setRetailPrice(page, false, 20); + await boProductsCreateTabPricingPage.setRetailPrice(page, false, 20); const message = await createProductPage.saveProduct(page); expect(message).to.eq(createProductPage.successfulUpdateMessage); @@ -155,9 +155,9 @@ describe('FO - Product page - Product page : Display discount', async () => { it('should create new specific price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'setSpecificPrice', baseContext); - await pricingTab.clickOnAddSpecificPriceButton(page); + await boProductsCreateTabPricingPage.clickOnAddSpecificPriceButton(page); - const createProductMessage = await pricingTab.setSpecificPrice(page, newProductData.specificPrice); + const createProductMessage = await boProductsCreateTabPricingPage.setSpecificPrice(page, newProductData.specificPrice); expect(createProductMessage).to.equal(createProductPage.successfulCreationMessage); }); }); @@ -264,9 +264,12 @@ describe('FO - Product page - Product page : Display discount', async () => { it('should create a second specific price', async function () { await testContext.addContextItem(this, 'testIdentifier', 'createSecondSpecificPrice', baseContext); - await pricingTab.clickOnAddSpecificPriceButton(page); + await boProductsCreateTabPricingPage.clickOnAddSpecificPriceButton(page); - const createProductMessage = await pricingTab.setSpecificPrice(page, secondSpecificPriceData.specificPrice); + const createProductMessage = await boProductsCreateTabPricingPage.setSpecificPrice( + page, + secondSpecificPriceData.specificPrice, + ); expect(createProductMessage).to.equal(createProductPage.successfulCreationMessage); }); diff --git a/tests/UI/campaigns/functional/WS/03_productsCRUD.ts b/tests/UI/campaigns/functional/WS/03_productsCRUD.ts index ab690c5b548df..3a454c5d13c0e 100644 --- a/tests/UI/campaigns/functional/WS/03_productsCRUD.ts +++ b/tests/UI/campaigns/functional/WS/03_productsCRUD.ts @@ -13,7 +13,6 @@ import {enableEcoTaxTest, disableEcoTaxTest} from '@commonTests/BO/international import webservicePage from '@pages/BO/advancedParameters/webservice'; import createProductsPage from '@pages/BO/catalog/products/add'; import optionsTab from '@pages/BO/catalog/products/add/optionsTab'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import seoTab from '@pages/BO/catalog/products/add/seoTab'; // Import data @@ -28,6 +27,7 @@ import { boProductsPage, boProductsCreateTabDescriptionPage, boProductsCreateTabDetailsPage, + boProductsCreateTabPricingPage, boProductsCreateTabShippingPage, boProductsCreateTabStocksPage, type BrowserContext, @@ -820,7 +820,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'postCheckPrice', baseContext); const xmlValue = productXml.getAttributeValue(xmlCreate, 'price'); - const value = (await pricingTab.getValue(page, 'price')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'price')); expect(value).to.eq(xmlValue); }); @@ -828,7 +828,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'postCheckTaxRule', baseContext); const xmlValue = productXml.getAttributeValue(xmlCreate, 'id_tax_rules_group'); - const value = (await pricingTab.getValue(page, 'id_tax_rules_group')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'id_tax_rules_group')); expect(value).to.eq(xmlValue); }); @@ -836,7 +836,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'postCheckEcotax', baseContext); const xmlValue = productXml.getAttributeValue(xmlCreate, 'ecotax'); - const value = (await pricingTab.getValue(page, 'ecotax')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'ecotax')); expect(value).to.eq(xmlValue); }); @@ -844,7 +844,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'postCheckWholesalePrice', baseContext); const xmlValue = productXml.getAttributeValue(xmlCreate, 'wholesale_price'); - const value = (await pricingTab.getValue(page, 'wholesale_price')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'wholesale_price')); expect(value).to.eq(xmlValue); }); @@ -852,7 +852,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'postCheckUnitPrice', baseContext); const xmlValue = productXml.getAttributeValue(xmlCreate, 'unit_price'); - const value = (await pricingTab.getValue(page, 'unit_price')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'unit_price')); expect(value).to.eq(xmlValue); }); @@ -860,7 +860,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'postCheckUnity', baseContext); const xmlValue = productXml.getAttributeValue(xmlCreate, 'unity'); - const value = (await pricingTab.getValue(page, 'unity')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'unity')); expect(value).to.eq(xmlValue); }); @@ -868,7 +868,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'postCheckOnSale', baseContext); const xmlValue = productXml.getAttributeValue(xmlCreate, 'on_sale'); - const value = (await pricingTab.getValue(page, 'on_sale')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'on_sale')); expect(value).to.eq(xmlValue); }); }); @@ -1493,7 +1493,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'putCheckPrice', baseContext); const xmlValue = productXml.getAttributeValue(xmlUpdate, 'price'); - const value = (await pricingTab.getValue(page, 'price')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'price')); expect(value).to.eq(xmlValue); }); @@ -1501,7 +1501,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'putCheckTaxRule', baseContext); const xmlValue = productXml.getAttributeValue(xmlUpdate, 'id_tax_rules_group'); - const value = (await pricingTab.getValue(page, 'id_tax_rules_group')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'id_tax_rules_group')); expect(value).to.eq(xmlValue); }); @@ -1509,7 +1509,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'putCheckEcotax', baseContext); const xmlValue = productXml.getAttributeValue(xmlUpdate, 'ecotax'); - const value = (await pricingTab.getValue(page, 'ecotax')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'ecotax')); expect(value).to.eq(xmlValue); }); @@ -1517,7 +1517,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'putCheckWholesalePrice', baseContext); const xmlValue = productXml.getAttributeValue(xmlUpdate, 'wholesale_price'); - const value = (await pricingTab.getValue(page, 'wholesale_price')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'wholesale_price')); expect(value).to.eq(xmlValue); }); @@ -1525,7 +1525,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'putCheckUnitPrice', baseContext); const xmlValue = productXml.getAttributeValue(xmlUpdate, 'unit_price'); - const value = (await pricingTab.getValue(page, 'unit_price')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'unit_price')); expect(value).to.eq(xmlValue); }); @@ -1533,7 +1533,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'putCheckUnity', baseContext); const xmlValue = productXml.getAttributeValue(xmlUpdate, 'unity'); - const value = (await pricingTab.getValue(page, 'unity')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'unity')); expect(value).to.eq(xmlValue); }); @@ -1541,7 +1541,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'putCheckOnSale', baseContext); const xmlValue = productXml.getAttributeValue(xmlUpdate, 'on_sale'); - const value = (await pricingTab.getValue(page, 'on_sale')); + const value = (await boProductsCreateTabPricingPage.getValue(page, 'on_sale')); expect(value).to.eq(xmlValue); }); }); diff --git a/tests/UI/package-lock.json b/tests/UI/package-lock.json index 5c57d15360131..2d8de91ea2af3 100644 --- a/tests/UI/package-lock.json +++ b/tests/UI/package-lock.json @@ -432,7 +432,7 @@ }, "node_modules/@prestashop-core/ui-testing": { "version": "0.0.12", - "resolved": "git+ssh://git@github.com/PrestaShop/ui-testing-library.git#a07c65819e88eb3492e68fd36781f4f0884992e1", + "resolved": "git+ssh://git@github.com/PrestaShop/ui-testing-library.git#cae09500898853028043fd4c8356b10d1ec37b5c", "license": "MIT", "dependencies": { "@faker-js/faker": "^9.0.3", @@ -8419,7 +8419,7 @@ } }, "@prestashop-core/ui-testing": { - "version": "git+ssh://git@github.com/PrestaShop/ui-testing-library.git#a07c65819e88eb3492e68fd36781f4f0884992e1", + "version": "git+ssh://git@github.com/PrestaShop/ui-testing-library.git#cae09500898853028043fd4c8356b10d1ec37b5c", "from": "@prestashop-core/ui-testing@https://github.com/PrestaShop/ui-testing-library#main", "requires": { "@faker-js/faker": "^9.0.3", diff --git a/tests/UI/pages/BO/catalog/products/add/index.ts b/tests/UI/pages/BO/catalog/products/add/index.ts index 2893cd8e300b9..f0bd8ac9e2328 100644 --- a/tests/UI/pages/BO/catalog/products/add/index.ts +++ b/tests/UI/pages/BO/catalog/products/add/index.ts @@ -1,10 +1,10 @@ import BOBasePage from '@pages/BO/BObasePage'; -import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import packTab from '@pages/BO/catalog/products/add/packTab'; import { boProductsCreateTabDescriptionPage, boProductsCreateTabDetailsPage, + boProductsCreateTabPricingPage, boProductsCreateTabShippingPage, boProductsCreateTabStocksPage, boProductsCreateTabVirtualProductPage, @@ -373,7 +373,7 @@ class CreateProduct extends BOBasePage { await boProductsCreateTabShippingPage.setPackageDimension(page, productData); } - await pricingTab.setProductPricing(page, productData); + await boProductsCreateTabPricingPage.setProductPricing(page, productData); return this.saveProduct(page); } diff --git a/tests/UI/pages/BO/catalog/products/add/pricingTab.ts b/tests/UI/pages/BO/catalog/products/add/pricingTab.ts deleted file mode 100644 index 737f6b0008bab..0000000000000 --- a/tests/UI/pages/BO/catalog/products/add/pricingTab.ts +++ /dev/null @@ -1,461 +0,0 @@ -// Import pages -import BOBasePage from '@pages/BO/BObasePage'; - -import { - type Page, - - type FakerProduct, - type ProductSpecificPrice, -} from '@prestashop-core/ui-testing'; - -/** - * Pricing tab on new product V2 page, contains functions that can be used on the page - * @class - * @extends BOBasePage - */ -class PricingTab extends BOBasePage { - private readonly pricingTabLink: string; - - private readonly retailPriceInputTaxExcl: string; - - private readonly retailPriceInputTaxIncl: string; - - private readonly taxRuleID: string; - - private readonly taxRuleSelect: string; - - private readonly taxRuleSpan: string; - - private readonly taxRuleList: string; - - private readonly wholesalePriceInput: string; - - private readonly unitPriceInput: string; - - private readonly unityInput: string; - - private readonly onSaleCheckbox: string; - - private readonly productPricingSummarySection: string; - - private readonly priceTaxExcludedValue: string; - - private readonly priceTaxIncludedValue: string; - - private readonly unitPriceValue: string; - - private readonly marginValue: string; - - private readonly marginRateValue: string; - - private readonly wholeSalePriceValue: string; - - private readonly displayRetailPricePerUnit: (toEnable: number) => string; - - private readonly ecotaxInput: string; - - private readonly retailPricePerUnitInputTaxExcl: string; - - private readonly retailPricePerUnitInputTaxIncl: string; - - private readonly addSpecificPriceButton: string; - - private readonly specificPriceModal: string; - - private readonly startingAtInput: string; - - private readonly applyDiscountToInitialPrice: (value: boolean) => string; - - private readonly combinationSelectButton: string; - - private readonly combinationSelectResult: string; - - private readonly combinationToSelectButton: (idCombination: number) => string; - - private readonly applyDiscountOfInput: string; - - private readonly reductionType: string; - - private readonly saveAndPublishButton: string; - - private readonly closeSpecificPriceForm: string; - - private readonly pricingOnSaleCheckBox: string; - - private readonly specificPriceTable: string; - - private readonly catalogPriceRulesTable: string; - - private readonly deleteSpecificPriceModal: string; - - private readonly deleteSpecificPriceModalConfirmButton: string; - - private readonly showCatalogPriceRuleButton: string; - - private readonly manageCatalogPriceRuleLink: string; - - private readonly catalogPriceRuleRow: (row: number) => string; - - private readonly specificPriceTableRow: (row: number) => string; - - private readonly editSpecificPriceIcon: (row: number) => string; - - private readonly deleteSpecificPriceIcon: (row: number) => string; - - private readonly catalogPriceRuleRowColumn: (row: number, column: string) => string; - - /** - * @constructs - * Setting up texts and selectors to use on pricing tab - */ - constructor() { - super(); - - // Selectors in pricing tab - this.pricingTabLink = '#product_pricing-tab-nav'; - // Selectors in retail price section - this.retailPriceInputTaxExcl = '#product_pricing_retail_price_price_tax_excluded'; - this.retailPriceInputTaxIncl = '#product_pricing_retail_price_price_tax_included'; - this.taxRuleID = 'product_pricing_retail_price_tax_rules_group_id'; - this.taxRuleSelect = `#${this.taxRuleID}`; - this.taxRuleSpan = `#select2-${this.taxRuleID}-container`; - this.taxRuleList = `ul#select2-${this.taxRuleID}-results`; - // Selectors in cost price section - this.wholesalePriceInput = '#product_pricing_wholesale_price'; - // Selectors in retail price per unit section - this.displayRetailPricePerUnit = (toEnable: number) => `#product_pricing_disabling_switch_unit_price_${toEnable}`; - this.retailPricePerUnitInputTaxExcl = '#product_pricing_unit_price_price_tax_excluded'; - this.retailPricePerUnitInputTaxIncl = '#product_pricing_unit_price_price_tax_included'; - this.unitPriceInput = '#product_pricing_unit_price_price_tax_excluded'; - this.unityInput = '#product_pricing_unit_price_unity'; - // Selectors in summary section - this.productPricingSummarySection = '#product_pricing_summary'; - this.priceTaxExcludedValue = `${this.productPricingSummarySection} div.price-tax-excluded-value`; - this.priceTaxIncludedValue = `${this.productPricingSummarySection} div.price-tax-included-value`; - this.unitPriceValue = `${this.productPricingSummarySection} div.unit-price-value`; - this.marginValue = `${this.productPricingSummarySection} div.margin-value`; - this.marginRateValue = `${this.productPricingSummarySection} div.margin-rate-value`; - this.wholeSalePriceValue = `${this.productPricingSummarySection} div.wholesale-price-value`; - this.onSaleCheckbox = '#product_pricing_on_sale'; - this.ecotaxInput = '#product_pricing_retail_price_ecotax_tax_excluded'; - this.pricingOnSaleCheckBox = '#product_pricing div.form-group.checkbox-widget div.md-checkbox-inline'; - - // Selectors in specific Price section - this.addSpecificPriceButton = '#product_pricing_specific_prices_add_specific_price_btn'; - // Specific Price modal - this.specificPriceModal = '#modal-specific-price-form'; - this.closeSpecificPriceForm = `${this.specificPriceModal} div.modal-header button.close`; - // Combination Modal Bloc - this.combinationSelectButton = '#select2-specific_price_combination_id-container'; - this.combinationSelectResult = '#select2-specific_price_combination_id-results'; - this.combinationToSelectButton = (idCombination: number) => `li.select2-results__option:nth-child(${idCombination})`; - // Minimum number of units purchased Bloc - this.startingAtInput = '#specific_price_from_quantity'; - // Impact on price Bloc - this.applyDiscountToInitialPrice = (value: boolean) => '#specific_price_impact_disabling_switch_reduction_' - + `${value ? '1' : '0'}`; - this.applyDiscountOfInput = '#specific_price_impact_reduction_value'; - this.reductionType = '#specific_price_impact_reduction_type'; - // Footer - this.saveAndPublishButton = `${this.specificPriceModal} div.modal-footer button.btn-confirm-submit`; - - // Selectors is specific price table - this.specificPriceTable = '#specific-prices-list-table'; - this.specificPriceTableRow = (row: number) => `${this.specificPriceTable} tr:nth-child(${row})`; - this.editSpecificPriceIcon = (row: number) => `${this.specificPriceTableRow(row)} td button.js-edit-specific-price-btn`; - this.deleteSpecificPriceIcon = (row: number) => `${this.specificPriceTableRow(row)} td button.js-delete-specific-price-btn`; - this.deleteSpecificPriceModal = '#modal-confirm-delete-combination'; - this.deleteSpecificPriceModalConfirmButton = `${this.deleteSpecificPriceModal} button.btn-confirm-submit`; - - // Selectors in catalog price rules section - this.showCatalogPriceRuleButton = '#product_pricing_show_catalog_price_rules'; - this.manageCatalogPriceRuleLink = '#product_pricing a[href*=\'AdminSpecificPriceRule\']'; - this.catalogPriceRulesTable = '#catalog-price-rules-list-table'; - this.catalogPriceRuleRow = (row: number) => `${this.catalogPriceRulesTable} tbody tr:nth-child(${row})`; - this.catalogPriceRuleRowColumn = (row: number, column: string) => `${this.catalogPriceRuleRow(row)} td.${column}`; - } - - /* - Methods - */ - - /** - * Set product pricing - * @param page {Page} Browser tab - * @param productData {FakerProduct} Data to set in pricing form - * @returns {Promise} - */ - async setProductPricing(page: Page, productData: FakerProduct): Promise { - await this.waitForSelectorAndClick(page, this.pricingTabLink); - // Select tax rule by ID - await Promise.all([ - this.waitForSelectorAndClick(page, this.taxRuleSpan), - this.waitForVisibleSelector(page, this.taxRuleList), - ]); - await page.locator(`li:has-text('${productData.taxRule}')`).click(); - // We define the price after the tax because the tax impact the priceTaxIncluded - await this.setRetailPrice(page, false, productData.price); - if (productData.onSale) { - await page.locator(this.pricingOnSaleCheckBox).click(); - } - } - - /** - * Set tax rule - * @param page {Page} Browser tab - * @param taxRule {string} Tax rule to select - * @returns {Promise} - */ - async setTaxRule(page: Page, taxRule: string): Promise { - await Promise.all([ - this.waitForSelectorAndClick(page, this.taxRuleSpan), - this.waitForVisibleSelector(page, this.taxRuleList), - ]); - await page.locator(`li:has-text('${taxRule}')`).click(); - } - - /** - * Set retail price - * @param page {Page} Browser tab - * @param isTaxExcluded {boolean} is Tax Excluded - * @param price {number} Retail price - * @returns {Promise} - */ - async setRetailPrice(page: Page, isTaxExcluded: boolean, price: number): Promise { - await this.setValue( - page, - isTaxExcluded ? this.retailPriceInputTaxExcl : this.retailPriceInputTaxIncl, - price, - ); - } - - /** - * Set cost price - * @param page {Page} Browser tab - * @param costPrice {number} - * @returns {Promise} - */ - async setCostPrice(page: Page, costPrice: number): Promise { - await this.setValue(page, this.wholesalePriceInput, costPrice); - } - - /** - * Set display retail price per unit - * @param page {Page} Browser tab - * @param toEnable {boolean} True if we need to check display retail price per unit - * @returns {Promise} - */ - async setDisplayRetailPricePerUnit(page: Page, toEnable: true): Promise { - await this.setChecked(page, this.displayRetailPricePerUnit(toEnable ? 1 : 0)); - } - - /** - * Set retail price per unit - * @param page {Page} Browser tab - * @param isTaxExcluded {boolean} is Tax Excluded - * @param price {number} Retail price - * @param unit {string} Unit - * @returns {Promise} - */ - async setRetailPricePerUnit(page: Page, isTaxExcluded: boolean, price: number, unit: string): Promise { - await this.setValue( - page, - isTaxExcluded ? this.retailPricePerUnitInputTaxExcl : this.retailPricePerUnitInputTaxIncl, - price, - ); - await this.setValue(page, this.unityInput, unit); - } - - /** - * Get summary - * @param page {Page} Browser tab - * @returns {Promise} - */ - async getSummary(page: Page) { - await this.waitForSelectorAndClick(page, this.pricingTabLink); - return { - priceTaxExcludedValue: await this.getTextContent(page, this.priceTaxExcludedValue), - priceTaxIncludedValue: await this.getTextContent(page, this.priceTaxIncludedValue), - marginValue: await this.getTextContent(page, this.marginValue), - marginRateValue: await this.getTextContent(page, this.marginRateValue), - WholesalePriceValue: await this.getTextContent(page, this.wholeSalePriceValue), - }; - } - - /** - * Get unit price - * @param page {Page} Browser tab - * @returns {Promise} - */ - async getUnitPriceValue(page: Page): Promise { - return this.getTextContent(page, this.unitPriceValue); - } - - /** - * Set display on sale flag - * @param page {Page} Browser tab - * @returns {Promise} - */ - async setDisplayOnSaleFlag(page: Page): Promise { - await this.waitForSelectorAndClick(page, this.pricingOnSaleCheckBox); - } - - /** - * Click on add specific price button - * @param page {Page} Browser tab - * @returns {Promise} - */ - async clickOnAddSpecificPriceButton(page: Page): Promise { - await this.waitForSelectorAndClick(page, this.pricingTabLink); - - await Promise.all([ - page.locator(this.addSpecificPriceButton).click(), - this.waitForVisibleSelector(page, `${this.specificPriceModal}.show`), - ]); - } - - /** - * Click on edit specific price icon - * @param page {Page} Browser tab - * @param row {number} Row to edit - * @returns {Promise} - */ - async clickOnEditSpecificPriceIcon(page: Page, row: number): Promise { - await this.waitForSelectorAndClick(page, this.pricingTabLink); - - await Promise.all([ - page.locator(this.editSpecificPriceIcon(row)).click(), - this.waitForVisibleSelector(page, `${this.specificPriceModal}.show`), - ]); - } - - /** - * Product specific price - * @param page {Page} Browser tab - * @param specificPriceData {ProductSpecificPrice} Data to set on specific price form - * @return {Promise} - */ - async setSpecificPrice(page: Page, specificPriceData: ProductSpecificPrice): Promise { - const addSpecificPriceFrame = page.frame({name: 'modal-specific-price-form-iframe'}); - - await this.setValue(addSpecificPriceFrame!, this.startingAtInput, specificPriceData.startingAt); - await this.setChecked(addSpecificPriceFrame!, this.applyDiscountToInitialPrice(true)); - - // Choose combinations if exist - if (specificPriceData.attributes) { - await addSpecificPriceFrame!.locator(this.combinationSelectButton).click(); - await this.waitForVisibleSelector(addSpecificPriceFrame!, this.combinationSelectResult); - await this.waitForSelectorAndClick(addSpecificPriceFrame!, this.combinationToSelectButton(specificPriceData.attributes)); - } - - await this.setValue(addSpecificPriceFrame!, this.applyDiscountOfInput, specificPriceData.discount); - await this.selectByVisibleText(addSpecificPriceFrame!, this.reductionType, specificPriceData.reductionType); - - // Save and get growl message - await page.locator(this.saveAndPublishButton).click(); - const successMessage = await this.getAlertSuccessBlockParagraphContent(addSpecificPriceFrame!); - await page.locator(this.closeSpecificPriceForm).click(); - - return successMessage; - } - - /** - * Delete specific price - * @param page {Page} Browser tab - * @param row {number} Row to edit - * @return {Promise} - */ - async deleteSpecificPrice(page: Page, row: number): Promise { - await page.locator(this.deleteSpecificPriceIcon(row)).click(); - await page.locator(this.deleteSpecificPriceModalConfirmButton).click(); - - return this.getGrowlMessageContent(page); - } - - /** - * Click on show catalog price rule button - * @param page {Page} Browser tab - * @return {Promise} - */ - async clickOnShowCatalogPriceRuleButton(page: Page): Promise { - await page.locator(this.showCatalogPriceRuleButton).click(); - } - - /** - * Click on hide catalog price rule button - * @param page {Page} Browser tab - * @return {Promise} - */ - async clickOnHideCatalogPriceRulesButton(page: Page): Promise { - await page.locator(this.showCatalogPriceRuleButton).click(); - - return this.elementVisible(page, this.catalogPriceRulesTable, 1000); - } - - /** - * Click on manage catalog price rule link - * @param page {Page} Browser tab - * @return {Promise} - */ - async clickOnManageCatalogPriceRuleLink(page: Page): Promise { - return this.openLinkWithTargetBlank(page, this.manageCatalogPriceRuleLink, 'body'); - } - - /** - * Get catalog price rule data - * @param page {Page} Browser tab - * @param row {number} Row of catalog price rule - */ - async getCatalogPriceRuleData(page: Page, row: number) { - return { - id: await this.getTextContent(page, this.catalogPriceRuleRowColumn(row, 'catalog-price-rule-id')), - name: await this.getTextContent(page, this.catalogPriceRuleRowColumn(row, 'name')), - currency: await this.getTextContent(page, this.catalogPriceRuleRowColumn(row, 'currency')), - country: await this.getTextContent(page, this.catalogPriceRuleRowColumn(row, 'country')), - group: await this.getTextContent(page, this.catalogPriceRuleRowColumn(row, 'group')), - store: await this.getTextContent(page, this.catalogPriceRuleRowColumn(row, 'shop')), - discount: await this.getTextContent(page, this.catalogPriceRuleRowColumn(row, 'impact')), - fromQuantity: await this.getNumberFromText(page, this.catalogPriceRuleRowColumn(row, 'from-qty')), - }; - } - - /** - * Returns the value of a form element - * @param page {Page} - * @param inputName {string} - */ - async getValue(page: Page, inputName: string): Promise { - switch (inputName) { - case 'ecotax': - return this.getAttributeContent(page, this.ecotaxInput, 'value'); - case 'id_tax_rules_group': - return page.locator(this.taxRuleSelect).evaluate((node: HTMLSelectElement) => node.value); - case 'on_sale': - return (await this.isChecked(page, this.onSaleCheckbox)) ? '1' : '0'; - case 'price': - return this.getAttributeContent(page, this.retailPriceInputTaxExcl, 'value'); - case 'unit_price': - return this.getAttributeContent(page, this.unitPriceInput, 'value'); - case 'unity': - return this.getAttributeContent(page, this.unityInput, 'value'); - case 'wholesale_price': - return this.getAttributeContent(page, this.wholesalePriceInput, 'value'); - default: - throw new Error(`Input ${inputName} was not found`); - } - } - - /** - * Set ecoTax value and save - * @param page {Page} Browser tab - * @param ecoTax {string} Eco tax value to set on eco tax input - * @returns {Promise} - */ - async addEcoTax(page: Page, ecoTax: number): Promise { - await this.waitForSelectorAndClick(page, this.pricingTabLink); - - await this.setValue(page, this.ecotaxInput, ecoTax); - } -} - -export default new PricingTab();