Skip to content

Commit

Permalink
Merge pull request #36383 from Progi1984/test4055
Browse files Browse the repository at this point in the history
Functional Tests : New products block module - BO header buttons
  • Loading branch information
Progi1984 authored Jun 20, 2024
2 parents 16bd25d + b5b9dbf commit b58b0cb
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import loginCommon from '@commonTests/BO/loginBO';
import {homePage} from '@pages/FO/classic/home';
// Import BO pages
import {moduleManager as moduleManagerPage} from '@pages/BO/modules/moduleManager';
import psNewProducts from '@pages/BO/modules/psNewProducts';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';
import {
boDashboardPage,
dataModules,
modPsNewProductsBoMain,
utilsPlaywright,
} from '@prestashop-core/ui-testing';

Expand Down Expand Up @@ -80,24 +80,24 @@ describe('New products block module - Reset module', async () => {

await moduleManagerPage.goToConfigurationPage(page, dataModules.psNewProducts.tag);

const pageTitle = await psNewProducts.getPageSubtitle(page);
expect(pageTitle).to.eq(psNewProducts.pageSubTitle);
const pageTitle = await modPsNewProductsBoMain.getPageSubtitle(page);
expect(pageTitle).to.eq(modPsNewProductsBoMain.pageSubTitle);

defaultValue = parseInt(await psNewProducts.getNumProductsToDisplay(page), 10);
defaultValue = parseInt(await modPsNewProductsBoMain.getNumProductsToDisplay(page), 10);
expect(defaultValue).to.be.gt(0);
});

it('should change the configuration in the module', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'changeConfiguration', baseContext);

const textResult = await psNewProducts.setNumProductsToDisplay(page, numProducts);
expect(textResult).to.contains(psNewProducts.updateSettingsSuccessMessage);
const textResult = await modPsNewProductsBoMain.setNumProductsToDisplay(page, numProducts);
expect(textResult).to.contains(modPsNewProductsBoMain.updateSettingsSuccessMessage);
});

