From d6103ae757d5417b65c62a3ce2e7842bf9724319 Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Thu, 18 Jul 2024 09:31:25 +0200 Subject: [PATCH] Add some fixes --- .github/workflows/ui-test/nightly.json | 39 ++++++++ .github/workflows/ui-test/sanity.json | 48 ---------- .../02_productsBO/01_filterProducts.spec.ts | 53 +++++++---- .../02_CRUDStandardProduct.spec.ts | 2 +- .../03_CRUDProductWithCombinations.spec.ts | 16 ++-- .../04_CRUDVirtualProduct.spec.ts | 2 +- .../02_productsBO/05_deleteProduct.spec.ts | 2 +- .../06_deleteProductsWithBulkActions.spec.ts | 2 +- .../03_catalogFO/01_filterProducts.spec.ts | 39 +++++--- .../03_catalogFO/02_checkProduct.spec.ts | 21 +++-- .../sanity/04_cartFO/01_editCheckCart.spec.ts | 88 ++++++++++++++----- .../05_checkoutFO/01_orderProduct.spec.ts | 37 ++++++-- .../shopVersion/01_CheckVersion.spec.ts | 6 +- tests/UI/docker-compose.yml | 2 +- 14 files changed, 232 insertions(+), 125 deletions(-) diff --git a/.github/workflows/ui-test/nightly.json b/.github/workflows/ui-test/nightly.json index 1b86ca3f6..f41ba2d24 100644 --- a/.github/workflows/ui-test/nightly.json +++ b/.github/workflows/ui-test/nightly.json @@ -1,5 +1,44 @@ { "include": [ + { + "comment": "1.7.2.0 ~ 1.7.2.5 -> 1.7.8.11 PHP 7.1 online" + }, + { + "PS_VERSION_START": "1.7.2.0", + "PS_VERSION_END": "1.7.8.11", + "PHP_VERSION": "7.1", + "UPGRADE_CHANNEL": "online" + }, + { + "PS_VERSION_START": "1.7.2.1", + "PS_VERSION_END": "1.7.8.11", + "PHP_VERSION": "7.1", + "UPGRADE_CHANNEL": "online" + }, + { + "PS_VERSION_START": "1.7.2.2", + "PS_VERSION_END": "1.7.8.11", + "PHP_VERSION": "7.1", + "UPGRADE_CHANNEL": "online" + }, + { + "PS_VERSION_START": "1.7.2.3", + "PS_VERSION_END": "1.7.8.11", + "PHP_VERSION": "7.1", + "UPGRADE_CHANNEL": "online" + }, + { + "PS_VERSION_START": "1.7.2.4", + "PS_VERSION_END": "1.7.8.11", + "PHP_VERSION": "7.1", + "UPGRADE_CHANNEL": "online" + }, + { + "PS_VERSION_START": "1.7.2.5", + "PS_VERSION_END": "1.7.8.11", + "PHP_VERSION": "7.1", + "UPGRADE_CHANNEL": "online" + }, { "comment": "1.7.3.0 ~ 1.7.3.4 -> 1.7.8.11 PHP 7.1" }, diff --git a/.github/workflows/ui-test/sanity.json b/.github/workflows/ui-test/sanity.json index e94e2c4b9..2a839ef15 100644 --- a/.github/workflows/ui-test/sanity.json +++ b/.github/workflows/ui-test/sanity.json @@ -1,54 +1,6 @@ { "include": [ { - "comment": "1.7.8 ~ minor PHP 7.4" - "comment": "1.7.2 ~ minor PHP 7.1" - }, - { - "PS_VERSION_START": "1.7.2.0", - "PS_VERSION_END": "1.7.8.11", - "UPGRADE_CHANNEL": "minor", - "PHP_VERSION": "7.1", - "IMG_DOCKER": "1.7.2.0" - }, - { - "PS_VERSION_START": "1.7.2.1", - "PS_VERSION_END": "1.7.8.11", - "UPGRADE_CHANNEL": "minor", - "PHP_VERSION": "7.1", - "IMG_DOCKER": "1.7.2.1" - }, - { - "PS_VERSION_START": "1.7.2.2", - "PS_VERSION_END": "1.7.8.11", - "UPGRADE_CHANNEL": "minor", - "PHP_VERSION": "7.1", - "IMG_DOCKER": "1.7.2.2" - }, - { - "PS_VERSION_START": "1.7.2.3", - "PS_VERSION_END": "1.7.8.11", - "UPGRADE_CHANNEL": "minor", - "PHP_VERSION": "7.1", - "IMG_DOCKER": "1.7.2.3" - }, - { - "PS_VERSION_START": "1.7.2.4", - "PS_VERSION_END": "1.7.8.11", - "UPGRADE_CHANNEL": "minor", - "PHP_VERSION": "7.1", - "IMG_DOCKER": "1.7.2.4" - }, - { - "PS_VERSION_START": "1.7.2.5", - "PS_VERSION_END": "1.7.8.11", - "UPGRADE_CHANNEL": "minor", - "PHP_VERSION": "7.1", - "IMG_DOCKER": "1.7.2.5" - }, - { - "comment": "1.7.8 ~ minor PHP 7.2 ~ 7.4" - "comment": "1.7.6.0 -> 1.7.8.11 PHP 7.1" "comment": "1.7.6.0 -> 1.7.8.11 PHP 7.1 online" }, { diff --git a/tests/UI/campaigns/sanity/02_productsBO/01_filterProducts.spec.ts b/tests/UI/campaigns/sanity/02_productsBO/01_filterProducts.spec.ts index c9bbaa275..66f506622 100755 --- a/tests/UI/campaigns/sanity/02_productsBO/01_filterProducts.spec.ts +++ b/tests/UI/campaigns/sanity/02_productsBO/01_filterProducts.spec.ts @@ -121,21 +121,16 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name, expect(isVisible, 'Reset button is visible!').toEqual(false); }); - if (semver.lt(psVersion, '8.1.0') || isProductPageV1) { - test('should get the number of products', async () => { - await utilsTest.addContextItem(test.info(), 'testIdentifier', 'getNumberOfProduct', baseContext); + test('should get the number of products', async () => { + await utilsTest.addContextItem(test.info(), 'testIdentifier', 'getNumberOfProduct', baseContext); + if (semver.lt(psVersion, '8.1.0') || isProductPageV1) { numberOfProducts = await boProductsPage.getNumberOfProductsFromList(page); - expect(numberOfProducts).toBeGreaterThan(0); - }); - } else { - test('should get number of products', async () => { - await utilsTest.addContextItem(test.info(), 'testIdentifier', 'getNumberOfProduct', baseContext); - + } else { numberOfProducts = await boProductsPage.getNumberOfProductsFromHeader(page); - expect(numberOfProducts).toBeGreaterThan(0); - }); - } + } + expect(numberOfProducts).toBeGreaterThan(0); + }); [ { @@ -143,6 +138,8 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name, identifier: 'filterIDMinMax', filterBy: 'id_product', filterValue: {min: 5, max: 10}, + // For PS version <= 1.7.2 + oldFilterValue: {min: 3, max: 7}, filterType: 'input', }, }, @@ -151,6 +148,8 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name, identifier: 'filterName', filterBy: 'product_name', filterValue: dataProducts.demo_14.name, + // For PS version <= 1.7.2 + oldFilterValue: dataProducts.old_demo_4.name, filterType: 'input', }, }, @@ -159,6 +158,8 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name, identifier: 'filterReference', filterBy: 'reference', filterValue: dataProducts.demo_14.reference, + // For PS version <= 1.7.2 + oldFilterValue: dataProducts.old_demo_7.reference, filterType: 'input', }, }, @@ -167,6 +168,8 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name, identifier: 'filterCategory', filterBy: 'category', filterValue: dataCategories.art.name, + // For PS version <= 1.7.2 + oldFilterValue: dataProducts.old_demo_3.category, filterType: 'input', }, }, @@ -175,6 +178,8 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name, identifier: 'filterPriceMinMax', filterBy: 'price', filterValue: {min: 5, max: 10}, + // For PS version <= 1.7.2 + oldFilterValue: {min: 20, max: 30}, filterType: 'input', }, }, @@ -183,6 +188,8 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name, identifier: 'filterQuantityMinMax', filterBy: 'quantity', filterValue: {min: 1300, max: 1500}, + // For PS version <= 1.7.2 + oldFilterValue: {min: 900, max: 1500}, filterType: 'input', }, }, @@ -191,6 +198,8 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name, identifier: 'filterStatus', filterBy: 'active', filterValue: 'Yes', + // For PS version <= 1.7.2 + oldFilterValue: 'Yes', filterType: 'select', }, }, @@ -198,10 +207,20 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name, test(`should filter list by '${tst.args.filterBy}' and check result`, async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', `${tst.args.identifier}`, baseContext); + let filterValue: any = ''; + + if (numberOfProducts > 7) { + // For PS version > 1.7.2 + filterValue = tst.args.filterValue; + } else { + // For PS version <= 1.7.2 + filterValue = tst.args.oldFilterValue; + } + if (semver.lt(psVersion, '8.1.0') && tst.args.filterBy === 'active') { await boProductsPage.filterProducts(page, tst.args.filterBy, 'Active', tst.args.filterType); } else { - await boProductsPage.filterProducts(page, tst.args.filterBy, tst.args.filterValue, tst.args.filterType); + await boProductsPage.filterProducts(page, tst.args.filterBy, filterValue, tst.args.filterType); } const numberOfProductsAfterFilter = await boProductsPage.getNumberOfProductsFromList(page); @@ -214,13 +233,13 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name, for (let i = 1; i <= numberOfProductsAfterFilter; i++) { const textColumn = await boProductsPage.getTextColumn(page, tst.args.filterBy, i); - if (typeof tst.args.filterValue !== 'string') { - expect(textColumn).toBeGreaterThanOrEqual(tst.args.filterValue.min); - expect(textColumn).toBeLessThanOrEqual(tst.args.filterValue.max); + if (typeof filterValue !== 'string') { + expect(textColumn).toBeGreaterThanOrEqual(filterValue.min); + expect(textColumn).toBeLessThanOrEqual(filterValue.max); } else if (tst.args.filterBy === 'active') { expect(textColumn).toEqual(true); } else { - expect(textColumn).toContain(tst.args.filterValue); + expect(textColumn).toContain(filterValue); } } }); diff --git a/tests/UI/campaigns/sanity/02_productsBO/02_CRUDStandardProduct.spec.ts b/tests/UI/campaigns/sanity/02_productsBO/02_CRUDStandardProduct.spec.ts index 000384429..a4ab728f3 100755 --- a/tests/UI/campaigns/sanity/02_productsBO/02_CRUDStandardProduct.spec.ts +++ b/tests/UI/campaigns/sanity/02_productsBO/02_CRUDStandardProduct.spec.ts @@ -90,7 +90,7 @@ test.describe('BO - Catalog - Products : CRUD standard product', async () => { }); // @todo : https://github.com/PrestaShop/PrestaShop/issues/36097 - if (semver.lte(psVersion, '8.1.6')) { + if (semver.lte(psVersion, '8.1.6') && semver.gte(psVersion, '7.3.0')) { test('should close the menu', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'closeMenu', baseContext); diff --git a/tests/UI/campaigns/sanity/02_productsBO/03_CRUDProductWithCombinations.spec.ts b/tests/UI/campaigns/sanity/02_productsBO/03_CRUDProductWithCombinations.spec.ts index 1bb29da49..e0350bd42 100755 --- a/tests/UI/campaigns/sanity/02_productsBO/03_CRUDProductWithCombinations.spec.ts +++ b/tests/UI/campaigns/sanity/02_productsBO/03_CRUDProductWithCombinations.spec.ts @@ -64,7 +64,7 @@ test.describe('BO - Catalog - Products : CRUD product with combinations', async }, { name: 'size', - values: ['L', 'XL'], + values: ['L'], }, ], }); @@ -103,7 +103,7 @@ test.describe('BO - Catalog - Products : CRUD product with combinations', async }); // @todo : https://github.com/PrestaShop/PrestaShop/issues/36097 - if (semver.lte(psVersion, '8.1.6')) { + if (semver.lte(psVersion, '8.1.6') && semver.gte(psVersion, '7.3.0')) { test('should close the menu', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'closeMenu', baseContext); @@ -150,7 +150,7 @@ test.describe('BO - Catalog - Products : CRUD product with combinations', async }); } - test('should create combinations and check generate combinations button', async () => { + test('should create combinations', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'createCombinations', baseContext); const textResult = await boProductsCreateTabCombinationsPage.setProductAttributes( @@ -160,6 +160,8 @@ test.describe('BO - Catalog - Products : CRUD product with combinations', async if (semver.gte(psVersion, '8.1.0')) { expect(textResult).toEqual('Generate 2 combinations'); + } else if (semver.lte(psVersion, '7.2.1')) { + expect(textResult).toEqual(boProductsCreatePage.successfulUpdateMessage); } else { expect(textResult).toEqual(boProductsCreatePage.successfulUpdateMessage); } @@ -248,7 +250,9 @@ test.describe('BO - Catalog - Products : CRUD product with combinations', async ); if (semver.gte(psVersion, '8.1.0')) { - expect(textResult).toEqual('Generate 6 combinations'); + expect(textResult).toEqual('Generate 3 combinations'); + } else if (semver.lte(psVersion, '7.2.1')) { + expect(textResult).toEqual(boProductsCreatePage.successfulUpdateMessage); } else { expect(textResult).toEqual(boProductsCreatePage.successfulUpdateMessage); } @@ -259,7 +263,7 @@ test.describe('BO - Catalog - Products : CRUD product with combinations', async await utilsTest.addContextItem(test.info(), 'testIdentifier', 'generateCombinations2', baseContext); const successMessage = await boProductsCreateTabCombinationsPage.generateCombinations(page); - expect(successMessage).toEqual('Successfully generated 6 combinations.'); + expect(successMessage).toEqual('Successfully generated 3 combinations.'); }); test('should check that combinations generation modal is closed', async () => { @@ -309,7 +313,7 @@ test.describe('BO - Catalog - Products : CRUD product with combinations', async }); test.describe('Delete product', async () => { - test('should go back to BO to delete product', async () => { + test('should go back to BO', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'goBackToBOToDeleteProduct', baseContext); // Go back to BO diff --git a/tests/UI/campaigns/sanity/02_productsBO/04_CRUDVirtualProduct.spec.ts b/tests/UI/campaigns/sanity/02_productsBO/04_CRUDVirtualProduct.spec.ts index 3fd302998..66746745f 100755 --- a/tests/UI/campaigns/sanity/02_productsBO/04_CRUDVirtualProduct.spec.ts +++ b/tests/UI/campaigns/sanity/02_productsBO/04_CRUDVirtualProduct.spec.ts @@ -83,7 +83,7 @@ test.describe('BO - Catalog - Products : CRUD virtual product', async () => { }); // @todo : https://github.com/PrestaShop/PrestaShop/issues/36097 - if (semver.lte(psVersion, '8.1.6')) { + if (semver.lte(psVersion, '8.1.6') && semver.gte(psVersion, '7.3.0')) { test('should close the menu', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'closeMenu', baseContext); diff --git a/tests/UI/campaigns/sanity/02_productsBO/05_deleteProduct.spec.ts b/tests/UI/campaigns/sanity/02_productsBO/05_deleteProduct.spec.ts index 585c85e44..8998cb39c 100755 --- a/tests/UI/campaigns/sanity/02_productsBO/05_deleteProduct.spec.ts +++ b/tests/UI/campaigns/sanity/02_productsBO/05_deleteProduct.spec.ts @@ -71,7 +71,7 @@ test.describe('BO - Catalog - Products : Delete product', async () => { }); // @todo : https://github.com/PrestaShop/PrestaShop/issues/36097 - if (semver.lte(psVersion, '8.1.6')) { + if (semver.lte(psVersion, '8.1.6') && semver.gte(psVersion, '7.3.0')) { test('should close the menu', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'closeMenu', baseContext); diff --git a/tests/UI/campaigns/sanity/02_productsBO/06_deleteProductsWithBulkActions.spec.ts b/tests/UI/campaigns/sanity/02_productsBO/06_deleteProductsWithBulkActions.spec.ts index c8f81051e..c5885ea46 100755 --- a/tests/UI/campaigns/sanity/02_productsBO/06_deleteProductsWithBulkActions.spec.ts +++ b/tests/UI/campaigns/sanity/02_productsBO/06_deleteProductsWithBulkActions.spec.ts @@ -81,7 +81,7 @@ test.describe('BO - Catalog - Products : Delete products with bulk actions', asy }); // @todo : https://github.com/PrestaShop/PrestaShop/issues/36097 - if (semver.lte(psVersion, '8.1.6')) { + if (semver.lte(psVersion, '8.1.6') && semver.gte(psVersion, '7.3.0')) { test('should close the menu', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'closeMenu', baseContext); diff --git a/tests/UI/campaigns/sanity/03_catalogFO/01_filterProducts.spec.ts b/tests/UI/campaigns/sanity/03_catalogFO/01_filterProducts.spec.ts index 1083a292e..1e3f6c31f 100755 --- a/tests/UI/campaigns/sanity/03_catalogFO/01_filterProducts.spec.ts +++ b/tests/UI/campaigns/sanity/03_catalogFO/01_filterProducts.spec.ts @@ -11,7 +11,9 @@ import { import { test, expect, Page, BrowserContext, } from '@playwright/test'; +import semver from 'semver'; +const psVersion = utilsTest.getPSVersion(); const baseContext: string = 'sanity_catalogFO_filterProducts'; /* @@ -52,24 +54,39 @@ test.describe('FO - Catalog : Filter Products by categories in Home page', async expect(allProductsNumber).toBeGreaterThan(0); }); - test('should filter products by the category \'Accessories\' and check result', async () => { - await utilsTest.addContextItem(test.info(), 'testIdentifier', 'FilterProductByCategory', baseContext); + if (semver.gte(psVersion, '7.3.0')) { + test('should filter products by category and check result', async () => { + await utilsTest.addContextItem(test.info(), 'testIdentifier', 'FilterProductByCategory', baseContext); - await foClassicCategoryPage.goToCategory(page, dataCategories.accessories.id); + if (allProductsNumber > 7) { + await foClassicCategoryPage.goToCategory(page, dataCategories.accessories.id); - const pageTitle = await foClassicCategoryPage.getPageTitle(page); - expect(pageTitle).toEqual(dataCategories.accessories.name); + const pageTitle = await foClassicCategoryPage.getPageTitle(page); + expect(pageTitle).toEqual(dataCategories.accessories.name); - const numberOfProducts = await foClassicCategoryPage.getNumberOfProducts(page); - expect(numberOfProducts).toBeLessThan(allProductsNumber); - }); + const numberOfProducts = await foClassicCategoryPage.getNumberOfProducts(page); + expect(numberOfProducts).toBeLessThan(allProductsNumber); + } else { + await foClassicCategoryPage.goToCategory(page, dataCategories.oldWomen.id); - test('should filter products by the subcategory \'Stationery\' and check result', async () => { + const pageTitle = await foClassicCategoryPage.getPageTitle(page); + expect(pageTitle).toEqual(dataCategories.oldWomen.name); + + const numberOfProducts = await foClassicCategoryPage.getNumberOfProducts(page); + expect(numberOfProducts).toEqual(allProductsNumber); + } + }); + } + + test('should filter products by subcategory and check result', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'FilterProductBySubCategory', baseContext); await foClassicCategoryPage.reloadPage(page); - await foClassicCategoryPage.goToSubCategory(page, dataCategories.accessories.id, dataCategories.stationery.id); - + if (allProductsNumber > 7) { + await foClassicCategoryPage.goToSubCategory(page, dataCategories.accessories.id, dataCategories.stationery.id); + } else { + await foClassicCategoryPage.goToSubCategory(page, dataCategories.oldWomen.id, dataCategories.eveningDresses.id); + } const numberOfProducts = await foClassicCategoryPage.getNumberOfProducts(page); expect(numberOfProducts).toBeLessThan(allProductsNumber); }); diff --git a/tests/UI/campaigns/sanity/03_catalogFO/02_checkProduct.spec.ts b/tests/UI/campaigns/sanity/03_catalogFO/02_checkProduct.spec.ts index ef754db04..1f1e656b3 100755 --- a/tests/UI/campaigns/sanity/03_catalogFO/02_checkProduct.spec.ts +++ b/tests/UI/campaigns/sanity/03_catalogFO/02_checkProduct.spec.ts @@ -46,17 +46,26 @@ test.describe('FO - Catalog : Check the Product page', async () => { await foClassicHomePage.goToProductPage(page, 1); const pageTitle = await foClassicProductPage.getPageTitle(page); - expect(pageTitle).toContain(dataProducts.demo_1.name); + expect(pageTitle).toBeDefined(); }); test('should check the product page', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkProductPage', baseContext); const result = await foClassicProductPage.getProductInformation(page); - await Promise.all([ - expect(result.name).toEqual(dataProducts.demo_1.name), - expect(result.price).toEqual(dataProducts.demo_1.finalPrice), - expect(result.description).toContain(dataProducts.demo_1.description), - ]); + + if (result.name === dataProducts.demo_1.name) { + await Promise.all([ + expect(result.name).toEqual(dataProducts.demo_1.name), + expect(result.price).toEqual(dataProducts.demo_1.finalPrice), + expect(result.description).toContain(dataProducts.demo_1.description), + ]); + } else { + await Promise.all([ + expect(result.name).toEqual(dataProducts.old_demo_1.name), + expect(result.price).toEqual(dataProducts.old_demo_1.finalPrice), + expect(result.description).toContain(dataProducts.old_demo_1.description), + ]); + } }); }); diff --git a/tests/UI/campaigns/sanity/04_cartFO/01_editCheckCart.spec.ts b/tests/UI/campaigns/sanity/04_cartFO/01_editCheckCart.spec.ts index 85a5d8abb..7a81e15a1 100755 --- a/tests/UI/campaigns/sanity/04_cartFO/01_editCheckCart.spec.ts +++ b/tests/UI/campaigns/sanity/04_cartFO/01_editCheckCart.spec.ts @@ -3,6 +3,7 @@ import { utilsTest, // Import FO pages foClassicHomePage, + foClassicCategoryPage, foClassicProductPage, foClassicCartPage, // Import data @@ -28,6 +29,7 @@ const psVersion = utilsTest.getPSVersion(); test.describe('FO - Cart : Check Cart in FO', async () => { let browserContext: BrowserContext; let page: Page; + let allProductsNumber: number = 0; let totalATI: number = 0; let itemsNumber: number = 0; @@ -49,20 +51,35 @@ test.describe('FO - Cart : Check Cart in FO', async () => { expect(isHomePage).toEqual(true); }); + test('should check and get the products number', async () => { + await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkNumberOfProducts', baseContext); + + await foClassicHomePage.goToAllProductsPage(page); + + allProductsNumber = await foClassicCategoryPage.getNumberOfProducts(page); + expect(allProductsNumber).toBeGreaterThan(0); + }); + test('should go to the first product page', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'goToProductPage1', baseContext); + await foClassicHomePage.goToHomePage(page); await foClassicHomePage.goToProductPage(page, 1); const pageTitle = await foClassicProductPage.getPageTitle(page); - expect(pageTitle).toContain(dataProducts.demo_1.name); + + if (allProductsNumber > 7) { + expect(pageTitle).toContain(dataProducts.demo_1.name); + } else { + expect(pageTitle).toContain(dataProducts.old_demo_1.name); + } }); test('should add product to cart and check that the number of products is updated in cart header', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'addProductToCart1', baseContext); await foClassicProductPage.addProductToTheCart(page); - // getNumberFromText is used to get the notifications number in the cart + const notificationsNumber = await foClassicHomePage.getCartNotificationsNumber(page); expect(notificationsNumber).toEqual(1); }); @@ -82,7 +99,12 @@ test.describe('FO - Cart : Check Cart in FO', async () => { await foClassicHomePage.goToProductPage(page, 2); const pageTitle = await foClassicProductPage.getPageTitle(page); - expect(pageTitle).toContain(dataProducts.demo_3.name); + + if (allProductsNumber > 7) { + expect(pageTitle).toContain(dataProducts.demo_3.name); + } else { + expect(pageTitle).toContain(dataProducts.old_demo_2.name); + } }); test('should add the second product to cart and check that the number of products is updated in cart header', async () => { @@ -90,7 +112,6 @@ test.describe('FO - Cart : Check Cart in FO', async () => { await foClassicProductPage.addProductToTheCart(page); - // getNumberFromText is used to get the notifications number in the cart const notificationsNumber = await foClassicHomePage.getCartNotificationsNumber(page); expect(notificationsNumber).toEqual(2); }); @@ -98,33 +119,59 @@ test.describe('FO - Cart : Check Cart in FO', async () => { test('should check the first product details', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkProductDetail1', baseContext); - const result = await foClassicCartPage.getProductDetail(page, 1); - await Promise.all([ - expect(result.name).toEqual(dataProducts.demo_1.name), - expect(result.price).toEqual(dataProducts.demo_1.finalPrice), - expect(result.quantity).toEqual(1), - ]); + if (allProductsNumber > 7) { + const result = await foClassicCartPage.getProductDetail(page, 1); + await Promise.all([ + expect(result.name).toEqual(dataProducts.demo_1.name), + expect(result.price).toEqual(dataProducts.demo_1.finalPrice), + expect(result.quantity).toEqual(1), + ]); + } else { + const productName = await foClassicCartPage.getProductName(page, 1); + expect(productName).toEqual(dataProducts.old_demo_1.name); + + const productPrice = await foClassicCartPage.getProductPrice(page, 1); + expect(productPrice).toEqual(dataProducts.old_demo_1.finalPrice); + + const productQuantity = await foClassicCartPage.getProductQuantity(page, 1); + expect(productQuantity).toEqual(1); + } }); test('should check the second product details', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkProductDetail2', baseContext); - const result = await foClassicCartPage.getProductDetail(page, 2); - await Promise.all([ - expect(result.name).toEqual(dataProducts.demo_3.name), - expect(result.price).toEqual(dataProducts.demo_3.finalPrice), - expect(result.quantity).toEqual(1), - ]); + if (allProductsNumber > 7) { + const result = await foClassicCartPage.getProductDetail(page, 2); + await Promise.all([ + expect(result.name).toEqual(dataProducts.demo_3.name), + expect(result.price).toEqual(dataProducts.demo_3.finalPrice), + expect(result.quantity).toEqual(1), + ]); + } else { + const productName = await foClassicCartPage.getProductName(page, 2); + expect(productName).toEqual(dataProducts.old_demo_2.name); + + const productPrice = await foClassicCartPage.getProductPrice(page, 2); + expect(productPrice).toEqual(dataProducts.old_demo_2.finalPrice); + + const productQuantity = await foClassicCartPage.getProductQuantity(page, 2); + expect(productQuantity).toEqual(1); + } }); // @todo : https://github.com/PrestaShop/PrestaShop/issues/9779 test.skip('should get the ATI price', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkTotalATI', baseContext); - // getNumberFromText is used to get the price ATI totalATI = await foClassicCartPage.getATIPrice(page); - expect(totalATI.toString()).toEqual((dataProducts.demo_3.finalPrice + dataProducts.demo_1.finalPrice) - .toFixed(2)); + if (allProductsNumber > 7) { + expect(totalATI.toString()).toEqual((dataProducts.demo_3.finalPrice + dataProducts.demo_1.finalPrice) + .toFixed(2)); + } else { + expect(totalATI.toString()).toEqual((dataProducts.old_demo_1.finalPrice + dataProducts.old_demo_2.finalPrice) + .toFixed(2)); + } }); test('should get the products number and check that is equal to 2', async () => { @@ -132,7 +179,6 @@ test.describe('FO - Cart : Check Cart in FO', async () => { totalATI = await foClassicCartPage.getATIPrice(page); - // getNumberFromText is used to get the products number itemsNumber = await foClassicCartPage.getProductsNumber(page); expect(itemsNumber).toEqual(2); }); @@ -142,11 +188,9 @@ test.describe('FO - Cart : Check Cart in FO', async () => { await foClassicCartPage.editProductQuantity(page, 1, 3); - // getNumberFromText is used to get the new price ATI const totalPrice = await foClassicCartPage.getATIPrice(page); expect(totalPrice).toBeGreaterThan(totalATI); - // getNumberFromText is used to get the new products number const productsNumber = await foClassicCartPage.getProductsNumber(page); expect(productsNumber).toBeGreaterThan(itemsNumber); }); diff --git a/tests/UI/campaigns/sanity/05_checkoutFO/01_orderProduct.spec.ts b/tests/UI/campaigns/sanity/05_checkoutFO/01_orderProduct.spec.ts index 1cfe7a3ec..067eeced0 100755 --- a/tests/UI/campaigns/sanity/05_checkoutFO/01_orderProduct.spec.ts +++ b/tests/UI/campaigns/sanity/05_checkoutFO/01_orderProduct.spec.ts @@ -4,6 +4,7 @@ import { // Import FO pages foClassicHomePage, foClassicLoginPage, + foClassicCategoryPage, foClassicCartPage, foClassicCheckoutPage, foClassicCheckoutOrderConfirmationPage, @@ -27,6 +28,7 @@ const baseContext: string = 'sanity_checkoutFO_orderProduct'; test.describe('BO - Checkout : Order a product and check order confirmation', async () => { let browserContext: BrowserContext; let page: Page; + let allProductsNumber: number = 0; test.beforeAll(async ({browser}) => { browserContext = await browser.newContext(); @@ -77,9 +79,19 @@ test.describe('BO - Checkout : Order a product and check order confirmation', as expect(result).toEqual(true); }); + test('should check and get the products number', async () => { + await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkNumberOfProducts', baseContext); + + await foClassicHomePage.goToAllProductsPage(page); + + allProductsNumber = await foClassicCategoryPage.getNumberOfProducts(page); + expect(allProductsNumber).toBeGreaterThan(0); + }); + test('should quick view the first product', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'quickViewFirstProduct', baseContext); + await foClassicHomePage.goToHomePage(page); await foClassicHomePage.quickViewProduct(page, 1); const isQuickViewModalVisible = await foClassicModalQuickViewPage.isQuickViewProductModalVisible(page); @@ -99,12 +111,23 @@ test.describe('BO - Checkout : Order a product and check order confirmation', as test('should check the cart details', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkCartDetails', baseContext); - const result = await foClassicCartPage.getProductDetail(page, 1); - await Promise.all([ - expect(result.name).toEqual(dataProducts.demo_1.name), - expect(result.price).toEqual(dataProducts.demo_1.finalPrice), - expect(result.quantity).toEqual(1), - ]); + if (allProductsNumber > 7) { + const result = await foClassicCartPage.getProductDetail(page, 1); + await Promise.all([ + expect(result.name).toEqual(dataProducts.demo_1.name), + expect(result.price).toEqual(dataProducts.demo_1.finalPrice), + expect(result.quantity).toEqual(1), + ]); + } else { + const productName = await foClassicCartPage.getProductName(page, 1); + expect(productName).toEqual(dataProducts.old_demo_1.name); + + const productPrice = await foClassicCartPage.getProductPrice(page, 1); + expect(productPrice).toEqual(dataProducts.old_demo_1.finalPrice); + + const productQuantity = await foClassicCartPage.getProductQuantity(page, 1); + expect(productQuantity).toEqual(1); + } }); test('should proceed to checkout and check Step Address', async () => { @@ -136,7 +159,7 @@ test.describe('BO - Checkout : Order a product and check order confirmation', as expect(isStepDeliveryComplete, 'Step Address is not complete').toEqual(true); }); - test('should Pay by back wire and confirm order', async () => { + test('should Pay by bank wire and confirm order', async () => { await utilsTest.addContextItem(test.info(), 'testIdentifier', 'confirmOrder', baseContext); await foClassicCheckoutPage.choosePaymentAndOrder(page, dataPaymentMethods.wirePayment.moduleName); diff --git a/tests/UI/campaigns/shopVersion/01_CheckVersion.spec.ts b/tests/UI/campaigns/shopVersion/01_CheckVersion.spec.ts index d94eb0f36..e1c2e4bce 100644 --- a/tests/UI/campaigns/shopVersion/01_CheckVersion.spec.ts +++ b/tests/UI/campaigns/shopVersion/01_CheckVersion.spec.ts @@ -16,9 +16,9 @@ const psVersion = utilsTest.getPSVersion(); /* Open BO - Check new version in login page for PS version <= 1.7.2.5 + Check new version in login page for PS version < 1.7.4 Login - Check new version in dashboard page + Check new version in dashboard page for PS version >= 1.7.4 */ test.describe('Check new shop version', () => { let browserContext: BrowserContext; @@ -44,7 +44,7 @@ test.describe('Check new shop version', () => { if (semver.lt(psVersion, '7.4.0')) { test(`should check that the shop version is ${psVersion}`, async () => { - await utilsTest.addContextItem(test.info(), 'testIdentifier', 'openBO', baseContext); + await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkShopVersionInLoginPage', baseContext); const shopVersion = await boLoginPage.getShopVersion(page); expect(shopVersion).toContain(psVersion); diff --git a/tests/UI/docker-compose.yml b/tests/UI/docker-compose.yml index 0d73d8cfd..f86e9a96c 100644 --- a/tests/UI/docker-compose.yml +++ b/tests/UI/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.7' services: prestashop: - image: prestashop/prestashop:${PS_VERSION} + image: prestashop/prestashop:${PS_VERSION}-apache container_name: prestashop depends_on: - mysql