From e5b82af14e974caede870b4061b233cada674f87 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Mon, 22 Jan 2024 10:33:59 +0100 Subject: [PATCH] Bump dependency @prestashop-core/ui-testing to 0.0.3 --- .../02_statisticsTabSettings.spec.ts | 194 +++++++++--------- tests/UI/package-lock.json | 38 +++- tests/UI/package.json | 2 +- 3 files changed, 124 insertions(+), 110 deletions(-) diff --git a/tests/UI/campaigns/02_configuration/02_statisticsTabSettings.spec.ts b/tests/UI/campaigns/02_configuration/02_statisticsTabSettings.spec.ts index b70122dd..d1d72280 100644 --- a/tests/UI/campaigns/02_configuration/02_statisticsTabSettings.spec.ts +++ b/tests/UI/campaigns/02_configuration/02_statisticsTabSettings.spec.ts @@ -4,31 +4,24 @@ import { // Import BO pages boDashboardPage, boLoginPage, + boModuleManagerPage, + // Import FO pages + foCategoryPage, + foHomePage, + foLoginPage, + // Import modules + modBlockwishlistBoMain, + modBlockwishlistBoStatistics, + // Import data + dataCustomers, + dataModules, } from '@prestashop-core/ui-testing'; -// Import commonTests -//import loginCommon from '@prestashop-core/ui-testing/dist/common/BO/loginBO'; - -// Import pages -// Import BO pages -/* -import {moduleManager as moduleManagerPage} from '@pages/BO/modules/moduleManager'; -import blockwishlistPage from '@pages/BO/modules/blockwishlist'; -import blockwishlistStatisticsPage from '@pages/BO/modules/blockwishlist/statistics'; -// Import FO pages -import categoryPage from '@pages/FO/category'; -import {homePage} from '@pages/FO/home'; -import {loginPage as foLoginPage} from '@pages/FO/login'; - -// Import data -import Customers from '@data/demo/customers'; -import Modules from '@data/demo/modules';*/ - import { test, expect } from '@playwright/test'; const baseContext: string = 'modules_blockwishlist_configuration_statisticsTabSettings'; -test('Wishlist module - Statistics tab settings', async ({ page }) => { +test('Wishlist module - Statistics tab settings', async ({ page, context }) => { await test.step('should login in BO', async () => { await testContext.addContextItem(test.info(), 'testIdentifier', 'loginBO', baseContext); @@ -47,127 +40,124 @@ test('Wishlist module - Statistics tab settings', async ({ page }) => { boDashboardPage.modulesParentLink, boDashboardPage.moduleManagerLink, ); - /* - await moduleManagerPage.closeSfToolBar(page); + await boModuleManagerPage.closeSfToolBar(page); - const pageTitle = await moduleManagerPage.getPageTitle(page); - expect(pageTitle).to.contains(moduleManagerPage.pageTitle);*/ + const pageTitle = await boModuleManagerPage.getPageTitle(page); + expect(pageTitle).toContain(boModuleManagerPage.pageTitle); }); -/* - test(`should search the module ${Modules.blockwishlist.name}`, async ({ page }) => { - await testContext.addContextItem(this, 'testIdentifier', 'searchModule', baseContext); - const isModuleVisible = await moduleManagerPage.searchModule(page, Modules.blockwishlist); - expect(isModuleVisible).to.eq(true); - }); + await test.step(`should search the module ${dataModules.blockwishlist.name}`, async () => { + await testContext.addContextItem(test.info(), 'testIdentifier', 'searchModule', baseContext); - test(`should go to the configuration page of the module '${Modules.blockwishlist.name}'`, async ({ page }) => { - await testContext.addContextItem(this, 'testIdentifier', 'goToConfigurationPage', baseContext); + const isModuleVisible = await boModuleManagerPage.searchModule(page, dataModules.blockwishlist); + expect(isModuleVisible).toEqual(true); + }); - await moduleManagerPage.goToConfigurationPage(page, Modules.blockwishlist.tag); + await test.step(`should go to the configuration page of the module '${dataModules.blockwishlist.name}'`, async () => { + await testContext.addContextItem(test.info(), 'testIdentifier', 'goToConfigurationPage', baseContext); - const pageTitle = await blockwishlistPage.getPageTitle(page); - expect(pageTitle).to.eq(blockwishlistPage.pageTitle); + await boModuleManagerPage.goToConfigurationPage(page, dataModules.blockwishlist.tag); - const isConfigurationTabActive = await blockwishlistPage.isTabActive(page, 'Configuration'); - expect(isConfigurationTabActive).to.eq(true); + const pageTitle = await modBlockwishlistBoMain.getPageTitle(page); + expect(pageTitle).toEqual(modBlockwishlistBoMain.pageTitle); - const isStatisticsTabActive = await blockwishlistPage.isTabActive(page, 'Statistics'); - expect(isStatisticsTabActive).to.eq(false); - }); + const isConfigurationTabActive = await modBlockwishlistBoMain.isTabActive(page, 'Configuration'); + expect(isConfigurationTabActive).toEqual(true); - test('should go on Statistics Tab', async ({ page }) => { - await testContext.addContextItem(this, 'testIdentifier', 'goToStatisticsTab', baseContext); + const isStatisticsTabActive = await modBlockwishlistBoMain.isTabActive(page, 'Statistics'); + expect(isStatisticsTabActive).toEqual(false); + }); + + await test.step('should go on Statistics Tab', async () => { + await testContext.addContextItem(test.info(), 'testIdentifier', 'goToStatisticsTab', baseContext); - await blockwishlistPage.goToStatisticsTab(page); + await modBlockwishlistBoMain.goToStatisticsTab(page); - const pageTitle = await blockwishlistStatisticsPage.getPageTitle(page); - expect(pageTitle).to.eq(blockwishlistStatisticsPage.pageTitle); + const pageTitle = await modBlockwishlistBoStatistics.getPageTitle(page); + expect(pageTitle).toEqual(modBlockwishlistBoStatistics.pageTitle); - const noRecordsFoundText = await blockwishlistStatisticsPage.getTextForEmptyTable(page); - expect(noRecordsFoundText).to.contains('warning No records found'); - }); + const noRecordsFoundText = await modBlockwishlistBoStatistics.getTextForEmptyTable(page); + expect(noRecordsFoundText).toContain('warning No records found'); }); - describe('Go to the FO and add to favorites some products', async () => { - test('should go to the FO', async ({ page }) => { - await testContext.addContextItem(this, 'testIdentifier', 'goToFO', baseContext); - page = await blockwishlistStatisticsPage.viewMyShop(page); - await homePage.changeLanguage(page, 'en'); + await test.step('should go to the FO', async () => { + await testContext.addContextItem(test.info(), 'testIdentifier', 'goToFO', baseContext); - const isHomePage = await homePage.isHomePage(page); - expect(isHomePage).to.eq(true); - }); + page = await modBlockwishlistBoStatistics.viewMyShop(page); + await foHomePage.changeLanguage(page, 'en'); - test('should go to login page', async ({ page }) => { - await testContext.addContextItem(this, 'testIdentifier', 'goToLoginPage', baseContext); + const isHomePage = await foHomePage.isHomePage(page); + expect(isHomePage).toEqual(true); + }); - await homePage.goToLoginPage(page); + await test.step('should go to login page', async () => { + await testContext.addContextItem(test.info(), 'testIdentifier', 'goToLoginPage', baseContext); - const pageTitle = await foLoginPage.getPageTitle(page); - expect(pageTitle, 'Fail to open FO login page').to.contains(foLoginPage.pageTitle); - }); + await foHomePage.goToLoginPage(page); - test('should sign in with default customer', async ({ page }) => { - await testContext.addContextItem(this, 'testIdentifier', 'sighInFo', baseContext); + const pageTitle = await foLoginPage.getPageTitle(page); + expect(pageTitle, 'Fail to open FO login page').toContain(foLoginPage.pageTitle); + }); - await foLoginPage.customerLogin(page, Customers.johnDoe); + await test.step('should sign in with default customer', async () => { + await testContext.addContextItem(test.info(), 'testIdentifier', 'sighInFo', baseContext); - const isCustomerConnected = await foLoginPage.isCustomerConnected(page); - expect(isCustomerConnected, 'Customer is not connected').to.eq(true); - }); + await foLoginPage.customerLogin(page, dataCustomers.johnDoe); - test('should go to all products page', async ({ page }) => { - await testContext.addContextItem(this, 'testIdentifier', 'goToAllProducts', baseContext); + const isCustomerConnected = await foLoginPage.isCustomerConnected(page); + expect(isCustomerConnected, 'Customer is not connected').toEqual(true); + }); + + await test.step('should go to all products page', async () => { + await testContext.addContextItem(test.info(), 'testIdentifier', 'goToAllProducts', baseContext); - await homePage.goToAllProductsPage(page); + await foHomePage.goToAllProductsPage(page); - const isCategoryPageVisible = await categoryPage.isCategoryPage(page); - expect(isCategoryPageVisible).to.eq(true); - }); + const isCategoryPageVisible = await foCategoryPage.isCategoryPage(page); + expect(isCategoryPageVisible).toEqual(true); + }); for (let idxProduct: number = 1; idxProduct <= 3; idxProduct++) { // eslint-disable-next-line no-loop-func - test(`should add product #${idxProduct} to wishlist`, async ({ page }) => { - await testContext.addContextItem(this, 'testIdentifier', `addToFavorite${idxProduct}`, baseContext); + await test.step(`should add product #${idxProduct} to wishlist`, async () => { + await testContext.addContextItem(test.info(), 'testIdentifier', `addToFavorite${idxProduct}`, baseContext); - const textResult = await categoryPage.addToWishList(page, idxProduct); - expect(textResult).to.be.eq(categoryPage.messageAddedToWishlist); + const textResult = await foCategoryPage.addToWishList(page, idxProduct); + expect(textResult).toEqual(foCategoryPage.messageAddedToWishlist); - const isAddedToWishlist = await categoryPage.isAddedToWishlist(page, idxProduct); - expect(isAddedToWishlist).to.eq(true); + const isAddedToWishlist = await foCategoryPage.isAddedToWishlist(page, idxProduct); + expect(isAddedToWishlist).toEqual(true); }); } - test('should logout', async ({ page }) => { - await testContext.addContextItem(this, 'testIdentifier', 'foLogout', baseContext); + await test.step('should logout', async () => { + await testContext.addContextItem(test.info(), 'testIdentifier', 'foLogout', baseContext); - await categoryPage.logout(page); + await foCategoryPage.logout(page); - const isCustomerConnected = await homePage.isCustomerConnected(page); - expect(isCustomerConnected).to.eq(false); - }); + const isCustomerConnected = await foHomePage.isCustomerConnected(page); + expect(isCustomerConnected).toEqual(false); }); - describe('Return to BO and check statistics', async () => { - test('should go to BO', async ({ page }) => { - await testContext.addContextItem(this, 'testIdentifier', 'goToBoBack', baseContext); + + await test.step('should go to BO', async () => { + await testContext.addContextItem(test.info(), 'testIdentifier', 'goToBoBack', baseContext); - page = await homePage.closePage(browserContext, page, 0); + page = await foHomePage.closePage(context, page, 0); - const pageTitle = await blockwishlistStatisticsPage.getPageTitle(page); - expect(pageTitle).to.contains(blockwishlistStatisticsPage.pageTitle); - }); - // @todo : https://github.com/PrestaShop/PrestaShop/issues/33374 - test('should click on the refresh button', async ({ page }) => { - await testContext.addContextItem(this, 'testIdentifier', 'clickOnRefreshButton', baseContext); + const pageTitle = await modBlockwishlistBoStatistics.getPageTitle(page); + expect(pageTitle).toContain(modBlockwishlistBoStatistics.pageTitle); + }); + + // @todo : https://github.com/PrestaShop/PrestaShop/issues/33374 + await test.step('should click on the refresh button', async () => { + await testContext.addContextItem(test.info(), 'testIdentifier', 'clickOnRefreshButton', baseContext); - test.skip(); + test.skip(true, 'https://github.com/PrestaShop/PrestaShop/issues/33374'); - await blockwishlistStatisticsPage.refreshStatistics(page); + await modBlockwishlistBoStatistics.refreshStatistics(page); - // Check statistics - const pageTitle = await blockwishlistStatisticsPage.getPageTitle(page); - expect(pageTitle).to.contains(blockwishlistStatisticsPage.pageTitle); - }); - });*/ + // Check statistics + const pageTitle = await modBlockwishlistBoStatistics.getPageTitle(page); + expect(pageTitle).toContain(modBlockwishlistBoStatistics.pageTitle); + }); }); diff --git a/tests/UI/package-lock.json b/tests/UI/package-lock.json index 4620d167..97092d81 100644 --- a/tests/UI/package-lock.json +++ b/tests/UI/package-lock.json @@ -13,12 +13,28 @@ }, "devDependencies": { "@playwright/test": "^1.40.1", - "@prestashop-core/ui-testing": "^0.0.2", + "@prestashop-core/ui-testing": "^0.0.3", "@types/node": "^20.11.5", "pwmochawesome": "^1.1.1", "typescript": "^5.3.3" } }, + "node_modules/@faker-js/faker": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-8.3.1.tgz", + "integrity": "sha512-FdgpFxY6V6rLZE9mmIBb9hM0xpfvQOSNOLnzolzKwsE1DH+gC7lEKV1p1IbR0lAYyvYd5a4u3qWJzowUkw1bIw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/fakerjs" + } + ], + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0", + "npm": ">=6.14.13" + } + }, "node_modules/@playwright/test": { "version": "1.40.1", "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.40.1.tgz", @@ -35,11 +51,12 @@ } }, "node_modules/@prestashop-core/ui-testing": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/@prestashop-core/ui-testing/-/ui-testing-0.0.2.tgz", - "integrity": "sha512-v74KEfm8ZjWsjSwOdDixrnj/r633fLCKViyTYd4LXCmWPv4EaeS+vobgyqy/fxOAWoEr2ck/b4endrsGwicEmQ==", + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@prestashop-core/ui-testing/-/ui-testing-0.0.3.tgz", + "integrity": "sha512-qZIGkD7cuNvLMvRyLGhLxSgh4riCn+wL1fF0dC+d+Vr0G0pbWGEDpIv1gWhvzj1f2BFyadO1vvVxUaDIwWDbAQ==", "dev": true, "dependencies": { + "@faker-js/faker": "^8.3.1", "@playwright/test": "^1.40.1", "semver": "^7.5.4" } @@ -568,6 +585,12 @@ } }, "dependencies": { + "@faker-js/faker": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-8.3.1.tgz", + "integrity": "sha512-FdgpFxY6V6rLZE9mmIBb9hM0xpfvQOSNOLnzolzKwsE1DH+gC7lEKV1p1IbR0lAYyvYd5a4u3qWJzowUkw1bIw==", + "dev": true + }, "@playwright/test": { "version": "1.40.1", "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.40.1.tgz", @@ -578,11 +601,12 @@ } }, "@prestashop-core/ui-testing": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/@prestashop-core/ui-testing/-/ui-testing-0.0.2.tgz", - "integrity": "sha512-v74KEfm8ZjWsjSwOdDixrnj/r633fLCKViyTYd4LXCmWPv4EaeS+vobgyqy/fxOAWoEr2ck/b4endrsGwicEmQ==", + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@prestashop-core/ui-testing/-/ui-testing-0.0.3.tgz", + "integrity": "sha512-qZIGkD7cuNvLMvRyLGhLxSgh4riCn+wL1fF0dC+d+Vr0G0pbWGEDpIv1gWhvzj1f2BFyadO1vvVxUaDIwWDbAQ==", "dev": true, "requires": { + "@faker-js/faker": "^8.3.1", "@playwright/test": "^1.40.1", "semver": "^7.5.4" } diff --git a/tests/UI/package.json b/tests/UI/package.json index fb8892de..77a7bb26 100644 --- a/tests/UI/package.json +++ b/tests/UI/package.json @@ -8,7 +8,7 @@ "license": "MIT", "devDependencies": { "@playwright/test": "^1.40.1", - "@prestashop-core/ui-testing": "^0.0.2", + "@prestashop-core/ui-testing": "^0.0.3", "@types/node": "^20.11.5", "pwmochawesome": "^1.1.1", "typescript": "^5.3.3"