it('should go to the front office', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToTheFo', baseContext);

page = await psNewProducts.viewMyShop(page);
page = await modPsNewProductsBoMain.viewMyShop(page);
await homePage.changeLanguage(page, 'en');

const isHomePage = await homePage.isHomePage(page);
Expand All @@ -116,8 +116,8 @@ describe('New products block module - Reset module', async () => {

page = await homePage.closePage(browserContext, page, 0);

const pageTitle = await psNewProducts.getPageSubtitle(page);
expect(pageTitle).to.eq(psNewProducts.pageSubTitle);
const pageTitle = await modPsNewProductsBoMain.getPageSubtitle(page);
expect(pageTitle).to.eq(modPsNewProductsBoMain.pageSubTitle);
});

it('should return to \'Modules > Module Manager\' page', async function () {
Expand Down Expand Up @@ -153,21 +153,21 @@ describe('New products block module - Reset module', async () => {

await moduleManagerPage.goToConfigurationPage(page, dataModules.psNewProducts.tag);

const pageTitle = await psNewProducts.getPageSubtitle(page);
expect(pageTitle).to.eq(psNewProducts.pageSubTitle);
const pageTitle = await modPsNewProductsBoMain.getPageSubtitle(page);
expect(pageTitle).to.eq(modPsNewProductsBoMain.pageSubTitle);
});

it('should check the configuration is reset', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'changeConfigurationReset', baseContext);

const numProductsValue = await psNewProducts.getNumProductsToDisplay(page);
const numProductsValue = await modPsNewProductsBoMain.getNumProductsToDisplay(page);
expect(numProductsValue).to.be.equal(defaultValue.toString());
});

it('should go to the front office', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToTheFoAfterReset', baseContext);

page = await psNewProducts.viewMyShop(page);
page = await modPsNewProductsBoMain.viewMyShop(page);
await homePage.changeLanguage(page, 'en');

const isHomePage = await homePage.isHomePage(page);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import loginCommon from '@commonTests/BO/loginBO';
import {homePage} from '@pages/FO/classic/home';
// Import BO pages
import {moduleManager as moduleManagerPage} from '@pages/BO/modules/moduleManager';
import psNewProducts from '@pages/BO/modules/psNewProducts';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';
import {
boDashboardPage,
dataModules,
modPsNewProductsBoMain,
utilsPlaywright,
} from '@prestashop-core/ui-testing';

Expand Down Expand Up @@ -80,7 +80,7 @@ describe('New products block module - Disable/Enable module', async () => {
it('should go to the front office', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToFOAfterDisable', baseContext);

page = await psNewProducts.viewMyShop(page);
page = await modPsNewProductsBoMain.viewMyShop(page);
await homePage.changeLanguage(page, 'en');

const isHomePage = await homePage.isHomePage(page);
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('New products block module - Disable/Enable module', async () => {
it('should go to the front office', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToFOAfterEnable', baseContext);

page = await psNewProducts.viewMyShop(page);
page = await modPsNewProductsBoMain.viewMyShop(page);
await homePage.changeLanguage(page, 'en');

const isHomePage = await homePage.isHomePage(page);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// Import utils
import testContext from '@utils/testContext';

// Import commonTests
import loginCommon from '@commonTests/BO/loginBO';

// Import pages
// Import BO pages
import boDesignPositionsPage from '@pages/BO/design/positions';
import {moduleManager as moduleManagerPage} from '@pages/BO/modules/moduleManager';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';
import {
boDashboardPage,
dataModules,
modPsNewProductsBoMain,
utilsPlaywright,
} from '@prestashop-core/ui-testing';

const baseContext: string = 'modules_ps_newproducts_configuration_boHeaderButtons';

describe('New products block module - BO Header Buttons', async () => {
let browserContext: BrowserContext;
let page: Page;

// before and after functions
before(async function () {
browserContext = await utilsPlaywright.createBrowserContext(this.browser);
page = await utilsPlaywright.newTab(browserContext);
});

after(async () => {
await utilsPlaywright.closeBrowserContext(browserContext);
});

describe('BO - Header Buttons', async () => {
it('should login in BO', async function () {
await loginCommon.loginBO(this, page);
});

it('should go to \'Modules > Module Manager\' page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToModuleManagerPage', baseContext);

await boDashboardPage.goToSubMenu(
page,
boDashboardPage.modulesParentLink,
boDashboardPage.moduleManagerLink,
);
await moduleManagerPage.closeSfToolBar(page);

const pageTitle = await moduleManagerPage.getPageTitle(page);
expect(pageTitle).to.contains(moduleManagerPage.pageTitle);
});

it(`should search the module ${dataModules.psNewProducts.name}`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'searchModule', baseContext);

const isModuleVisible = await moduleManagerPage.searchModule(page, dataModules.psNewProducts);
expect(isModuleVisible).to.eq(true);
});

it(`should go to the configuration page of the module '${dataModules.psNewProducts.name}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToConfigurationPage', baseContext);

await moduleManagerPage.goToConfigurationPage(page, dataModules.psNewProducts.tag);

const pageTitle = await modPsNewProductsBoMain.getPageSubtitle(page);
expect(pageTitle).to.eq(modPsNewProductsBoMain.pageSubTitle);
});

it('should click on the "Back" button', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'clickOnBackButton', baseContext);

await modPsNewProductsBoMain.clickHeaderBack(page);

const pageTitle = await moduleManagerPage.getPageTitle(page);
expect(pageTitle).to.contains(moduleManagerPage.pageTitle);
});

it('should return to the configure page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'returnConfigureAfterBack', baseContext);

const isModuleVisible = await moduleManagerPage.searchModule(page, dataModules.psNewProducts);
expect(isModuleVisible).to.eq(true);

await moduleManagerPage.goToConfigurationPage(page, dataModules.psNewProducts.tag);

const pageTitle = await modPsNewProductsBoMain.getPageSubtitle(page);
expect(pageTitle).to.eq(modPsNewProductsBoMain.pageSubTitle);
});

it('should click on the "Translate" button', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'clickOnTranslateButton', baseContext);

await modPsNewProductsBoMain.clickHeaderTranslate(page);

const isModalVisible = await modPsNewProductsBoMain.isModalTranslateVisible(page);
expect(isModalVisible).to.be.equal(true);
});

it('should close the "Translate" modal', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'closeTranslateModal', baseContext);

await modPsNewProductsBoMain.closeTranslateModal(page);

const isModalVisible = await modPsNewProductsBoMain.isModalTranslateVisible(page);
expect(isModalVisible).to.be.equal(false);

const pageTitle = await modPsNewProductsBoMain.getPageSubtitle(page);
expect(pageTitle).to.eq(modPsNewProductsBoMain.pageSubTitle);
});

it('should click on the "Manage hooks" button', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'clickOnManageHooksButton', baseContext);

await modPsNewProductsBoMain.clickHeaderManageHooks(page);

const pageTitle = await boDesignPositionsPage.getPageTitle(page);
expect(pageTitle).to.be.equal(boDesignPositionsPage.pageTitle);

const moduleFiltered = await boDesignPositionsPage.getModuleFilter(page);
expect(moduleFiltered).to.be.equal(dataModules.psNewProducts.name);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import loginCommon from '@commonTests/BO/loginBO';
import {homePage} from '@pages/FO/classic/home';
// Import BO pages
import {moduleManager as moduleManagerPage} from '@pages/BO/modules/moduleManager';
import psNewProducts from '@pages/BO/modules/psNewProducts';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';
import {
boDashboardPage,
dataModules,
modPsNewProductsBoMain,
utilsPlaywright,
} from '@prestashop-core/ui-testing';

Expand Down Expand Up @@ -67,10 +67,10 @@ describe('New products block module - Configure settings of "Number of days for

await moduleManagerPage.goToConfigurationPage(page, dataModules.psNewProducts.tag);

const pageTitle = await psNewProducts.getPageSubtitle(page);
expect(pageTitle).to.eq(psNewProducts.pageSubTitle);
const pageTitle = await modPsNewProductsBoMain.getPageSubtitle(page);
expect(pageTitle).to.eq(modPsNewProductsBoMain.pageSubTitle);

defaultValue = await psNewProducts.getNumDaysConsideredAsNew(page);
defaultValue = await modPsNewProductsBoMain.getNumDaysConsideredAsNew(page);
});

[
Expand Down Expand Up @@ -111,14 +111,14 @@ describe('New products block module - Configure settings of "Number of days for
it(`should change the configuration (${arg.setting}) in the module`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `changeConfiguration${index}`, baseContext);

const textResult = await psNewProducts.setNumDaysConsideredAsNew(page, arg.setting);
expect(textResult).to.contains(psNewProducts.updateSettingsSuccessMessage);
const textResult = await modPsNewProductsBoMain.setNumDaysConsideredAsNew(page, arg.setting);
expect(textResult).to.contains(modPsNewProductsBoMain.updateSettingsSuccessMessage);
});

it('should go to the front office', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToTheFo${index}`, baseContext);

page = await psNewProducts.viewMyShop(page);
page = await modPsNewProductsBoMain.viewMyShop(page);
await homePage.changeLanguage(page, 'en');

const isHomePage = await homePage.isHomePage(page);
Expand All @@ -137,15 +137,15 @@ describe('New products block module - Configure settings of "Number of days for

page = await homePage.closePage(browserContext, page, 0);

const pageTitle = await psNewProducts.getPageSubtitle(page);
expect(pageTitle).to.eq(psNewProducts.pageSubTitle);
const pageTitle = await modPsNewProductsBoMain.getPageSubtitle(page);
expect(pageTitle).to.eq(modPsNewProductsBoMain.pageSubTitle);
});
});

it('should reset the configuration in the module', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'setDefaultValue', baseContext);

const textResult = await psNewProducts.setNumDaysConsideredAsNew(page, defaultValue);
expect(textResult).to.contains(psNewProducts.updateSettingsSuccessMessage);
const textResult = await modPsNewProductsBoMain.setNumDaysConsideredAsNew(page, defaultValue);
expect(textResult).to.contains(modPsNewProductsBoMain.updateSettingsSuccessMessage);
});
});
4 changes: 2 additions & 2 deletions tests/UI/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b58b0cb

Please sign in to comment.