diff --git a/.github/actions/ui-test/action.yml b/.github/actions/ui-test/action.yml index 075d6eff669c1..232dd5ada7822 100644 --- a/.github/actions/ui-test/action.yml +++ b/.github/actions/ui-test/action.yml @@ -72,5 +72,6 @@ runs: URL_API: ${{ (inputs.ENABLE_SSL == 'false') && 'http://localhost:8001/admin-api/' || 'https://localhost:8002/admin-api/' }} URL_INSTALL: ${{ (inputs.ENABLE_SSL == 'false') && 'http://localhost:8001/install-dev/' || 'https://localhost:8002/install-dev/' }} DB_SERVER: ${{ inputs.DB_SERVER }} + LANG: 'en-GB' shell: bash run: npm run test:${{ inputs.TEST_CAMPAIGN }} diff --git a/tests/UI/campaigns/functional/API/02_endpoints/10_product/01_postProduct.ts b/tests/UI/campaigns/functional/API/02_endpoints/10_product/01_postProduct.ts index 6fcee0f9c1be3..e9f1a1efa32fb 100644 --- a/tests/UI/campaigns/functional/API/02_endpoints/10_product/01_postProduct.ts +++ b/tests/UI/campaigns/functional/API/02_endpoints/10_product/01_postProduct.ts @@ -8,7 +8,6 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import {expect} from 'chai'; import type {APIRequestContext, BrowserContext, Page} from 'playwright'; @@ -16,6 +15,7 @@ import { boApiClientsPage, boApiClientsCreatePage, boProductsPage, + boProductsCreateTabDescriptionPage, boDashboardPage, dataLanguages, FakerAPIClient, @@ -251,14 +251,14 @@ describe('API : POST /product', async () => { it('should check the JSON Response : `description` (EN)', async function () { await testContext.addContextItem(this, 'testIdentifier', 'checkResponseDescriptionsEN', baseContext); - const value = await descriptionTab.getValue(page, 'description', dataLanguages.english.id.toString()); + const value = await boProductsCreateTabDescriptionPage.getValue(page, 'description', dataLanguages.english.id.toString()); expect(value).to.equal(jsonResponse.descriptions[dataLanguages.english.id]); }); it('should check the JSON Response : `description` (FR)', async function () { await testContext.addContextItem(this, 'testIdentifier', 'checkResponseDescriptionsFR', baseContext); - const value = await descriptionTab.getValue(page, 'description', dataLanguages.french.id.toString()); + const value = await boProductsCreateTabDescriptionPage.getValue(page, 'description', dataLanguages.french.id.toString()); expect(value).to.equal(jsonResponse.descriptions[dataLanguages.french.id]); }); }); diff --git a/tests/UI/campaigns/functional/API/02_endpoints/10_product/03_getProductId.ts b/tests/UI/campaigns/functional/API/02_endpoints/10_product/03_getProductId.ts index 96cbb2f762daf..66a6bf2e4a224 100644 --- a/tests/UI/campaigns/functional/API/02_endpoints/10_product/03_getProductId.ts +++ b/tests/UI/campaigns/functional/API/02_endpoints/10_product/03_getProductId.ts @@ -7,7 +7,6 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import {expect} from 'chai'; import type {APIRequestContext, BrowserContext, Page} from 'playwright'; @@ -16,6 +15,7 @@ import { boApiClientsCreatePage, boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, dataLanguages, dataProducts, FakerAPIClient, @@ -186,10 +186,18 @@ describe('API : GET /product/{productId}', async () => { productNameFr = await createProductsPage.getProductName(page, dataLanguages.french.isoCode); expect(productNameFr).to.be.a('string'); - productDescriptionEn = await descriptionTab.getValue(page, 'description', dataLanguages.english.id.toString()); + productDescriptionEn = await boProductsCreateTabDescriptionPage.getValue( + page, + 'description', + dataLanguages.english.id.toString(), + ); expect(productDescriptionEn).to.be.a('string'); - productDescriptionFr = await descriptionTab.getValue(page, 'description', dataLanguages.french.id.toString()); + productDescriptionFr = await boProductsCreateTabDescriptionPage.getValue( + page, + 'description', + dataLanguages.french.id.toString(), + ); expect(productDescriptionFr).to.be.a('string'); }); }); diff --git a/tests/UI/campaigns/functional/API/02_endpoints/10_product/04_patchProductId.ts b/tests/UI/campaigns/functional/API/02_endpoints/10_product/04_patchProductId.ts index 558bed0b40f8d..bd2da1652d067 100644 --- a/tests/UI/campaigns/functional/API/02_endpoints/10_product/04_patchProductId.ts +++ b/tests/UI/campaigns/functional/API/02_endpoints/10_product/04_patchProductId.ts @@ -8,7 +8,6 @@ import {createProductTest, deleteProductTest} from '@commonTests/BO/catalog/prod // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import {expect} from 'chai'; import type {APIRequestContext, BrowserContext, Page} from 'playwright'; @@ -17,6 +16,7 @@ import { boApiClientsCreatePage, boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, dataLanguages, FakerAPIClient, FakerProduct, @@ -244,8 +244,16 @@ describe('API : PATCH /product/{productId}', async () => { [dataLanguages.french.id]: valuePropertyFR, }).to.deep.equal(data.propertyValue); } else if (data.propertyName === 'descriptions') { - const valuePropertyEN = await descriptionTab.getValue(page, 'description', dataLanguages.english.id.toString()); - const valuePropertyFR = await descriptionTab.getValue(page, 'description', dataLanguages.french.id.toString()); + const valuePropertyEN = await boProductsCreateTabDescriptionPage.getValue( + page, + 'description', + dataLanguages.english.id.toString(), + ); + const valuePropertyFR = await boProductsCreateTabDescriptionPage.getValue( + page, + 'description', + dataLanguages.french.id.toString(), + ); expect({ [dataLanguages.english.id]: valuePropertyEN, [dataLanguages.french.id]: valuePropertyFR, diff --git a/tests/UI/campaigns/functional/API/02_endpoints/10_product/05_postProductIdImage.ts b/tests/UI/campaigns/functional/API/02_endpoints/10_product/05_postProductIdImage.ts index 8bfe232a096a6..d6badf85f69c5 100644 --- a/tests/UI/campaigns/functional/API/02_endpoints/10_product/05_postProductIdImage.ts +++ b/tests/UI/campaigns/functional/API/02_endpoints/10_product/05_postProductIdImage.ts @@ -8,7 +8,6 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import {expect} from 'chai'; import fs from 'fs'; @@ -18,6 +17,7 @@ import { boApiClientsCreatePage, boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, dataLanguages, FakerAPIClient, FakerProduct, @@ -239,10 +239,10 @@ describe('API : POST /product/{productId}/image', async () => { const pageTitle: string = await createProductsPage.getPageTitle(page); expect(pageTitle).to.contains(createProductsPage.pageTitle); - const numImages = await descriptionTab.getNumberOfImages(page); + const numImages = await boProductsCreateTabDescriptionPage.getNumberOfImages(page); expect(numImages).to.be.equals(1); - productImageInformation = await descriptionTab.getProductImageInformation(page, 1); + productImageInformation = await boProductsCreateTabDescriptionPage.getProductImageInformation(page, 1); }); it('should check the JSON Response : `imageId`', async function () { diff --git a/tests/UI/campaigns/functional/API/02_endpoints/10_product/06_getProductIdImages.ts b/tests/UI/campaigns/functional/API/02_endpoints/10_product/06_getProductIdImages.ts index 550e13df0e025..cf722c63327dd 100644 --- a/tests/UI/campaigns/functional/API/02_endpoints/10_product/06_getProductIdImages.ts +++ b/tests/UI/campaigns/functional/API/02_endpoints/10_product/06_getProductIdImages.ts @@ -7,7 +7,6 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import {expect} from 'chai'; import type {APIRequestContext, BrowserContext, Page} from 'playwright'; @@ -16,6 +15,7 @@ import { boApiClientsCreatePage, boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, dataLanguages, dataProducts, FakerAPIClient, @@ -206,7 +206,7 @@ describe('API : GET /product/{productId}/images', async () => { const pageTitle: string = await createProductsPage.getPageTitle(page); expect(pageTitle).to.contains(createProductsPage.pageTitle); - const numImages = await descriptionTab.getNumberOfImages(page); + const numImages = await boProductsCreateTabDescriptionPage.getNumberOfImages(page); expect(numImages).to.be.equals(jsonResponse.length); }); @@ -214,7 +214,7 @@ describe('API : GET /product/{productId}/images', async () => { await testContext.addContextItem(this, 'testIdentifier', 'checkJSONItems', baseContext); for (let idxItem: number = 0; idxItem < jsonResponse.length; idxItem++) { - const productImageInformation = await descriptionTab.getProductImageInformation(page, idxItem + 1); + const productImageInformation = await boProductsCreateTabDescriptionPage.getProductImageInformation(page, idxItem + 1); expect(productImageInformation.id).to.equal(jsonResponse[idxItem].imageId); diff --git a/tests/UI/campaigns/functional/API/02_endpoints/10_product/07_getProductImageId.ts b/tests/UI/campaigns/functional/API/02_endpoints/10_product/07_getProductImageId.ts index 787aaecc47c5e..66089996f5fb2 100644 --- a/tests/UI/campaigns/functional/API/02_endpoints/10_product/07_getProductImageId.ts +++ b/tests/UI/campaigns/functional/API/02_endpoints/10_product/07_getProductImageId.ts @@ -7,7 +7,6 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import {expect} from 'chai'; import type {APIRequestContext, BrowserContext, Page} from 'playwright'; @@ -16,6 +15,7 @@ import { boApiClientsCreatePage, boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, dataLanguages, dataProducts, FakerAPIClient, @@ -206,7 +206,7 @@ describe('API : GET /product/image/{imageId}', async () => { it('should fetch images informations', async function () { await testContext.addContextItem(this, 'testIdentifier', 'checkJSONItems', baseContext); - const productImageInformation = await descriptionTab.getProductImageInformation(page, 1); + const productImageInformation = await boProductsCreateTabDescriptionPage.getProductImageInformation(page, 1); expect(productImageInformation.id).to.equal(jsonResponse.imageId); diff --git a/tests/UI/campaigns/functional/API/02_endpoints/10_product/08_postProductImageId.ts b/tests/UI/campaigns/functional/API/02_endpoints/10_product/08_postProductImageId.ts index f2be75ddb39c1..49d3489ddc5e4 100644 --- a/tests/UI/campaigns/functional/API/02_endpoints/10_product/08_postProductImageId.ts +++ b/tests/UI/campaigns/functional/API/02_endpoints/10_product/08_postProductImageId.ts @@ -8,7 +8,6 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import {expect} from 'chai'; import fs from 'fs'; @@ -18,6 +17,7 @@ import { boApiClientsCreatePage, boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, dataLanguages, FakerAPIClient, FakerProduct, @@ -188,23 +188,23 @@ describe('API : POST /product/image/{imageId}', async () => { const pageTitle: string = await createProductsPage.getPageTitle(page); expect(pageTitle).to.contains(createProductsPage.pageTitle); - const numImages = await descriptionTab.getNumberOfImages(page); + const numImages = await boProductsCreateTabDescriptionPage.getNumberOfImages(page); expect(numImages).to.be.equals(0); }); it('should add image', async function () { await testContext.addContextItem(this, 'testIdentifier', 'addImage', baseContext); - await descriptionTab.addProductImages(page, [productImageCreated]); + await boProductsCreateTabDescriptionPage.addProductImages(page, [productImageCreated]); - const numOfImages = await descriptionTab.getNumberOfImages(page); + const numOfImages = await boProductsCreateTabDescriptionPage.getNumberOfImages(page); expect(numOfImages).to.eq(1); }); it('should set image information', async function () { await testContext.addContextItem(this, 'testIdentifier', 'setImageInformation', baseContext); - const message = await descriptionTab.setProductImageInformation( + const message = await boProductsCreateTabDescriptionPage.setProductImageInformation( page, 1, true, @@ -214,9 +214,9 @@ describe('API : POST /product/image/{imageId}', async () => { true, true, ); - expect(message).to.be.eq(descriptionTab.settingUpdatedMessage); + expect(message).to.be.eq(boProductsCreateTabDescriptionPage.settingUpdatedMessage); - productImageInformation = await descriptionTab.getProductImageInformation(page, 1); + productImageInformation = await boProductsCreateTabDescriptionPage.getProductImageInformation(page, 1); }); }); @@ -294,7 +294,7 @@ describe('API : POST /product/image/{imageId}', async () => { await boProductsPage.reloadPage(page); - productImageInformation = await descriptionTab.getProductImageInformation(page, 1); + productImageInformation = await boProductsCreateTabDescriptionPage.getProductImageInformation(page, 1); }); it('should check the JSON Response : `imageId`', async function () { 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 1ed34e2f78317..02ae8eb8199b8 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 @@ -7,7 +7,6 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import detailsTab from '@pages/BO/catalog/products/add/detailsTab'; import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; @@ -17,6 +16,7 @@ import {faker} from '@faker-js/faker'; import { boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, boProductsCreateTabStocksPage, FakerProduct, type ProductHeaderSummary, @@ -259,23 +259,29 @@ describe('BO - Catalog - Products : Header', async () => { it('should add image', async function () { await testContext.addContextItem(this, 'testIdentifier', 'addImage', baseContext); - await descriptionTab.addProductImages(page, [productCoverImage]); + await boProductsCreateTabDescriptionPage.addProductImages(page, [productCoverImage]); - const numOfImages = await descriptionTab.getNumberOfImages(page); + const numOfImages = await boProductsCreateTabDescriptionPage.getNumberOfImages(page); expect(numOfImages).to.eq(2); }); it('should set image information', async function () { await testContext.addContextItem(this, 'testIdentifier', 'setImageInformation', baseContext); - const message = await descriptionTab.setProductImageInformation(page, 2, true, 'Caption EN', 'Caption FR'); - expect(message).to.be.eq(descriptionTab.settingUpdatedMessage); + const message = await boProductsCreateTabDescriptionPage.setProductImageInformation( + page, + 2, + true, + 'Caption EN', + 'Caption FR', + ); + expect(message).to.be.eq(boProductsCreateTabDescriptionPage.settingUpdatedMessage); }); it('should check image has changed', async function () { await testContext.addContextItem(this, 'testIdentifier', 'checkImageHasChanged', baseContext); - await descriptionTab.reloadPage(page); + await boProductsCreateTabDescriptionPage.reloadPage(page); const productHeaderSummary = await createProductsPage.getProductHeaderSummary(page); expect(productHeaderSummary.imageUrl).to.be.not.eq(productHeaderSummaryInitial.imageUrl); diff --git a/tests/UI/campaigns/functional/BO/03_catalog/01_products/10_descriptionTab.ts b/tests/UI/campaigns/functional/BO/03_catalog/01_products/10_descriptionTab.ts index 376a6cbfd9444..37ebb14ba7be7 100644 --- a/tests/UI/campaigns/functional/BO/03_catalog/01_products/10_descriptionTab.ts +++ b/tests/UI/campaigns/functional/BO/03_catalog/01_products/10_descriptionTab.ts @@ -7,13 +7,13 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import type {BrowserContext, Page} from 'playwright'; import {expect} from 'chai'; import { boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, FakerProduct, utilsFile, utilsPlaywright, @@ -114,57 +114,66 @@ describe('BO - Catalog - Products : Description tab', async () => { it('should add 3 images', async function () { await testContext.addContextItem(this, 'testIdentifier', 'addImage', baseContext); - await descriptionTab.addProductImages(page, [productData.coverImage, productCoverImage, replaceProductCoverImage]); + await boProductsCreateTabDescriptionPage.addProductImages( + page, + [productData.coverImage, productCoverImage, replaceProductCoverImage], + ); - const numOfImages = await descriptionTab.getNumberOfImages(page); + const numOfImages = await boProductsCreateTabDescriptionPage.getNumberOfImages(page); expect(numOfImages).to.eq(3); }); it('should set image information', async function () { await testContext.addContextItem(this, 'testIdentifier', 'setImageInformation', baseContext); - const message = await descriptionTab.setProductImageInformation(page, 2, true, 'Caption EN', 'Caption FR'); - expect(message).to.be.eq(descriptionTab.settingUpdatedMessage); + const message = await boProductsCreateTabDescriptionPage.setProductImageInformation( + page, + 2, + true, + 'Caption EN', + 'Caption FR', + ); + expect(message).to.be.eq(boProductsCreateTabDescriptionPage.settingUpdatedMessage); }); it('should click on the magnifying glass', async function () { await testContext.addContextItem(this, 'testIdentifier', 'zoomImage', baseContext); - const isImageZoomed = await descriptionTab.clickOnMagnifyingGlass(page); + const isImageZoomed = await boProductsCreateTabDescriptionPage.clickOnMagnifyingGlass(page); expect(isImageZoomed).to.eq(true); }); it('should close the image zoom', async function () { await testContext.addContextItem(this, 'testIdentifier', 'closeZoom', baseContext); - const isZoomClosed = await descriptionTab.closeImageZoom(page); + const isZoomClosed = await boProductsCreateTabDescriptionPage.closeImageZoom(page); expect(isZoomClosed).to.eq(true); }); it('should replace image selection', async function () { await testContext.addContextItem(this, 'testIdentifier', 'replaceImageSelection', baseContext); - const message = await descriptionTab.replaceImageSelection(page, replaceProductCoverImage); - expect(message).to.be.eq(descriptionTab.settingUpdatedMessage); + const message = await boProductsCreateTabDescriptionPage.replaceImageSelection(page, replaceProductCoverImage); + expect(message).to.be.eq(boProductsCreateTabDescriptionPage.settingUpdatedMessage); }); it('should delete the image', async function () { await testContext.addContextItem(this, 'testIdentifier', 'deleteImage', baseContext); - const message = await descriptionTab.deleteImage(page); - expect(message).to.be.eq(descriptionTab.successfulMultiDeleteMessage); + const message = await boProductsCreateTabDescriptionPage.deleteImage(page); + expect(message).to.be.eq(boProductsCreateTabDescriptionPage.successfulMultiDeleteMessage); }); it('should select the first image and click on select all products', async function () { await testContext.addContextItem(this, 'testIdentifier', 'selectProduct', baseContext); - await descriptionTab.setProductImageInformation(page, 1, undefined, undefined, undefined, true, false); + await boProductsCreateTabDescriptionPage.setProductImageInformation(page, 1, undefined, undefined, undefined, true, false); }); it('should set product description and summary', async function () { await testContext.addContextItem(this, 'testIdentifier', 'setProductDescription', baseContext); - await descriptionTab.setProductDescription(page, productData); + await boProductsCreateTabDescriptionPage.setProductDescription(page, productData); const createProductMessage = await createProductsPage.saveProduct(page); expect(createProductMessage).to.equal(createProductsPage.successfulUpdateMessage); @@ -173,32 +182,32 @@ describe('BO - Catalog - Products : Description tab', async () => { it('should add category', async function () { await testContext.addContextItem(this, 'testIdentifier', 'addCategory', baseContext); - await descriptionTab.addNewCategory(page, ['Clothes', 'Men']); + await boProductsCreateTabDescriptionPage.addNewCategory(page, ['Clothes', 'Men']); const createProductMessage = await createProductsPage.saveProduct(page); expect(createProductMessage).to.equal(createProductsPage.successfulUpdateMessage); - const selectedCategories = await descriptionTab.getSelectedCategories(page); + const selectedCategories = await boProductsCreateTabDescriptionPage.getSelectedCategories(page); expect(selectedCategories).to.eq('Home x Clothes x Men x'); }); it('should check that we can delete the 2 categories', async function () { await testContext.addContextItem(this, 'testIdentifier', 'checkDeleteIcon', baseContext); - let isDeleteIconVisible = await descriptionTab.isDeleteCategoryIconVisible(page, 0); + let isDeleteIconVisible = await boProductsCreateTabDescriptionPage.isDeleteCategoryIconVisible(page, 0); expect(isDeleteIconVisible).to.eq(false); - isDeleteIconVisible = await descriptionTab.isDeleteCategoryIconVisible(page, 1); + isDeleteIconVisible = await boProductsCreateTabDescriptionPage.isDeleteCategoryIconVisible(page, 1); expect(isDeleteIconVisible).to.eq(true); - isDeleteIconVisible = await descriptionTab.isDeleteCategoryIconVisible(page, 2); + isDeleteIconVisible = await boProductsCreateTabDescriptionPage.isDeleteCategoryIconVisible(page, 2); expect(isDeleteIconVisible).to.eq(true); }); it('should choose default category', async function () { await testContext.addContextItem(this, 'testIdentifier', 'chooseDefaultCategory', baseContext); - await descriptionTab.chooseDefaultCategory(page, 2); + await boProductsCreateTabDescriptionPage.chooseDefaultCategory(page, 2); const createProductMessage = await createProductsPage.saveProduct(page); expect(createProductMessage).to.equal(createProductsPage.successfulUpdateMessage); @@ -207,20 +216,20 @@ describe('BO - Catalog - Products : Description tab', async () => { it('should check that we can delete the first and the last category', async function () { await testContext.addContextItem(this, 'testIdentifier', 'checkDeleteIcon2', baseContext); - let isDeleteIconVisible = await descriptionTab.isDeleteCategoryIconVisible(page, 0); + let isDeleteIconVisible = await boProductsCreateTabDescriptionPage.isDeleteCategoryIconVisible(page, 0); expect(isDeleteIconVisible).to.eq(true); - isDeleteIconVisible = await descriptionTab.isDeleteCategoryIconVisible(page, 1); + isDeleteIconVisible = await boProductsCreateTabDescriptionPage.isDeleteCategoryIconVisible(page, 1); expect(isDeleteIconVisible).to.eq(false); - isDeleteIconVisible = await descriptionTab.isDeleteCategoryIconVisible(page, 2); + isDeleteIconVisible = await boProductsCreateTabDescriptionPage.isDeleteCategoryIconVisible(page, 2); expect(isDeleteIconVisible).to.eq(true); }); it('should choose brand', async function () { await testContext.addContextItem(this, 'testIdentifier', 'chooseBrand', baseContext); - await descriptionTab.chooseBrand(page, 2); + await boProductsCreateTabDescriptionPage.chooseBrand(page, 2); const createProductMessage = await createProductsPage.saveProduct(page); expect(createProductMessage).to.equal(createProductsPage.successfulUpdateMessage); @@ -229,7 +238,7 @@ describe('BO - Catalog - Products : Description tab', async () => { it('should add related product', async function () { await testContext.addContextItem(this, 'testIdentifier', 'addRelatedProduct', baseContext); - await descriptionTab.addRelatedProduct(page, 't-shirt'); + await boProductsCreateTabDescriptionPage.addRelatedProduct(page, 't-shirt'); const createProductMessage = await createProductsPage.saveProduct(page); expect(createProductMessage).to.equal(createProductsPage.successfulUpdateMessage); diff --git a/tests/UI/campaigns/functional/BO/03_catalog/01_products/19_optionsTab.ts b/tests/UI/campaigns/functional/BO/03_catalog/01_products/19_optionsTab.ts index 6c9261e240358..757107229ed7a 100644 --- a/tests/UI/campaigns/functional/BO/03_catalog/01_products/19_optionsTab.ts +++ b/tests/UI/campaigns/functional/BO/03_catalog/01_products/19_optionsTab.ts @@ -6,13 +6,13 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import BO pages import createProductPage from '@pages/BO/catalog/products/add'; import optionsTab from '@pages/BO/catalog/products/add/optionsTab'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import type {BrowserContext, Page} from 'playwright'; import {expect} from 'chai'; import { boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, FakerProduct, foClassicHomePage, foClassicCategoryPage, @@ -109,7 +109,7 @@ describe('BO - Catalog - Products : Options tab', async () => { await testContext.addContextItem(this, 'testIdentifier', 'addCategory', baseContext); await createProductPage.goToTab(page, 'description'); - await descriptionTab.addNewCategory(page, ['Clothes']); + await boProductsCreateTabDescriptionPage.addNewCategory(page, ['Clothes']); const createProductMessage = await createProductPage.saveProduct(page); expect(createProductMessage).to.equal(createProductPage.successfulUpdateMessage); @@ -118,7 +118,7 @@ describe('BO - Catalog - Products : Options tab', async () => { it('should choose \'Clothes\' as default category', async function () { await testContext.addContextItem(this, 'testIdentifier', 'chooseDefaultCategory', baseContext); - await descriptionTab.chooseDefaultCategory(page, 2); + await boProductsCreateTabDescriptionPage.chooseDefaultCategory(page, 2); const createProductMessage = await createProductPage.saveProduct(page); expect(createProductMessage).to.equal(createProductPage.successfulUpdateMessage); diff --git a/tests/UI/campaigns/functional/BO/03_catalog/01_products/21_filterSortPagination.ts b/tests/UI/campaigns/functional/BO/03_catalog/01_products/21_filterSortPagination.ts index efebb9c602c44..961dc06c2ae7d 100644 --- a/tests/UI/campaigns/functional/BO/03_catalog/01_products/21_filterSortPagination.ts +++ b/tests/UI/campaigns/functional/BO/03_catalog/01_products/21_filterSortPagination.ts @@ -6,13 +6,13 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import {expect} from 'chai'; import type {BrowserContext, Page} from 'playwright'; import { boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, dataCategories, type ProductFilterMinMax, utilsCore, @@ -225,7 +225,7 @@ describe('BO - Catalog - Products list : Filter & Sort, Pagination, Filter by ca baseContext, ); - const selectedCategories: string = await descriptionTab.getSelectedCategories(page); + const selectedCategories: string = await boProductsCreateTabDescriptionPage.getSelectedCategories(page); expect(selectedCategories).to.contains(arg.categoryName); }); diff --git a/tests/UI/campaigns/functional/BO/08_design/06_imageSettings/13_checkProductImageFormat.ts b/tests/UI/campaigns/functional/BO/08_design/06_imageSettings/13_checkProductImageFormat.ts index cc317102bfc68..55b2510107c88 100644 --- a/tests/UI/campaigns/functional/BO/08_design/06_imageSettings/13_checkProductImageFormat.ts +++ b/tests/UI/campaigns/functional/BO/08_design/06_imageSettings/13_checkProductImageFormat.ts @@ -7,7 +7,6 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import imageSettingsPage from '@pages/BO/design/imageSettings'; import {expect} from 'chai'; @@ -15,6 +14,7 @@ import type {BrowserContext, Page} from 'playwright'; import { boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, FakerProduct, foClassicCategoryPage, foClassicHomePage, @@ -220,7 +220,7 @@ describe('BO - Design - Image Settings - Check product image format', async () = expect(saveButtonName).to.equal('Save and publish'); idProduct = await createProductsPage.getProductID(page); - idProductImage = await descriptionTab.getProductIDImageCover(page); + idProductImage = await boProductsCreateTabDescriptionPage.getProductIDImageCover(page); expect(idProduct).to.be.gt(0); }); diff --git a/tests/UI/campaigns/functional/BO/08_design/06_imageSettings/16_checkBaseImageFormat.ts b/tests/UI/campaigns/functional/BO/08_design/06_imageSettings/16_checkBaseImageFormat.ts index 1427e72397f89..ea24d45aefc3e 100644 --- a/tests/UI/campaigns/functional/BO/08_design/06_imageSettings/16_checkBaseImageFormat.ts +++ b/tests/UI/campaigns/functional/BO/08_design/06_imageSettings/16_checkBaseImageFormat.ts @@ -7,7 +7,6 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import pages import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import imageSettingsPage from '@pages/BO/design/imageSettings'; import {expect} from 'chai'; @@ -15,6 +14,7 @@ import type {BrowserContext, Page} from 'playwright'; import { boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, FakerProduct, utilsFile, utilsPlaywright, @@ -223,7 +223,7 @@ describe('BO - Design - Image Settings - Check base image format', async () => { expect(saveButtonName).to.equal('Save and publish'); idProduct = await createProductsPage.getProductID(page); - idProductImage = await descriptionTab.getProductIDImageCover(page); + idProductImage = await boProductsCreateTabDescriptionPage.getProductIDImageCover(page); expect(idProduct).to.be.gt(0); }); diff --git a/tests/UI/campaigns/functional/BO/13_shopParameters/01_general/general/03_allowIframes.ts b/tests/UI/campaigns/functional/BO/13_shopParameters/01_general/general/03_allowIframes.ts index fab56a7aa8bb0..1fa7cae03d3c9 100644 --- a/tests/UI/campaigns/functional/BO/13_shopParameters/01_general/general/03_allowIframes.ts +++ b/tests/UI/campaigns/functional/BO/13_shopParameters/01_general/general/03_allowIframes.ts @@ -7,13 +7,13 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import pages // Import BO pages import addProductPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import {expect} from 'chai'; import type {BrowserContext, Page} from 'playwright'; import { boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, boShopParametersPage, dataProducts, foClassicProductPage, @@ -103,7 +103,7 @@ describe('BO - Shop Parameters - General : Enable/Disable Allow iframes on HTML it('should add an iframe in the product description', async function () { await testContext.addContextItem(this, 'testIdentifier', `editDescription${index}`, baseContext); - await descriptionTab.setIframeInDescription(page, description); + await boProductsCreateTabDescriptionPage.setIframeInDescription(page, description); // @todo : https://github.com/PrestaShop/PrestaShop/issues/33921 // To delete after the fix of the issue @@ -176,8 +176,8 @@ describe('BO - Shop Parameters - General : Enable/Disable Allow iframes on HTML it('should reset the product description', async function () { await testContext.addContextItem(this, 'testIdentifier', 'resetDescription', baseContext); - await descriptionTab.setIframeInDescription(page, ''); - await descriptionTab.setDescription(page, dataProducts.demo_14.description); + await boProductsCreateTabDescriptionPage.setIframeInDescription(page, ''); + await boProductsCreateTabDescriptionPage.setDescription(page, dataProducts.demo_14.description); const message = await addProductPage.saveProduct(page); expect(message).to.eq(addProductPage.successfulUpdateMessage); diff --git a/tests/UI/campaigns/functional/BO/13_shopParameters/03_productSettings/01_productsGeneral/03_maxSizeShortDescription.ts b/tests/UI/campaigns/functional/BO/13_shopParameters/03_productSettings/01_productsGeneral/03_maxSizeShortDescription.ts index 3a71a08a8890c..c491b0b3ac733 100644 --- a/tests/UI/campaigns/functional/BO/13_shopParameters/03_productSettings/01_productsGeneral/03_maxSizeShortDescription.ts +++ b/tests/UI/campaigns/functional/BO/13_shopParameters/03_productSettings/01_productsGeneral/03_maxSizeShortDescription.ts @@ -6,13 +6,13 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import pages import addProductPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import {expect} from 'chai'; import type {BrowserContext, Page} from 'playwright'; import { boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, boProductSettingsPage, FakerProduct, utilsPlaywright, @@ -107,7 +107,7 @@ describe('BO - Shop Parameters - Product Settings : Update max size of short des and check the error message`, async function () { await testContext.addContextItem(this, 'testIdentifier', `testSummarySize${index}`, baseContext); - await descriptionTab.setProductDescription(page, productData); + await boProductsCreateTabDescriptionPage.setProductDescription(page, productData); const errorMessage = await addProductPage.getErrorMessageWhenSummaryIsTooLong(page); expect(errorMessage).to.contains( diff --git a/tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/01_editSearchSettings/05_maximumWordLength.ts b/tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/01_editSearchSettings/05_maximumWordLength.ts new file mode 100644 index 0000000000000..f755511bdb1ab --- /dev/null +++ b/tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/01_editSearchSettings/05_maximumWordLength.ts @@ -0,0 +1,189 @@ +// Import utils +import testContext from '@utils/testContext'; + +// Import login steps +import loginCommon from '@commonTests/BO/loginBO'; + +import {expect} from 'chai'; +import type {BrowserContext, Page} from 'playwright'; +import { + boDashboardPage, + boSearchPage, + foClassicHomePage, + foClassicSearchResultsPage, + utilsPlaywright, +} from '@prestashop-core/ui-testing'; + +const baseContext: string = 'functional_BO_shopParameters_search_search_editSearchSettings_maximumWordLength'; + +describe('BO - Shop Parameters - Search : Maximum word length (in characters)', async () => { + const maximumWordLength: number = 15; + + let browserContext: BrowserContext; + let page: Page; + + 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 loginCommon.loginBO(this, page); + }); + + 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 verify the maximum word length value', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'checkMaxWordLengthValue', baseContext); + + const value = await boSearchPage.getMaximumWordLength(page); + expect(value).to.equal(maximumWordLength); + }); + + it('should go to the FrontOffice', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'viewMyShop', baseContext); + + page = await boSearchPage.viewMyShop(page); + await foClassicHomePage.changeLanguage(page, 'en'); + + const isHomePage = await foClassicHomePage.isHomePage(page); + expect(isHomePage, 'Fail to open FO home page').to.eq(true); + }); + + it('should search the word "hummingbird shirt"', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'searchWordHummingbirdShirt15', baseContext); + + await foClassicHomePage.searchProduct(page, 'hummingbird shirt'); + + const pageTitle = await foClassicSearchResultsPage.getPageTitle(page); + expect(pageTitle).to.equal(foClassicSearchResultsPage.pageTitle); + + const hasResults = await foClassicSearchResultsPage.hasResults(page); + expect(hasResults).to.eq(true); + + const numResults = await foClassicSearchResultsPage.getSearchResultsNumber(page); + expect(numResults).to.eq(1); + + const searchInputValue = await foClassicSearchResultsPage.getSearchValue(page); + expect(searchInputValue).to.be.equal('hummingbird shirt'); + }); + + it('should set the maximum word length to 2', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'setMaxWordLengthTo2', baseContext); + + page = await foClassicSearchResultsPage.changePage(browserContext, 0); + const textResult = await boSearchPage.setMaximumWordLength(page, 2); + expect(textResult).to.be.eq(boSearchPage.settingsUpdateMessage); + }); + + it('should search the word "hummingbird shirt"', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'searchWordHummingbirdShirt2', baseContext); + + page = await boSearchPage.changePage(browserContext, 1); + await foClassicHomePage.reloadPage(page); + + const pageTitle = await foClassicSearchResultsPage.getPageTitle(page); + expect(pageTitle).to.equal(foClassicSearchResultsPage.pageTitle); + + const hasResults = await foClassicSearchResultsPage.hasResults(page); + expect(hasResults).to.eq(true); + + const numResults = await foClassicSearchResultsPage.getSearchResultsNumber(page); + expect(numResults).to.eq(2); + + const searchInputValue = await foClassicSearchResultsPage.getSearchValue(page); + expect(searchInputValue).to.be.equal('hummingbird shirt'); + }); + + it('should set the maximum word length to 1', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'setMaxWordLengthTo1', baseContext); + + page = await foClassicSearchResultsPage.changePage(browserContext, 0); + const textResult = await boSearchPage.setMaximumWordLength(page, 1); + expect(textResult).to.be.eq(boSearchPage.settingsUpdateMessage); + }); + + it('should search the word "hummingbird shirt"', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'searchWordHummingbirdShirt1', baseContext); + + page = await boSearchPage.changePage(browserContext, 1); + await foClassicHomePage.reloadPage(page); + + const pageTitle = await foClassicSearchResultsPage.getPageTitle(page); + expect(pageTitle).to.equal(foClassicSearchResultsPage.pageTitle); + + const hasResults = await foClassicSearchResultsPage.hasResults(page); + expect(hasResults).to.eq(true); + + const numResults = await foClassicSearchResultsPage.getSearchResultsNumber(page); + expect(numResults).to.eq(13); + + const searchInputValue = await foClassicSearchResultsPage.getSearchValue(page); + expect(searchInputValue).to.be.equal('hummingbird shirt'); + }); + + it('should set the maximum word length to 0', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'setMaxWordLengthTo0', baseContext); + + page = await foClassicSearchResultsPage.changePage(browserContext, 0); + const textResult = await boSearchPage.setMaximumWordLength(page, 0); + expect(textResult).to.be.eq(boSearchPage.settingsUpdateMessage); + }); + + it('should search the word "hummingbird shirt"', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'searchWordHummingbirdShirt0', baseContext); + + page = await boSearchPage.changePage(browserContext, 1); + await foClassicHomePage.reloadPage(page); + + const pageTitle = await foClassicSearchResultsPage.getPageTitle(page); + expect(pageTitle).to.equal(foClassicSearchResultsPage.pageTitle); + + const hasResults = await foClassicSearchResultsPage.hasResults(page); + expect(hasResults).to.eq(true); + + const numResults = await foClassicSearchResultsPage.getSearchResultsNumber(page); + expect(numResults).to.eq(19); + + const searchInputValue = await foClassicSearchResultsPage.getSearchValue(page); + expect(searchInputValue).to.be.equal('hummingbird shirt'); + }); + + it('should set the maximum word length to ""', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'setMaxWordLengthToEmpty', baseContext); + + page = await foClassicSearchResultsPage.changePage(browserContext, 0); + const textResult = await boSearchPage.setMaximumWordLength(page, ''); + expect(textResult).to.contains(boSearchPage.errorFillFieldMessage); + }); + + it('should set the maximum word length to "vhgfud"', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'setMaxWordLengthToError', baseContext); + + page = await foClassicSearchResultsPage.changePage(browserContext, 0); + const textResult = await boSearchPage.setMaximumWordLength(page, 'vhgfud'); + expect(textResult).to.contains(boSearchPage.errorMaxWordLengthInvalidMessage); + }); + + it('should reset the maximum word length', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'resetMaximumWordLength', baseContext); + + const textResult = await boSearchPage.setMaximumWordLength(page, maximumWordLength); + expect(textResult).to.be.eq(boSearchPage.settingsUpdateMessage); + }); +}); diff --git a/tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/01_editSearchSettings/05_minimumWordLength.ts b/tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/01_editSearchSettings/06_minimumWordLength.ts similarity index 100% rename from tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/01_editSearchSettings/05_minimumWordLength.ts rename to tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/01_editSearchSettings/06_minimumWordLength.ts diff --git a/tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/01_editSearchSettings/06_blacklistedWords.ts b/tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/01_editSearchSettings/07_blacklistedWords.ts similarity index 100% rename from tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/01_editSearchSettings/06_blacklistedWords.ts rename to tests/UI/campaigns/functional/BO/13_shopParameters/07_search/01_search/01_editSearchSettings/07_blacklistedWords.ts diff --git a/tests/UI/campaigns/functional/BO/14_advancedParameters/03_administration/02_uploadQuota.ts b/tests/UI/campaigns/functional/BO/14_advancedParameters/03_administration/02_uploadQuota.ts index a0c05e6566312..7c951bb8de193 100644 --- a/tests/UI/campaigns/functional/BO/14_advancedParameters/03_administration/02_uploadQuota.ts +++ b/tests/UI/campaigns/functional/BO/14_advancedParameters/03_administration/02_uploadQuota.ts @@ -5,7 +5,6 @@ import testContext from '@utils/testContext'; import loginCommon from '@commonTests/BO/loginBO'; // Import pages -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import createProductPage from '@pages/BO/catalog/products/add'; import filesPage from '@pages/BO/catalog/files'; import addFilePage from '@pages/BO/catalog/files/add'; @@ -16,6 +15,7 @@ import { boAdministrationPage, boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, boProductsCreateTabVirtualProductPage, FakerFile, FakerProduct, @@ -307,7 +307,10 @@ describe('BO - Advanced Parameters - Administration : Upload quota', async () => await testContext.addContextItem(this, 'testIdentifier', 'addImageAndCheckErrorMessage', baseContext); await createProductPage.setProductName(page, firstVirtualProductData.name, 'en'); - await descriptionTab.uploadProductImages(page, [firstStandardProductData.coverImage, firstStandardProductData.thumbImage]); + await boProductsCreateTabDescriptionPage.uploadProductImages( + page, + [firstStandardProductData.coverImage, firstStandardProductData.thumbImage], + ); const message = await createProductPage.getGrowlMessageContent(page); expect(message).to.eq('Max file size allowed is "1048576" bytes.'); @@ -317,7 +320,7 @@ describe('BO - Advanced Parameters - Administration : Upload quota', async () => await testContext.addContextItem(this, 'testIdentifier', 'addImageAndCheckSuccessMessage', baseContext); await createProductPage.setProductName(page, firstVirtualProductData.name, 'en'); - await descriptionTab.uploadProductImages(page, + await boProductsCreateTabDescriptionPage.uploadProductImages(page, [secondStandardProductData.coverImage, secondStandardProductData.thumbImage]); const message = await createProductPage.saveProduct(page); diff --git a/tests/UI/campaigns/functional/FO/classic/09_productPage/02_productPage/03_changeImage.ts b/tests/UI/campaigns/functional/FO/classic/09_productPage/02_productPage/03_changeImage.ts index 92c5fc66fff7f..ab1faa59310da 100644 --- a/tests/UI/campaigns/functional/FO/classic/09_productPage/02_productPage/03_changeImage.ts +++ b/tests/UI/campaigns/functional/FO/classic/09_productPage/02_productPage/03_changeImage.ts @@ -3,17 +3,17 @@ import testContext from '@utils/testContext'; // Import common tests import {deleteProductTest} from '@commonTests/BO/catalog/product'; +import loginCommon from '@commonTests/BO/loginBO'; // Import BO pages -import loginCommon from '@commonTests/BO/loginBO'; import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import {expect} from 'chai'; import type {BrowserContext, Page} from 'playwright'; import { boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, FakerProduct, foClassicHomePage, foClassicProductPage, @@ -112,10 +112,10 @@ describe('FO - Product page - Quick view : Change image', async () => { it('should add 4 images', async function () { await testContext.addContextItem(this, 'testIdentifier', 'addImage', baseContext); - await descriptionTab.addProductImages(page, + await boProductsCreateTabDescriptionPage.addProductImages(page, [newProductData.coverImage, newProductData.thumbImage, 'secondThumbImage.jpg', 'thirdThumbImage.jpg']); - const numOfImages = await descriptionTab.getNumberOfImages(page); + const numOfImages = await boProductsCreateTabDescriptionPage.getNumberOfImages(page); expect(numOfImages).to.equal(4); }); }); diff --git a/tests/UI/campaigns/functional/FO/hummingbird/09_productPage/02_productPage/03_changeImage.ts b/tests/UI/campaigns/functional/FO/hummingbird/09_productPage/02_productPage/03_changeImage.ts index 4798d59772a05..f9a22d0f76284 100644 --- a/tests/UI/campaigns/functional/FO/hummingbird/09_productPage/02_productPage/03_changeImage.ts +++ b/tests/UI/campaigns/functional/FO/hummingbird/09_productPage/02_productPage/03_changeImage.ts @@ -4,17 +4,17 @@ import testContext from '@utils/testContext'; // Import common tests import {deleteProductTest} from '@commonTests/BO/catalog/product'; import {enableHummingbird, disableHummingbird} from '@commonTests/BO/design/hummingbird'; +import loginCommon from '@commonTests/BO/loginBO'; // Import BO pages -import loginCommon from '@commonTests/BO/loginBO'; import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import {expect} from 'chai'; import type {BrowserContext, Page} from 'playwright'; import { boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, FakerProduct, foHummingbirdHomePage, foHummingbirdProductPage, @@ -124,11 +124,11 @@ describe('FO - Product page - Quick view : Change image', async () => { it('should add 7 images', async function () { await testContext.addContextItem(this, 'testIdentifier', 'addImage', baseContext); - await descriptionTab.addProductImages(page, + await boProductsCreateTabDescriptionPage.addProductImages(page, [newProductData.coverImage, newProductData.thumbImage, 'secondThumbImage.jpg', 'thirdThumbImage.jpg', 'fourthThumbImage.jpg', 'fifthThumbImage.jpg', 'sixthThumbImage.jpg']); - const numOfImages = await descriptionTab.getNumberOfImages(page); + const numOfImages = await boProductsCreateTabDescriptionPage.getNumberOfImages(page); expect(numOfImages).to.equal(7); }); }); diff --git a/tests/UI/campaigns/functional/WS/03_productsCRUD.ts b/tests/UI/campaigns/functional/WS/03_productsCRUD.ts index 51810df34efac..6c9dd02f408d3 100644 --- a/tests/UI/campaigns/functional/WS/03_productsCRUD.ts +++ b/tests/UI/campaigns/functional/WS/03_productsCRUD.ts @@ -13,7 +13,6 @@ import loginCommon from '@commonTests/BO/loginBO'; // Import BO pages import webservicePage from '@pages/BO/advancedParameters/webservice'; import createProductsPage from '@pages/BO/catalog/products/add'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import detailsTab from '@pages/BO/catalog/products/add/detailsTab'; import optionsTab from '@pages/BO/catalog/products/add/optionsTab'; import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; @@ -29,6 +28,7 @@ import type { import { boDashboardPage, boProductsPage, + boProductsCreateTabDescriptionPage, boProductsCreateTabShippingPage, boProductsCreateTabStocksPage, utilsPlaywright, @@ -539,11 +539,11 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'postCheckShortDescription', baseContext); const xmlValueEn = productXml.getAttributeLangValue(xmlCreate, 'description_short', '1'); - const valueEn = (await descriptionTab.getValue(page, 'summary', '1')); + const valueEn = (await boProductsCreateTabDescriptionPage.getValue(page, 'summary', '1')); expect(valueEn).to.eq(xmlValueEn); const xmlValueFr = productXml.getAttributeLangValue(xmlCreate, 'description_short', '2'); - const valueFr = (await descriptionTab.getValue(page, 'summary', '2')); + const valueFr = (await boProductsCreateTabDescriptionPage.getValue(page, 'summary', '2')); expect(valueFr).to.eq(xmlValueFr); }); @@ -551,11 +551,11 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'postCheckDescription', baseContext); const xmlValueEn = productXml.getAttributeLangValue(xmlCreate, 'description', '1'); - const valueEn = (await descriptionTab.getValue(page, 'description', '1')); + const valueEn = (await boProductsCreateTabDescriptionPage.getValue(page, 'description', '1')); expect(valueEn).to.eq(xmlValueEn); const xmlValueFr = productXml.getAttributeLangValue(xmlCreate, 'description', '2'); - const valueFr = (await descriptionTab.getValue(page, 'description', '2')); + const valueFr = (await boProductsCreateTabDescriptionPage.getValue(page, 'description', '2')); expect(valueFr).to.eq(xmlValueFr); }); @@ -563,7 +563,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'postCheckDefaultCategory', baseContext); const xmlValue = productXml.getAttributeValue(xmlCreate, 'id_category_default'); - const value = (await descriptionTab.getValue(page, 'id_category_default', '1')); + const value = (await boProductsCreateTabDescriptionPage.getValue(page, 'id_category_default', '1')); expect(value).to.eq(xmlValue); }); @@ -571,7 +571,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'postCheckManufacturer', baseContext); const xmlValue = productXml.getAttributeValue(xmlCreate, 'id_manufacturer'); - const value = (await descriptionTab.getValue(page, 'manufacturer', '1')); + const value = (await boProductsCreateTabDescriptionPage.getValue(page, 'manufacturer', '1')); expect(value).to.eq(xmlValue); }); }); @@ -1213,11 +1213,11 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'putCheckShortDescription', baseContext); const xmlValueEn = productXml.getAttributeLangValue(xmlUpdate, 'description_short', '1'); - const valueEn = (await descriptionTab.getValue(page, 'summary', '1')); + const valueEn = (await boProductsCreateTabDescriptionPage.getValue(page, 'summary', '1')); expect(valueEn).to.eq(xmlValueEn); const xmlValueFr = productXml.getAttributeLangValue(xmlUpdate, 'description_short', '2'); - const valueFr = (await descriptionTab.getValue(page, 'summary', '2')); + const valueFr = (await boProductsCreateTabDescriptionPage.getValue(page, 'summary', '2')); expect(valueFr).to.eq(xmlValueFr); }); @@ -1225,11 +1225,11 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'putCheckDescription', baseContext); const xmlValueEn = productXml.getAttributeLangValue(xmlUpdate, 'description', '1'); - const valueEn = (await descriptionTab.getValue(page, 'description', '1')); + const valueEn = (await boProductsCreateTabDescriptionPage.getValue(page, 'description', '1')); expect(valueEn).to.eq(xmlValueEn); const xmlValueFr = productXml.getAttributeLangValue(xmlUpdate, 'description', '2'); - const valueFr = (await descriptionTab.getValue(page, 'description', '2')); + const valueFr = (await boProductsCreateTabDescriptionPage.getValue(page, 'description', '2')); expect(valueFr).to.eq(xmlValueFr); }); @@ -1237,7 +1237,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'putCheckDefaultCategory', baseContext); const xmlValue = productXml.getAttributeValue(xmlUpdate, 'id_category_default'); - const value = (await descriptionTab.getValue(page, 'id_category_default', '1')); + const value = (await boProductsCreateTabDescriptionPage.getValue(page, 'id_category_default', '1')); expect(value).to.eq(xmlValue); }); @@ -1245,7 +1245,7 @@ describe('WS - Products : CRUD', async () => { await testContext.addContextItem(this, 'testIdentifier', 'putCheckManufacturer', baseContext); const xmlValue = productXml.getAttributeValue(xmlUpdate, 'id_manufacturer'); - const value = (await descriptionTab.getValue(page, 'manufacturer', '1')); + const value = (await boProductsCreateTabDescriptionPage.getValue(page, 'manufacturer', '1')); expect(value).to.eq(xmlValue); }); }); diff --git a/tests/UI/package-lock.json b/tests/UI/package-lock.json index 8a2e618d817a6..531e6e0e2c854 100644 --- a/tests/UI/package-lock.json +++ b/tests/UI/package-lock.json @@ -433,7 +433,7 @@ }, "node_modules/@prestashop-core/ui-testing": { "version": "0.0.12", - "resolved": "git+ssh://git@github.com/PrestaShop/ui-testing-library.git#9d3f2f273cbc4048400b388a66a0681b7bec6285", + "resolved": "git+ssh://git@github.com/PrestaShop/ui-testing-library.git#1404862c933c89989bb30618aca7e08844a08cbc", "license": "MIT", "dependencies": { "@faker-js/faker": "^8.3.1", @@ -8432,7 +8432,7 @@ } }, "@prestashop-core/ui-testing": { - "version": "git+ssh://git@github.com/PrestaShop/ui-testing-library.git#9d3f2f273cbc4048400b388a66a0681b7bec6285", + "version": "git+ssh://git@github.com/PrestaShop/ui-testing-library.git#1404862c933c89989bb30618aca7e08844a08cbc", "from": "@prestashop-core/ui-testing@https://github.com/PrestaShop/ui-testing-library#main", "requires": { "@faker-js/faker": "^8.3.1", diff --git a/tests/UI/pages/BO/catalog/products/add/descriptionTab.ts b/tests/UI/pages/BO/catalog/products/add/descriptionTab.ts deleted file mode 100644 index 1673737cf6088..0000000000000 --- a/tests/UI/pages/BO/catalog/products/add/descriptionTab.ts +++ /dev/null @@ -1,534 +0,0 @@ -import type {Page} from 'playwright'; - -import BOBasePage from '@pages/BO/BObasePage'; -import { - type FakerProduct, - type ProductImageInformation, -} from '@prestashop-core/ui-testing'; - -/** - * Description tab on new product V2 page, contains functions that can be used on the page - * @class - * @extends BOBasePage - */ -class DescriptionTab extends BOBasePage { - public readonly settingUpdatedMessage: string; - - private readonly descriptionTabLink: string; - - private readonly productImageDropZoneDiv: string; - - private readonly imagePreviewBlock: string; - - private readonly imageDefaultBlock: string; - - private readonly imagePreviewCover: string; - - private readonly productImage: string; - - private readonly productImageContainer: string; - - private readonly productImageDropZoneWindow: string; - - private readonly productImageDropZoneCover: string; - - private readonly productImageDropZoneBtnLang: string; - - private readonly productImageDropZoneDropdown: string; - - private readonly productImageDropZoneDropdownItem: (locale: string) => string; - - private readonly productImageDropZoneCaption: string; - - private readonly productImageDropZoneBtnSubmit: string; - - private readonly productImageDropZoneSelectAllLink: string; - - private readonly productImageDropZoneCloseButton: string; - - private readonly productImageDropZoneZoomIcon: string; - - private readonly productImageDropZoneZoomImage: string; - - private readonly productImageDropZoneCloseZoom: string; - - private readonly productImageDropZoneReplaceImageSelection: string; - - private readonly productImageDropZoneDeleteImageSelection: string; - - private readonly applyDeleteImageButton: string; - - private readonly productSummary: string; - - private readonly productSummaryTabLocale: (locale: string) => string; - - private readonly productSummaryTabContent: (locale: string) => string; - - private readonly productDescription: string; - - private readonly productDescriptionSourceCodeLink: string; - - private readonly productDescriptionTextBox: string; - - private readonly productDescriptionTextBoxSaveButton: string; - - private readonly productDescriptionTabLocale: (locale: string) => string; - - private readonly productDescriptionTabContent: (locale: string) => string; - - private readonly productDefaultCategory: string; - - private readonly addCategoryButton: string; - - private readonly addCategoryInput: string; - - private readonly applyCategoryButton: string; - - private readonly categoriesList: string; - - private readonly defaultCategorySelectButton: string; - - private readonly defaultCategoryList: (categoryRow: number) => string; - - private readonly deleteCategoryIcon: (categoryRow: number) => string; - - private readonly productManufacturer: string; - - private readonly productManufacturerSelectButton: string; - - private readonly relatedProductSelectButton: string; - - private readonly productManufacturerList: (brandRow: number) => string; - - /** - * @constructs - * Setting up texts and selectors to use on description tab - */ - constructor() { - super(); - - // Message - this.settingUpdatedMessage = 'Settings updated'; - - // Selectors in description tab - this.descriptionTabLink = '#product_description-tab-nav'; - // Image selectors - this.productImageDropZoneDiv = '#product-images-dropzone'; - this.imagePreviewBlock = `${this.productImageDropZoneDiv} div.dz-preview.openfilemanager`; - this.imageDefaultBlock = `${this.productImageDropZoneDiv} div.dz-default.openfilemanager`; - this.imagePreviewCover = `${this.productImageDropZoneDiv} div.dz-preview.is-cover`; - this.productImage = `${this.productImageDropZoneDiv} div.dz-preview.dz-image-preview.dz-complete`; - this.productImageContainer = '#product-images-container'; - this.productImageDropZoneWindow = `${this.productImageContainer} .dropzone-window`; - this.productImageDropZoneCover = `${this.productImageDropZoneWindow} #is-cover-checkbox`; - this.productImageDropZoneBtnLang = `${this.productImageDropZoneWindow} #product_dropzone_lang`; - this.productImageDropZoneDropdown = `${this.productImageDropZoneWindow} .locale-dropdown-menu.show`; - this.productImageDropZoneDropdownItem = (locale: string) => `${this.productImageDropZoneDropdown} span` - + `[data-locale="${locale}"]`; - this.productImageDropZoneCaption = `${this.productImageDropZoneWindow} #caption-textarea`; - this.productImageDropZoneBtnSubmit = `${this.productImageDropZoneWindow} button.save-image-settings`; - this.productImageDropZoneSelectAllLink = `${this.productImageDropZoneWindow} p.dropzone-window-select`; - this.productImageDropZoneCloseButton = `${this.productImageDropZoneWindow} div.dropzone-window-header-right` - + ' i[data-original-title="Close window"]'; - this.productImageDropZoneZoomIcon = `${this.productImageDropZoneWindow} div.dropzone-window-header-right` - + ' i[data-original-title="Zoom on selection"]'; - this.productImageDropZoneZoomImage = `${this.productImageContainer} div.pswp--open.pswp--visible`; - this.productImageDropZoneCloseZoom = `${this.productImageContainer} button.pswp__button--close`; - this.productImageDropZoneReplaceImageSelection = `${this.productImageContainer} div.dropzone-window-header-right` - + ' i[data-original-title="Replace selection"]'; - this.productImageDropZoneDeleteImageSelection = `${this.productImageContainer} div.dropzone-window-header-right` - + ' i[data-original-title="Delete selection"]'; - this.applyDeleteImageButton = `${this.productImageContainer} footer button.btn-primary`; - // Description & summary selectors - this.productSummary = '#product_description_description_short'; - this.productSummaryTabLocale = (locale: string) => `${this.productSummary} a[data-locale="${locale}"]`; - this.productSummaryTabContent = (locale: string) => `${this.productSummary} div.panel[data-locale="${locale}"]`; - this.productDescription = '#product_description_description'; - this.productDescriptionTabLocale = (locale: string) => `${this.productDescription} a[data-locale="${locale}"]`; - this.productDescriptionTabContent = (locale: string) => `${this.productDescription} div.panel[data-locale="${locale}"]`; - this.productDescriptionSourceCodeLink = `${this.productDescription} div.mce-widget[aria-label='Source code']`; - this.productDescriptionTextBox = '.mce-textbox'; - this.productDescriptionTextBoxSaveButton = '.mce-window div.mce-first button[type="button"]'; - // Categories selectors - this.productDefaultCategory = '#product_description_categories_default_category_id'; - this.addCategoryButton = '#product_description_categories_add_categories_btn'; - this.addCategoryInput = '#ps-select-product-category'; - this.applyCategoryButton = '#category_tree_selector_apply_btn'; - this.categoriesList = '#product_description_categories_product_categories'; - this.defaultCategorySelectButton = '#select2-product_description_categories_default_category_id-container'; - this.defaultCategoryList = (categoryRow: number) => '#select2-product_description_categories_default_category_id-results' - + ` li:nth-child(${categoryRow})`; - this.deleteCategoryIcon = (categoryRow: number) => `#product_description_categories_product_categories_${categoryRow}_name` - + ' + a.pstaggerClosingCross:not(.d-none)'; - // Brand selectors - this.productManufacturer = '#product_description_manufacturer'; - this.productManufacturerSelectButton = '#select2-product_description_manufacturer-container'; - this.productManufacturerList = (BrandRow: number) => '#select2-product_description_manufacturer-results' - + ` li:nth-child(${BrandRow})`; - // Related product selectors - this.relatedProductSelectButton = '#product_description_related_products_search_input'; - } - - /* - Methods - */ - - /** - * Get Number of images to set on the product - * @param page {Page} Browser tab - * @returns {Promise} - */ - async getNumberOfImages(page: Page): Promise { - return page.locator(this.productImage).count(); - } - - /** - * Upload product image - * @param page {Page} Browser tab - * @param imagesPaths {Array} Paths of the images to add to the product - * @returns {Promise} - */ - async uploadProductImages(page: Page, imagesPaths: any[] = []): Promise { - const filteredImagePaths = imagesPaths.filter((el) => el !== null); - - if (filteredImagePaths !== null && filteredImagePaths.length !== 0) { - const imagePreviewBlock = await page.locator(this.imagePreviewBlock).isVisible({timeout: 5000}); - await this.uploadOnFileChooser( - page, - imagePreviewBlock ? this.imagePreviewBlock : this.imageDefaultBlock, - filteredImagePaths, - ); - } - } - - /** - * Add product images - * @param page {Page} Browser tab - * @param imagesPaths {Array} Paths of the images to add to the product - * @returns {Promise} - */ - async addProductImages(page: Page, imagesPaths: any[] = []): Promise { - const filteredImagePaths = imagesPaths.filter((el) => el !== null); - - if (filteredImagePaths !== null && filteredImagePaths.length !== 0) { - const numberOfImages = await this.getNumberOfImages(page); - const imagePreviewBlock = await page.locator(this.imagePreviewBlock).isVisible({timeout: 5000}); - await this.uploadOnFileChooser( - page, - imagePreviewBlock ? this.imagePreviewBlock : this.imageDefaultBlock, - filteredImagePaths, - ); - - await this.waitForVisibleSelector(page, this.imagePreviewBlock); - await this.waitForVisibleLocator(page.locator(this.productImage).nth(numberOfImages + filteredImagePaths.length - 1)); - } - } - - /** - * Get Product Image Information - * @param page {Page} Browser tab - * @param numImage {number} Number of the image - * @returns {Promise} - */ - async getProductImageInformation(page: Page, numImage: number): Promise { - await page.locator(this.productImage).nth(numImage - 1).click(); - - const isCover = await page.locator(this.productImageDropZoneCover).isChecked(); - - await page.locator(this.productImageDropZoneBtnLang).click(); - await this.elementVisible(page, this.productImageDropZoneDropdown); - await page.locator(this.productImageDropZoneDropdownItem('en')).click(); - const captionEN = await page - .locator(this.productImageDropZoneCaption) - .evaluate((node: HTMLTextAreaElement): string => node.value); - - await page.locator(this.productImageDropZoneBtnLang).click(); - await this.elementVisible(page, this.productImageDropZoneDropdown); - await page.locator(this.productImageDropZoneDropdownItem('fr')).click(); - const captionFR = await page - .locator(this.productImageDropZoneCaption) - .evaluate((node: HTMLTextAreaElement): string => node.value); - - await page.locator(this.productImageDropZoneCloseButton).click(); - - return { - id: parseInt(await page.locator(this.productImage).nth(numImage - 1).getAttribute('data-id') ?? '0', 10), - isCover, - position: numImage, - caption: { - en: captionEN, - fr: captionFR, - }, - }; - } - - /** - * Set Product Image Information - * @param page {Page} Browser tab - * @param numImage {number} Number of the image - * @param useAsCoverImage {boolean|undefined} Use as cover image - * @param captionEn {string|undefined} Caption in English - * @param captionFr {string|undefined} Caption in French - * @param selectAll {boolean|undefined} Select all - * @param toSave {boolean} True if we need to save - * @param toClose {boolean} True if we need to close - * @returns {Promise} - */ - async setProductImageInformation( - page: Page, - numImage: number, - useAsCoverImage: boolean | undefined, - captionEn: string | undefined, - captionFr: string | undefined, - selectAll: boolean | undefined = undefined, - toSave: boolean = true, - toClose: boolean = false, - ): Promise { - let returnValue: string|null = null; - // Select the image - await page.locator(this.productImage).nth(numImage - 1).click(); - - if (selectAll) { - await page.locator(this.productImageDropZoneSelectAllLink).click(); - } - - if (useAsCoverImage) { - await this.setCheckedWithIcon(page, this.productImageDropZoneCover, useAsCoverImage); - } - if (captionEn) { - await page.locator(this.productImageDropZoneBtnLang).click(); - await this.elementVisible(page, this.productImageDropZoneDropdown); - - await page.locator(this.productImageDropZoneDropdownItem('en')).click(); - await this.setValue(page, this.productImageDropZoneCaption, captionEn); - } - if (captionFr) { - await page.locator(this.productImageDropZoneBtnLang).click(); - await this.elementVisible(page, this.productImageDropZoneDropdown); - - await page.locator(this.productImageDropZoneDropdownItem('fr')).click(); - await this.setValue(page, this.productImageDropZoneCaption, captionFr); - } - - if (toSave) { - await page.locator(this.productImageDropZoneBtnSubmit).click(); - - returnValue = await this.getGrowlMessageContent(page); - } - if (toClose) { - await page.locator(this.productImageDropZoneCloseButton).click(); - } - return returnValue; - } - - /** - * Click on magnifying glass - * @param page {Page} Browser tab - * @returns {Promise} - */ - async clickOnMagnifyingGlass(page: Page): Promise { - await page.locator(this.productImageDropZoneZoomIcon).click(); - - return this.elementVisible(page, this.productImageDropZoneZoomImage, 1000); - } - - /** - * Close image zoom - * @param page {Page} Browser tab - * @returns {Promise} - */ - async closeImageZoom(page: Page): Promise { - await page.locator(this.productImageDropZoneCloseZoom).click(); - - return this.elementNotVisible(page, this.productImageDropZoneZoomImage, 1000); - } - - /** - * Replace image selection - * @param page {Page} Browser tab - * @param image {string} Browser tab - * @returns {Promise} - */ - async replaceImageSelection(page: Page, image: string): Promise { - await this.uploadOnFileChooser(page, this.productImageDropZoneReplaceImageSelection, [image]); - await page.locator(this.productImageDropZoneBtnSubmit).click(); - - return this.getGrowlMessageContent(page); - } - - /** - * Delete image - * @param page {Page} Browser tab - * @returns {Promise} - */ - async deleteImage(page: Page): Promise { - await this.closeGrowlMessage(page); - await page.locator(this.productImageDropZoneDeleteImageSelection).click(); - await page.locator(this.applyDeleteImageButton).click(); - - return this.getGrowlMessageContent(page); - } - - /** - * Set value on tinyMce textarea - * @param page {Page} Browser tab - * @param selector {string} Value of selector to use - * @param value {string} Text to set on tinymce input - * @returns {Promise} - */ - async setValueOnTinymceInput(page: Page, selector: string, value: string): Promise { - // Select all - await page.locator(`${selector} .mce-edit-area`).click({clickCount: 3}); - - // Delete all text - await page.keyboard.press('Backspace'); - - // Fill the text - await page.keyboard.type(value); - } - - /** - * Set description - * @param page {Page} Browser tab - * @param description {string} Data to set in description textarea - */ - async setDescription(page: Page, description: string): Promise { - await page.locator(this.productDescriptionTabLocale('en')).click(); - await this.elementVisible(page, `${this.productDescriptionTabLocale('en')}.active`); - await this.setValueOnTinymceInput(page, this.productDescriptionTabContent('en'), description); - } - - /** - * Set product description - * @param page {Page} Browser tab - * @param productData {FakerProduct} Data to set in description form - * @returns {Promise} - */ - async setProductDescription(page: Page, productData: FakerProduct): Promise { - await this.waitForSelectorAndClick(page, this.descriptionTabLink); - - await this.addProductImages(page, [productData.coverImage, productData.thumbImage]); - - await page.locator(this.productSummaryTabLocale('en')).click(); - await this.elementVisible(page, `${this.productSummaryTabLocale('en')}.active`); - await this.setValueOnTinymceInput(page, this.productSummaryTabContent('en'), productData.summary); - - await this.setDescription(page, productData.description); - } - - /** - * Set iframe in description - * @param page {Page} Browser tab - * @param description {string} Data to set in the description - */ - async setIframeInDescription(page: Page, description: string): Promise { - await this.waitForSelectorAndClick(page, this.descriptionTabLink); - await page.locator(this.productDescriptionSourceCodeLink).first().click(); - await this.setValue(page, this.productDescriptionTextBox, description); - await page.locator(this.productDescriptionTextBoxSaveButton).click(); - } - - /** - * Get Product ID Image Cover - * @param page {Page} Browser tab - * @returns {Promise} - */ - async getProductIDImageCover(page: Page): Promise { - return parseInt(await this.getAttributeContent(page, this.imagePreviewCover, 'data-id'), 10); - } - - /** - * Returns the value of a form element - * @param page {Page} - * @param inputName {string} - * @param languageId {string | undefined} - */ - async getValue(page: Page, inputName: string, languageId?: string): Promise { - switch (inputName) { - case 'description': - return this.getTextContent(page, `${this.productDescription}_${languageId}`, false); - case 'id_category_default': - return page.locator(this.productDefaultCategory).evaluate((node: HTMLSelectElement) => node.value); - case 'manufacturer': - return page.locator(this.productManufacturer).evaluate((node: HTMLSelectElement) => node.value); - case 'summary': - return this.getTextContent(page, `${this.productSummary}_${languageId}`, false); - default: - throw new Error(`Input ${inputName} was not found`); - } - } - - /** - * Add new category - * @param page {Page} Browser tab - * @param categories {string[]} Browser tab - * @returns {Promise} - */ - async addNewCategory(page: Page, categories: string[]): Promise { - await page.locator(this.addCategoryButton).click(); - await this.waitForVisibleSelector(page, this.addCategoryInput); - for (let i: number = 0; i < categories.length; i++) { - await page.locator(this.addCategoryInput).pressSequentially(categories[i]); - await page.keyboard.press('ArrowDown'); - await page.keyboard.press('Enter'); - await page.waitForTimeout(1000); - } - - await this.waitForSelectorAndClick(page, this.applyCategoryButton); - } - - /** - * Get selected categories - * @param page {Page} Browser tab - * @returns {Promise} - */ - async getSelectedCategories(page: Page): Promise { - return this.getTextContent(page, this.categoriesList); - } - - /** - * Get selected categories - * @param page {Page} Browser tab - * @param categoryRow {number} Category row - * @returns {Promise} - */ - async chooseDefaultCategory(page: Page, categoryRow: number): Promise { - await page.locator(this.defaultCategorySelectButton).click(); - await page.locator(this.defaultCategoryList(categoryRow)).click(); - } - - /** - * Is delete category icon visible - * @param page {Page} Browser tab - * @param categoryRow {number} Category row - * @returns {Promise} - */ - async isDeleteCategoryIconVisible(page: Page, categoryRow: number): Promise { - return (await page.locator(this.deleteCategoryIcon(categoryRow)).count()) !== 0; - } - - /** - * Is delete category icon visible - * @param page {Page} Browser tab - * @param brandRow {number} Brand row - * @returns {Promise} - */ - async chooseBrand(page: Page, brandRow: number): Promise { - await page.locator(this.productManufacturerSelectButton).click(); - await page.locator(this.productManufacturerList(brandRow)).click(); - } - - /** - * Add related product - * @param page {Page} Browser tab - * @param productName {string} Product name - * @returns {Promise} - */ - async addRelatedProduct(page: Page, productName: string): Promise { - await page.locator(this.relatedProductSelectButton).fill(productName); - await page.keyboard.press('ArrowDown'); - await page.keyboard.press('Enter'); - } -} - -export default new DescriptionTab(); diff --git a/tests/UI/pages/BO/catalog/products/add/index.ts b/tests/UI/pages/BO/catalog/products/add/index.ts index df515372cb0b7..207491663ec06 100644 --- a/tests/UI/pages/BO/catalog/products/add/index.ts +++ b/tests/UI/pages/BO/catalog/products/add/index.ts @@ -1,12 +1,12 @@ // Import pages import BOBasePage from '@pages/BO/BObasePage'; -import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab'; import detailsTab from '@pages/BO/catalog/products/add/detailsTab'; import pricingTab from '@pages/BO/catalog/products/add/pricingTab'; import packTab from '@pages/BO/catalog/products/add/packTab'; import type {Frame, Page} from 'playwright'; import { + boProductsCreateTabDescriptionPage, boProductsCreateTabShippingPage, boProductsCreateTabStocksPage, boProductsCreateTabVirtualProductPage, @@ -353,7 +353,7 @@ class CreateProduct extends BOBasePage { // Set status await this.setProductStatus(page, productData.status); // Set description - await descriptionTab.setProductDescription(page, productData); + await boProductsCreateTabDescriptionPage.setProductDescription(page, productData); // Set name await this.setProductName(page, productData.name, 'en'); await this.setProductName(page, productData.nameFR, 'fr');