From b706d8378c29007668c2c13c8c8182c720d2a844 Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Tue, 26 Sep 2023 15:11:33 +0200 Subject: [PATCH 1/5] Add new test to check pricing tab --- .../productV2/functional/17_pricingTab.ts | 532 ++++++++++++++++++ tests/UI/data/faker/product.ts | 1 + tests/UI/data/types/product.d.ts | 1 + .../BO/catalog/productsV2/add/pricingTab.ts | 280 +++++++++ tests/UI/pages/FO/product/index.ts | 21 + 5 files changed, 835 insertions(+) create mode 100644 tests/UI/campaigns/productV2/functional/17_pricingTab.ts diff --git a/tests/UI/campaigns/productV2/functional/17_pricingTab.ts b/tests/UI/campaigns/productV2/functional/17_pricingTab.ts new file mode 100644 index 0000000000000..17b29de4227df --- /dev/null +++ b/tests/UI/campaigns/productV2/functional/17_pricingTab.ts @@ -0,0 +1,532 @@ +// Import utils +import helper from '@utils/helpers'; +import testContext from '@utils/testContext'; + +// Import common tests +import loginCommon from '@commonTests/BO/loginBO'; + +// Import BO pages +import dashboardPage from '@pages/BO/dashboard'; +import createProductPage from '@pages/BO/catalog/productsV2/add'; +import pricingTab from '@pages/BO/catalog/productsV2/add/pricingTab'; +import productsPage from '@pages/BO/catalog/productsV2'; +import createCatalogPriceRulePage from '@pages/BO/catalog/discounts/catalogPriceRules/add'; + +// Import FO pages +import foProductPage from '@pages/FO/product'; +import catalogPriceRulesPage from '@pages/BO/catalog/discounts/catalogPriceRules'; + +// Import data +import ProductData from '@data/faker/product'; +import CatalogPriceRuleData from '@data/faker/catalogPriceRule'; + +import type {BrowserContext, Page} from 'playwright'; +import {expect} from 'chai'; +import cartRulesPage from "@pages/BO/catalog/discounts"; + +const baseContext: string = 'productV2_functional_pricingTab'; + +describe('BO - Catalog - Products : Pricing tab', async () => { + let browserContext: BrowserContext; + let page: Page; + + // Data to create standard product + const newProductData: ProductData = new ProductData({ + type: 'standard', + quantity: 10, + minimumQuantity: 1, + price: 100, + taxRule: 'No tax', + status: true, + }); + const specificPriceData: ProductData = new ProductData({ + specificPrice: { + attributes: null, + discount: 20, + startingAt: 1, + reductionType: '€', + isApplyDiscount: true, + }, + }); + const editSpecificPriceData: ProductData = new ProductData({ + specificPrice: { + attributes: null, + discount: 30, + startingAt: 1, + reductionType: '€', + isApplyDiscount: true, + }, + }); + + const newCatalogPriceRuleData: CatalogPriceRuleData = new CatalogPriceRuleData({ + currency: 'All currencies', + country: 'All countries', + group: 'All groups', + reductionType: 'Amount', + reductionTax: 'Tax included', + fromQuantity: 3, + reduction: 20, + }); + + // before and after functions + before(async function () { + browserContext = await helper.createBrowserContext(this.browser); + page = await helper.newTab(browserContext); + }); + + after(async () => { + await helper.closeBrowserContext(browserContext); + }); + + // 1 - Create product + describe('Create product', async () => { + it('should login in BO', async function () { + await loginCommon.loginBO(this, page); + }); + + it('should go to \'Catalog > Products\' page', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goToProductsPage', baseContext); + + await dashboardPage.goToSubMenu( + page, + dashboardPage.catalogParentLink, + dashboardPage.productsLink, + ); + + await productsPage.closeSfToolBar(page); + + const pageTitle = await productsPage.getPageTitle(page); + await expect(pageTitle).to.contains(productsPage.pageTitle); + }); + + it('should click on \'New product\' button and check new product modal', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'clickOnNewProductButton', baseContext); + + const isModalVisible = await productsPage.clickOnNewProductButton(page); + await expect(isModalVisible).to.be.true; + }); + + it('should choose \'Standard product\' and go to new product page', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'chooseStandardProduct', baseContext); + + await productsPage.selectProductType(page, newProductData.type); + await productsPage.clickOnAddNewProduct(page); + + const pageTitle = await createProductPage.getPageTitle(page); + await expect(pageTitle).to.contains(createProductPage.pageTitle); + }); + + it('should create standard product', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'createStandardProduct', baseContext); + + const createProductMessage = await createProductPage.setProduct(page, newProductData); + await expect(createProductMessage).to.equal(createProductPage.successfulUpdateMessage); + }); + }); + + // 2 - Check options in pricing tab + describe('Check all options in Details tab', async () => { + it('should check summary block', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkSummaryBlock', baseContext); + + const result = await pricingTab.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'), + ]); + }); + + it('should preview product', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'previewProduct', baseContext); + + page = await createProductPage.previewProduct(page); + + await foProductPage.changeLanguage(page, 'en'); + + const pageTitle = await foProductPage.getPageTitle(page); + expect(pageTitle).to.contains(newProductData.name); + }); + + it('should check the product price', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkProductPrice', baseContext); + + const productPrice = await foProductPage.getProductPrice(page); + expect(productPrice).to.eq('€100.00'); + }); + + it('should go back to BO', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goBackToBO', baseContext); + + page = await foProductPage.closePage(browserContext, page, 0); + + const pageTitle = await createProductPage.getPageTitle(page); + expect(pageTitle).to.contains(createProductPage.pageTitle); + }); + + 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%)'); + + const message = await createProductPage.saveProduct(page); + expect(message).to.eq(createProductPage.successfulUpdateMessage); + }); + + it('should check summary block', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkSummaryBlock2', baseContext); + + const result = await pricingTab.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'), + ]); + }); + + it('should preview product', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'previewProduct2', baseContext); + + page = await createProductPage.previewProduct(page); + + await foProductPage.changeLanguage(page, 'en'); + + const pageTitle = await foProductPage.getPageTitle(page); + expect(pageTitle).to.contains(newProductData.name); + }); + + it('should check the product price', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkProductPrice2', baseContext); + + const productPrice = await foProductPage.getProductPrice(page); + expect(productPrice).to.eq('€120.00'); + }); + + it('should go back to BO', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goBackToBO2', baseContext); + + page = await foProductPage.closePage(browserContext, page, 0); + + const pageTitle = await createProductPage.getPageTitle(page); + expect(pageTitle).to.contains(createProductPage.pageTitle); + }); + + it('should add a cost price', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'addCostPrice', baseContext); + + await pricingTab.setCostPrice(page, 35); + + const message = await createProductPage.saveProduct(page); + expect(message).to.eq(createProductPage.successfulUpdateMessage); + }); + + it('should check summary block', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkSummaryBlock3', baseContext); + + const result = await pricingTab.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'), + ]); + }); + + 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'); + + const message = await createProductPage.saveProduct(page); + expect(message).to.eq(createProductPage.successfulUpdateMessage); + }); + + it('should check summary block', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkSummaryBlock4', baseContext); + + const result = await pricingTab.getSummary(page); + 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'), + ]); + + const unitPrice = await pricingTab.getUnitPriceValue(page); + expect(unitPrice).to.eq('€10.00 per unit'); + }); + + it('should preview product', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'previewProduct3', baseContext); + + page = await createProductPage.previewProduct(page); + + await foProductPage.changeLanguage(page, 'en'); + + const pageTitle = await foProductPage.getPageTitle(page); + expect(pageTitle).to.contains(newProductData.name); + }); + + it('should check the price per unit', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkUnitPrice', baseContext); + + const flagText = await foProductPage.getProductUnitPrice(page); + expect(flagText).to.eq('€12.00 per unit'); + }); + + it('should go back to BO', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goBackToBO3', baseContext); + + page = await foProductPage.closePage(browserContext, page, 0); + + const pageTitle = await createProductPage.getPageTitle(page); + expect(pageTitle).to.contains(createProductPage.pageTitle); + }); + + it('should check Display On sale flag', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkDisplayOnSaleFlag', baseContext); + + await pricingTab.setDisplayOnSaleFlag(page); + + const message = await createProductPage.saveProduct(page); + expect(message).to.eq(createProductPage.successfulUpdateMessage); + }); + + it('should preview product', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'previewProduct4', baseContext); + + page = await createProductPage.previewProduct(page); + + await foProductPage.changeLanguage(page, 'en'); + + const pageTitle = await foProductPage.getPageTitle(page); + expect(pageTitle).to.contains(newProductData.name); + }); + + it('should check the on sale flag', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkOnSaleFlag', baseContext); + + const flagText = await foProductPage.getProductTag(page); + expect(flagText).to.contains('On sale!'); + }); + + it('should go back to BO', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goBackToBO4', baseContext); + + page = await foProductPage.closePage(browserContext, page, 0); + + const pageTitle = await createProductPage.getPageTitle(page); + expect(pageTitle).to.contains(createProductPage.pageTitle); + }); + + it('should add a specific price', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'addSpecificPrice', baseContext); + + await pricingTab.clickOnAddSpecificPriceButton(page); + + const message = await pricingTab.setSpecificPrice(page, specificPriceData.specificPrice); + await expect(message).to.equal(createProductPage.successfulCreationMessage); + }); + + it('should preview product', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'previewProduct5', baseContext); + + page = await createProductPage.previewProduct(page); + + await foProductPage.changeLanguage(page, 'en'); + + const pageTitle = await foProductPage.getPageTitle(page); + expect(pageTitle).to.contains(newProductData.name); + }); + + it('should check the product price', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkSpecificPrice', baseContext); + + const productPrice = await foProductPage.getProductPrice(page); + expect(productPrice).to.eq('€100.00'); + }); + + it('should go back to BO', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goBackToBO5', baseContext); + + page = await foProductPage.closePage(browserContext, page, 0); + + const pageTitle = await createProductPage.getPageTitle(page); + expect(pageTitle).to.contains(createProductPage.pageTitle); + }); + + it('should edit specific price', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'editSpecificPrice', baseContext); + + await pricingTab.clickOnEditSpecificPriceIcon(page, 1); + + const message = await pricingTab.setSpecificPrice(page, editSpecificPriceData.specificPrice); + await expect(message).to.equal('Update successful'); + }); + + it('should preview product', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'previewProduct6', baseContext); + + page = await createProductPage.previewProduct(page); + + await foProductPage.changeLanguage(page, 'en'); + + const pageTitle = await foProductPage.getPageTitle(page); + expect(pageTitle).to.contains(newProductData.name); + }); + + it('should check the product price', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkUpdatedSpecificPrice', baseContext); + + const productPrice = await foProductPage.getProductPrice(page); + expect(productPrice).to.eq('€90.00'); + }); + + it('should go back to BO', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goBackToBO6', baseContext); + + page = await foProductPage.closePage(browserContext, page, 0); + + const pageTitle = await createProductPage.getPageTitle(page); + expect(pageTitle).to.contains(createProductPage.pageTitle); + }); + + 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); + }); + + it('should preview product', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'previewProduct7', baseContext); + + page = await createProductPage.previewProduct(page); + + await foProductPage.changeLanguage(page, 'en'); + + const pageTitle = await foProductPage.getPageTitle(page); + expect(pageTitle).to.contains(newProductData.name); + }); + + it('should check the product price', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkDeletedSpecificPrice', baseContext); + + const productPrice = await foProductPage.getProductPrice(page); + expect(productPrice).to.eq('€120.00'); + }); + + it('should go back to BO', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goBackToBO7', baseContext); + + page = await foProductPage.closePage(browserContext, page, 0); + + const pageTitle = await createProductPage.getPageTitle(page); + expect(pageTitle).to.contains(createProductPage.pageTitle); + }); + + 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); + + const pageTitle = await catalogPriceRulesPage.getPageTitle(page); + expect(pageTitle).to.contains(catalogPriceRulesPage.pageTitle); + }); + + it('should create a new catalog price rule', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'createCatalogPriceRule', baseContext); + + await catalogPriceRulesPage.goToAddNewCatalogPriceRulePage(page); + + const validationMessage = await createCatalogPriceRulePage.setCatalogPriceRule(page, newCatalogPriceRuleData); + await expect(validationMessage).to.contains(catalogPriceRulesPage.successfulCreationMessage); + }); + + it('should close the page', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'closePage', baseContext); + + page = await catalogPriceRulesPage.closePage(browserContext, page, 0); + + await createProductPage.reloadPage(page); + + const pageTitle = await createProductPage.getPageTitle(page); + expect(pageTitle).to.contains(createProductPage.pageTitle); + }); + + 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); + + const result = await pricingTab.getCatalogPriceRuleData(page, 1); + Promise.all([ + expect(result.name).to.eq(newCatalogPriceRuleData.name), + expect(result.currency).to.eq(newCatalogPriceRuleData.currency), + expect(result.country).to.eq(newCatalogPriceRuleData.country), + expect(result.group).to.eq(newCatalogPriceRuleData.group), + expect(result.store).to.eq(global.INSTALL.SHOP_NAME), + expect(result.discount).to.eq('-€20.00 (tax incl.)'), + expect(result.fromQuantity).to.eq(newCatalogPriceRuleData.fromQuantity), + ]); + }); + + it('should click on hide catalog price rules button', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'clickOnHideCatalogPriceRuleButton', baseContext); + + const isCatalogPriceRulesTableVisible = await pricingTab.clickOnHideCatalogPriceRulesButton(page); + expect(isCatalogPriceRulesTableVisible).to.eq(false); + }); + }); + + // POST-TEST: Delete product + describe('POST-TEST: Delete product', async () => { + it('should delete product', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'deleteProduct', baseContext); + + const createProductMessage = await createProductPage.deleteProduct(page); + expect(createProductMessage).to.equal(productsPage.successfulDeleteMessage); + }); + }); + + // POST-TEST : Delete catalog price rules + describe('POST-TEST : Delete catalog price rule', async () => { + it('should go to \'Catalog > Discounts\' page', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goToDiscountsPage', baseContext); + + await dashboardPage.goToSubMenu( + page, + dashboardPage.catalogParentLink, + dashboardPage.discountsLink, + ); + + const pageTitle = await cartRulesPage.getPageTitle(page); + expect(pageTitle).to.contains(cartRulesPage.pageTitle); + }); + + it('should go to \'Catalog Price Rules\' tab', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goToCatalogPriceRulesTab', baseContext); + + await cartRulesPage.goToCatalogPriceRulesTab(page); + + const pageTitle = await catalogPriceRulesPage.getPageTitle(page); + expect(pageTitle).to.contains(catalogPriceRulesPage.pageTitle); + }); + + it('should delete catalog price rule', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'deleteCatalogPriceRule', baseContext); + + const deleteTextResult = await catalogPriceRulesPage.deleteCatalogPriceRule(page, newCatalogPriceRuleData.name); + expect(deleteTextResult).to.contains(catalogPriceRulesPage.successfulDeleteMessage); + }); + }); +}); diff --git a/tests/UI/data/faker/product.ts b/tests/UI/data/faker/product.ts index f6afc31283f92..9726cc55162cf 100644 --- a/tests/UI/data/faker/product.ts +++ b/tests/UI/data/faker/product.ts @@ -263,6 +263,7 @@ export default class ProductData { discount: faker.number.int({min: 10, max: 100}), startingAt: faker.number.int({min: 2, max: 5}), reductionType: '', + isApplyDiscount: true, }; /** @type {number} Minimum quantity to buy for the product */ diff --git a/tests/UI/data/types/product.d.ts b/tests/UI/data/types/product.d.ts index 6815b1e09176d..25044f13b4519 100644 --- a/tests/UI/data/types/product.d.ts +++ b/tests/UI/data/types/product.d.ts @@ -201,6 +201,7 @@ type ProductSpecificPrice = { discount: number startingAt: number reductionType: string + isApplyDiscount: boolean }; type ProductStockMovement = { diff --git a/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts b/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts index 79471fa538dd4..24f912ed8e5e6 100644 --- a/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts +++ b/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts @@ -4,6 +4,8 @@ import BOBasePage from '@pages/BO/BObasePage'; // Import data import ProductData from '@data/faker/product'; +import type {ProductSpecificPrice} from '@data/types/product'; + import type {Page} from 'playwright'; /** @@ -34,8 +36,58 @@ class PricingTab extends BOBasePage { 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: string) => string; + + private readonly applyDiscountOfInput: string; + + private readonly reductionType: string; + + private readonly saveAndPublishButton: string; + + private readonly closeSpecificPriceForm: string; + + private readonly pricingOnSaleCheckBox: string; + + private readonly catalogPriceRulesTable: string; + + private readonly catalogPriceRuleRow: (row: number) => string; + + private readonly catalogPriceRuleRowColumn: (row: number, column: string) => string; + /** * @constructs * Setting up texts and selectors to use on pricing tab @@ -45,17 +97,57 @@ class PricingTab extends BOBasePage { // 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: string) => `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 in catalog price rules table + 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}`; + } /* @@ -79,6 +171,20 @@ class PricingTab extends BOBasePage { await page.locator(`li:has-text('${productData.taxRule}')`).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 @@ -94,6 +200,180 @@ class PricingTab extends BOBasePage { ); } + /** + * 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(`#specific-prices-list-table tr:nth-child(${row}) td button.js-edit-specific-price-btn`).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 = await page.frame({name: 'modal-specific-price-form-iframe'}); + + await this.setValue(addSpecificPriceFrame!, this.startingAtInput, specificPriceData.startingAt); + await this.setChecked(addSpecificPriceFrame!, this.applyDiscountToInitialPrice(specificPriceData.isApplyDiscount)); + + // 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(`#specific-prices-list-table tr:nth-child(${row}) td button.js-delete-specific-price-btn`).click(); + await page.locator('#modal-confirm-delete-combination button.btn-confirm-submit').click(); + + return this.getGrowlMessageContent(page); + } + + /** + * + * @param page + */ + async clickOnShowCatalogPriceRuleButton(page: Page): Promise { + await page.locator('#product_pricing_show_catalog_price_rules').click(); + } + + async clickOnHideCatalogPriceRulesButton(page: Page): Promise { + await page.locator('#product_pricing_show_catalog_price_rules').click(); + + return this.elementVisible(page, '#product_pricing_catalog_price_rules', 1000); + } + + async clickOnManageCatalogPriceRuleLink(page: Page): Promise { + return this.openLinkWithTargetBlank(page, '#product_pricing a[href*=\'AdminSpecificPriceRule\']', 'body'); + } + + 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} diff --git a/tests/UI/pages/FO/product/index.ts b/tests/UI/pages/FO/product/index.ts index 02a4bf26315ea..6d936f2925d99 100644 --- a/tests/UI/pages/FO/product/index.ts +++ b/tests/UI/pages/FO/product/index.ts @@ -95,6 +95,8 @@ class Product extends FOBasePage { private readonly unitDiscountValue: string; + private readonly productUnitPrice: string; + private readonly commentCount: string; private readonly emptyReviewBlock: string; @@ -183,6 +185,7 @@ class Product extends FOBasePage { // Product prices block this.productPricesBlock = 'div.product-prices'; + this.productUnitPrice = `${this.productPricesBlock} p.product-unit-price`; this.discountAmountSpan = `${this.productPricesBlock} .discount.discount-amount`; this.discountPercentageSpan = `${this.productPricesBlock} .discount.discount-percentage`; this.regularPrice = `${this.productPricesBlock} .regular-price`; @@ -256,6 +259,15 @@ class Product extends FOBasePage { return this.elementVisible(page, this.productFlag); } + /** + * Get product price + * @param page {Page} Browser tab + * @returns {Promise} + */ + async getProductPrice(page: Page): Promise { + return this.getTextContent(page, this.productPrice); + } + /** * Get Product information (Product name, price, short description, description) * @param page {Page} Browser tab @@ -369,6 +381,15 @@ class Product extends FOBasePage { }; } + /** + * Get product unit price + * @param page {Page} Browser tab + * @returns {Promise} + */ + async getProductUnitPrice(page: Page): Promise { + return this.getTextContent(page, this.productUnitPrice); + } + /** * Get discount column title * @param page {Page} Browser tab From 0dca1280d906103de4be36f56210e9153d9d0025 Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Tue, 26 Sep 2023 15:31:30 +0200 Subject: [PATCH 2/5] Add new test to check pricing tab - part 2 --- .../productV2/functional/17_pricingTab.ts | 6 +- .../BO/catalog/productsV2/add/pricingTab.ts | 63 +++++++++++++++---- 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/tests/UI/campaigns/productV2/functional/17_pricingTab.ts b/tests/UI/campaigns/productV2/functional/17_pricingTab.ts index 17b29de4227df..d8086498a6f30 100644 --- a/tests/UI/campaigns/productV2/functional/17_pricingTab.ts +++ b/tests/UI/campaigns/productV2/functional/17_pricingTab.ts @@ -11,6 +11,7 @@ import createProductPage from '@pages/BO/catalog/productsV2/add'; import pricingTab from '@pages/BO/catalog/productsV2/add/pricingTab'; import productsPage from '@pages/BO/catalog/productsV2'; import createCatalogPriceRulePage from '@pages/BO/catalog/discounts/catalogPriceRules/add'; +import cartRulesPage from '@pages/BO/catalog/discounts'; // Import FO pages import foProductPage from '@pages/FO/product'; @@ -22,7 +23,6 @@ import CatalogPriceRuleData from '@data/faker/catalogPriceRule'; import type {BrowserContext, Page} from 'playwright'; import {expect} from 'chai'; -import cartRulesPage from "@pages/BO/catalog/discounts"; const baseContext: string = 'productV2_functional_pricingTab'; @@ -39,6 +39,7 @@ describe('BO - Catalog - Products : Pricing tab', async () => { taxRule: 'No tax', status: true, }); + // Data to create specific price const specificPriceData: ProductData = new ProductData({ specificPrice: { attributes: null, @@ -48,6 +49,7 @@ describe('BO - Catalog - Products : Pricing tab', async () => { isApplyDiscount: true, }, }); + // Data to edit specific price const editSpecificPriceData: ProductData = new ProductData({ specificPrice: { attributes: null, @@ -57,7 +59,7 @@ describe('BO - Catalog - Products : Pricing tab', async () => { isApplyDiscount: true, }, }); - + // Data to create new catalog price rule const newCatalogPriceRuleData: CatalogPriceRuleData = new CatalogPriceRuleData({ currency: 'All currencies', country: 'All countries', diff --git a/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts b/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts index 24f912ed8e5e6..81897f9288dba 100644 --- a/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts +++ b/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts @@ -82,10 +82,26 @@ class PricingTab extends BOBasePage { 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; /** @@ -143,11 +159,20 @@ class PricingTab extends BOBasePage { // Footer this.saveAndPublishButton = `${this.specificPriceModal} div.modal-footer button.btn-confirm-submit`; - // Selectors in catalog price rules table + // 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}`; - } /* @@ -295,7 +320,7 @@ class PricingTab extends BOBasePage { await this.waitForSelectorAndClick(page, this.pricingTabLink); await Promise.all([ - page.locator(`#specific-prices-list-table tr:nth-child(${row}) td button.js-edit-specific-price-btn`).click(), + page.locator(this.editSpecificPriceIcon(row)).click(), this.waitForVisibleSelector(page, `${this.specificPriceModal}.show`), ]); } @@ -337,30 +362,46 @@ class PricingTab extends BOBasePage { * @return {Promise} */ async deleteSpecificPrice(page: Page, row: number): Promise { - await page.locator(`#specific-prices-list-table tr:nth-child(${row}) td button.js-delete-specific-price-btn`).click(); - await page.locator('#modal-confirm-delete-combination button.btn-confirm-submit').click(); + await page.locator(this.deleteSpecificPriceIcon(row)).click(); + await page.locator(this.deleteSpecificPriceModalConfirmButton).click(); return this.getGrowlMessageContent(page); } /** - * - * @param page + * Click on show catalog price rule button + * @param page {Page} Browser tab + * @return {Promise} */ async clickOnShowCatalogPriceRuleButton(page: Page): Promise { - await page.locator('#product_pricing_show_catalog_price_rules').click(); + 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('#product_pricing_show_catalog_price_rules').click(); + await page.locator(this.showCatalogPriceRuleButton).click(); - return this.elementVisible(page, '#product_pricing_catalog_price_rules', 1000); + 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, '#product_pricing a[href*=\'AdminSpecificPriceRule\']', 'body'); + 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')), From 1b61ef03a951e4ab03befd0879cf729eb6e684b4 Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Tue, 26 Sep 2023 15:40:08 +0200 Subject: [PATCH 3/5] Add some fixes --- .../productV2/functional/17_pricingTab.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/UI/campaigns/productV2/functional/17_pricingTab.ts b/tests/UI/campaigns/productV2/functional/17_pricingTab.ts index d8086498a6f30..a7beec8eb3092 100644 --- a/tests/UI/campaigns/productV2/functional/17_pricingTab.ts +++ b/tests/UI/campaigns/productV2/functional/17_pricingTab.ts @@ -98,14 +98,14 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await productsPage.closeSfToolBar(page); const pageTitle = await productsPage.getPageTitle(page); - await expect(pageTitle).to.contains(productsPage.pageTitle); + expect(pageTitle).to.contains(productsPage.pageTitle); }); it('should click on \'New product\' button and check new product modal', async function () { await testContext.addContextItem(this, 'testIdentifier', 'clickOnNewProductButton', baseContext); const isModalVisible = await productsPage.clickOnNewProductButton(page); - await expect(isModalVisible).to.be.true; + expect(isModalVisible).to.eq(true); }); it('should choose \'Standard product\' and go to new product page', async function () { @@ -115,14 +115,14 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await productsPage.clickOnAddNewProduct(page); const pageTitle = await createProductPage.getPageTitle(page); - await expect(pageTitle).to.contains(createProductPage.pageTitle); + expect(pageTitle).to.contains(createProductPage.pageTitle); }); it('should create standard product', async function () { await testContext.addContextItem(this, 'testIdentifier', 'createStandardProduct', baseContext); const createProductMessage = await createProductPage.setProduct(page, newProductData); - await expect(createProductMessage).to.equal(createProductPage.successfulUpdateMessage); + expect(createProductMessage).to.equal(createProductPage.successfulUpdateMessage); }); }); @@ -335,7 +335,7 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await pricingTab.clickOnAddSpecificPriceButton(page); const message = await pricingTab.setSpecificPrice(page, specificPriceData.specificPrice); - await expect(message).to.equal(createProductPage.successfulCreationMessage); + expect(message).to.equal(createProductPage.successfulCreationMessage); }); it('should preview product', async function () { @@ -371,7 +371,7 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await pricingTab.clickOnEditSpecificPriceIcon(page, 1); const message = await pricingTab.setSpecificPrice(page, editSpecificPriceData.specificPrice); - await expect(message).to.equal('Update successful'); + expect(message).to.equal('Update successful'); }); it('should preview product', async function () { @@ -451,7 +451,7 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await catalogPriceRulesPage.goToAddNewCatalogPriceRulePage(page); const validationMessage = await createCatalogPriceRulePage.setCatalogPriceRule(page, newCatalogPriceRuleData); - await expect(validationMessage).to.contains(catalogPriceRulesPage.successfulCreationMessage); + expect(validationMessage).to.contains(catalogPriceRulesPage.successfulCreationMessage); }); it('should close the page', async function () { From ce08dd505a5fdf7113a80564da2625145bb3e3a4 Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Tue, 26 Sep 2023 15:55:52 +0200 Subject: [PATCH 4/5] Fix ts check errors --- tests/UI/campaigns/productV2/functional/17_pricingTab.ts | 2 -- tests/UI/data/faker/product.ts | 1 - tests/UI/data/types/product.d.ts | 1 - tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts | 2 +- 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/UI/campaigns/productV2/functional/17_pricingTab.ts b/tests/UI/campaigns/productV2/functional/17_pricingTab.ts index a7beec8eb3092..95e84937053a9 100644 --- a/tests/UI/campaigns/productV2/functional/17_pricingTab.ts +++ b/tests/UI/campaigns/productV2/functional/17_pricingTab.ts @@ -46,7 +46,6 @@ describe('BO - Catalog - Products : Pricing tab', async () => { discount: 20, startingAt: 1, reductionType: '€', - isApplyDiscount: true, }, }); // Data to edit specific price @@ -56,7 +55,6 @@ describe('BO - Catalog - Products : Pricing tab', async () => { discount: 30, startingAt: 1, reductionType: '€', - isApplyDiscount: true, }, }); // Data to create new catalog price rule diff --git a/tests/UI/data/faker/product.ts b/tests/UI/data/faker/product.ts index 9726cc55162cf..f6afc31283f92 100644 --- a/tests/UI/data/faker/product.ts +++ b/tests/UI/data/faker/product.ts @@ -263,7 +263,6 @@ export default class ProductData { discount: faker.number.int({min: 10, max: 100}), startingAt: faker.number.int({min: 2, max: 5}), reductionType: '', - isApplyDiscount: true, }; /** @type {number} Minimum quantity to buy for the product */ diff --git a/tests/UI/data/types/product.d.ts b/tests/UI/data/types/product.d.ts index 25044f13b4519..6815b1e09176d 100644 --- a/tests/UI/data/types/product.d.ts +++ b/tests/UI/data/types/product.d.ts @@ -201,7 +201,6 @@ type ProductSpecificPrice = { discount: number startingAt: number reductionType: string - isApplyDiscount: boolean }; type ProductStockMovement = { diff --git a/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts b/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts index 81897f9288dba..e804d56884ad9 100644 --- a/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts +++ b/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts @@ -335,7 +335,7 @@ class PricingTab extends BOBasePage { const addSpecificPriceFrame = await page.frame({name: 'modal-specific-price-form-iframe'}); await this.setValue(addSpecificPriceFrame!, this.startingAtInput, specificPriceData.startingAt); - await this.setChecked(addSpecificPriceFrame!, this.applyDiscountToInitialPrice(specificPriceData.isApplyDiscount)); + await this.setChecked(addSpecificPriceFrame!, this.applyDiscountToInitialPrice(true)); // Choose combinations if exist if (specificPriceData.attributes) { From 48c468e9e1e7a769f685b469a6c60adf011963a4 Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Wed, 27 Sep 2023 15:09:53 +0200 Subject: [PATCH 5/5] Fix review --- .../UI/campaigns/productV2/functional/17_pricingTab.ts | 10 ---------- tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts | 1 - 2 files changed, 11 deletions(-) diff --git a/tests/UI/campaigns/productV2/functional/17_pricingTab.ts b/tests/UI/campaigns/productV2/functional/17_pricingTab.ts index 95e84937053a9..61afe05031b01 100644 --- a/tests/UI/campaigns/productV2/functional/17_pricingTab.ts +++ b/tests/UI/campaigns/productV2/functional/17_pricingTab.ts @@ -92,7 +92,6 @@ describe('BO - Catalog - Products : Pricing tab', async () => { dashboardPage.catalogParentLink, dashboardPage.productsLink, ); - await productsPage.closeSfToolBar(page); const pageTitle = await productsPage.getPageTitle(page); @@ -143,7 +142,6 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await testContext.addContextItem(this, 'testIdentifier', 'previewProduct', baseContext); page = await createProductPage.previewProduct(page); - await foProductPage.changeLanguage(page, 'en'); const pageTitle = await foProductPage.getPageTitle(page); @@ -192,7 +190,6 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await testContext.addContextItem(this, 'testIdentifier', 'previewProduct2', baseContext); page = await createProductPage.previewProduct(page); - await foProductPage.changeLanguage(page, 'en'); const pageTitle = await foProductPage.getPageTitle(page); @@ -241,7 +238,6 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await testContext.addContextItem(this, 'testIdentifier', 'editRetailPriceParUnit', baseContext); await pricingTab.setDisplayRetailPricePerUnit(page, true); - await pricingTab.setRetailPricePerUnit(page, true, 10, 'per unit'); const message = await createProductPage.saveProduct(page); @@ -268,7 +264,6 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await testContext.addContextItem(this, 'testIdentifier', 'previewProduct3', baseContext); page = await createProductPage.previewProduct(page); - await foProductPage.changeLanguage(page, 'en'); const pageTitle = await foProductPage.getPageTitle(page); @@ -304,7 +299,6 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await testContext.addContextItem(this, 'testIdentifier', 'previewProduct4', baseContext); page = await createProductPage.previewProduct(page); - await foProductPage.changeLanguage(page, 'en'); const pageTitle = await foProductPage.getPageTitle(page); @@ -340,7 +334,6 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await testContext.addContextItem(this, 'testIdentifier', 'previewProduct5', baseContext); page = await createProductPage.previewProduct(page); - await foProductPage.changeLanguage(page, 'en'); const pageTitle = await foProductPage.getPageTitle(page); @@ -376,7 +369,6 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await testContext.addContextItem(this, 'testIdentifier', 'previewProduct6', baseContext); page = await createProductPage.previewProduct(page); - await foProductPage.changeLanguage(page, 'en'); const pageTitle = await foProductPage.getPageTitle(page); @@ -410,7 +402,6 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await testContext.addContextItem(this, 'testIdentifier', 'previewProduct7', baseContext); page = await createProductPage.previewProduct(page); - await foProductPage.changeLanguage(page, 'en'); const pageTitle = await foProductPage.getPageTitle(page); @@ -456,7 +447,6 @@ describe('BO - Catalog - Products : Pricing tab', async () => { await testContext.addContextItem(this, 'testIdentifier', 'closePage', baseContext); page = await catalogPriceRulesPage.closePage(browserContext, page, 0); - await createProductPage.reloadPage(page); const pageTitle = await createProductPage.getPageTitle(page); diff --git a/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts b/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts index e804d56884ad9..601782808e193 100644 --- a/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts +++ b/tests/UI/pages/BO/catalog/productsV2/add/pricingTab.ts @@ -3,7 +3,6 @@ import BOBasePage from '@pages/BO/BObasePage'; // Import data import ProductData from '@data/faker/product'; - import type {ProductSpecificPrice} from '@data/types/product'; import type {Page} from 'playwright';