From 6044d03631c17b5d0fa608306e36f79eacf24513 Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Thu, 26 Dec 2024 19:11:43 +0100 Subject: [PATCH 1/5] Add methods to install module for all versions --- src/index.ts | 3 + .../BO/modules/marketplace/index.ts | 11 ++ .../modulesAndServices/installedModules.ts | 12 +++ .../modules/modulesAndServices/selection.ts | 10 ++ src/pages/BO/modules/marketplace/index.ts | 16 +++ .../modulesAndServices/installedModules.ts | 22 ++++ .../modules/modulesAndServices/selection.ts | 25 +++++ .../modules/modulesAndServices/selection.ts | 39 +++++++ .../modulesAndServices/installedModules.ts | 38 +++++++ .../modules/modulesAndServices/selection.ts | 38 +++++++ .../modulesAndServices/installedModules.ts | 39 +++++++ .../modules/modulesAndServices/selection.ts | 40 +++++++ .../modulesAndServices/installedModules.ts | 102 ++++++++++++++++++ .../modules/modulesAndServices/selection.ts | 68 ++++++++++++ .../pages/BO/modules/marketplace/index.ts | 79 ++++++++++++++ .../pages/BO/modules/marketplace/index.ts | 53 +++++++++ .../modulesAndServices/installedModules.ts | 58 ++++++++++ .../modules/modulesAndServices/selection.ts | 41 +++++++ 18 files changed, 694 insertions(+) create mode 100644 src/interfaces/BO/modules/marketplace/index.ts create mode 100644 src/interfaces/BO/modules/modulesAndServices/installedModules.ts create mode 100644 src/interfaces/BO/modules/modulesAndServices/selection.ts create mode 100644 src/pages/BO/modules/marketplace/index.ts create mode 100644 src/pages/BO/modules/modulesAndServices/installedModules.ts create mode 100644 src/pages/BO/modules/modulesAndServices/selection.ts create mode 100644 src/versions/1.7.0/pages/BO/modules/modulesAndServices/selection.ts create mode 100644 src/versions/1.7.1/pages/BO/modules/modulesAndServices/installedModules.ts create mode 100644 src/versions/1.7.1/pages/BO/modules/modulesAndServices/selection.ts create mode 100644 src/versions/1.7.2/pages/BO/modules/modulesAndServices/installedModules.ts create mode 100644 src/versions/1.7.2/pages/BO/modules/modulesAndServices/selection.ts create mode 100644 src/versions/1.7.4/pages/BO/modules/modulesAndServices/installedModules.ts create mode 100644 src/versions/1.7.4/pages/BO/modules/modulesAndServices/selection.ts create mode 100644 src/versions/1.7.5/pages/BO/modules/marketplace/index.ts create mode 100644 src/versions/mock/pages/BO/modules/marketplace/index.ts create mode 100644 src/versions/mock/pages/BO/modules/modulesAndServices/installedModules.ts create mode 100644 src/versions/mock/pages/BO/modules/modulesAndServices/selection.ts diff --git a/src/index.ts b/src/index.ts index 8afb50fe..01af6b9a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -223,6 +223,9 @@ export {default as boLanguagesCreatePage} from '@pages/BO/international/language export {default as boLocalizationPage} from '@pages/BO/international/localization'; export {default as boLoginPage} from '@pages/BO/login'; export {default as boMaintenancePage} from '@pages/BO/shopParameters/general/maintenance'; +export {default as boMarketplacePage} from '@pages/BO/modules/marketplace'; +export {default as boInstalledModulesPage} from '@pages/BO/modules/modulesAndServices/installedModules'; +export {default as boSelectionPage} from '@pages/BO/modules/modulesAndServices/selection'; export {default as boModuleManagerPage} from '@pages/BO/modules/moduleManager'; export {default as boModuleManagerAlertsPage} from '@pages/BO/modules/moduleManager/alerts'; export {default as boModuleManagerUninstalledModulesPage} from '@pages/BO/modules/moduleManager/uninstalledModules'; diff --git a/src/interfaces/BO/modules/marketplace/index.ts b/src/interfaces/BO/modules/marketplace/index.ts new file mode 100644 index 00000000..3a84783c --- /dev/null +++ b/src/interfaces/BO/modules/marketplace/index.ts @@ -0,0 +1,11 @@ +import {BOBasePagePageInterface} from '@interfaces/BO'; +import type {Page} from '@playwright/test'; + +export interface MarketplacePageInterface extends BOBasePagePageInterface { + readonly installMessageSuccessful: (moduleTag: string) => string; + readonly pageTitle: string; + + goToMarketplacePage(page: Page): Promise; + installModule(page: Page, moduleTag: string): Promise; + goToModuleConfigurationPage(page:Page):Promise; +} diff --git a/src/interfaces/BO/modules/modulesAndServices/installedModules.ts b/src/interfaces/BO/modules/modulesAndServices/installedModules.ts new file mode 100644 index 00000000..3afbe7f9 --- /dev/null +++ b/src/interfaces/BO/modules/modulesAndServices/installedModules.ts @@ -0,0 +1,12 @@ +import {BOBasePagePageInterface} from '@interfaces/BO'; +import type {Page} from '@playwright/test'; +import FakerModule from '@data/faker/module'; + +export interface InstalledModulesPageInterface extends BOBasePagePageInterface { + readonly pageTitle: string; + + goToSelectionPage(page: Page): Promise; + goToModuleConfigurationPage(page:Page, moduleTag:string):Promise; + isModuleVisible(page: Page, module: FakerModule): Promise, + searchModule(page: Page, module: FakerModule): Promise; +} diff --git a/src/interfaces/BO/modules/modulesAndServices/selection.ts b/src/interfaces/BO/modules/modulesAndServices/selection.ts new file mode 100644 index 00000000..42f4e3fb --- /dev/null +++ b/src/interfaces/BO/modules/modulesAndServices/selection.ts @@ -0,0 +1,10 @@ +import {BOBasePagePageInterface} from '@interfaces/BO'; +import type {Page} from '@playwright/test'; + +export interface SelectionPageInterface extends BOBasePagePageInterface { + readonly installMessageSuccessful: (moduleTag: string) => string; + readonly pageTitle: string; + + installModule(page: Page, moduleTag: string): Promise; + goToInstalledModulesPage(page: Page): Promise; +} diff --git a/src/pages/BO/modules/marketplace/index.ts b/src/pages/BO/modules/marketplace/index.ts new file mode 100644 index 00000000..fadcc149 --- /dev/null +++ b/src/pages/BO/modules/marketplace/index.ts @@ -0,0 +1,16 @@ +import type {MarketplacePageInterface} from '@interfaces/BO/modules/marketplace'; +import testContext from '@utils/test'; +import semver from 'semver'; + +const psVersion = testContext.getPSVersion(); + +/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ +function requirePage(): MarketplacePageInterface { + if (semver.gte(psVersion, '8.0.0')) { + return require('@versions/mock/pages/BO/modules/marketplace'); + } + return require('@versions/1.7.5/pages/BO/modules/marketplace'); +} +/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ + +export default requirePage(); diff --git a/src/pages/BO/modules/modulesAndServices/installedModules.ts b/src/pages/BO/modules/modulesAndServices/installedModules.ts new file mode 100644 index 00000000..ca51fb3a --- /dev/null +++ b/src/pages/BO/modules/modulesAndServices/installedModules.ts @@ -0,0 +1,22 @@ +import type {InstalledModulesPageInterface} from '@interfaces/BO/modules/modulesAndServices/installedModules'; +import testContext from '@utils/test'; +import semver from 'semver'; + +const psVersion = testContext.getPSVersion(); + +/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ +function requirePage(): InstalledModulesPageInterface { + if (semver.gte(psVersion, '7.5.0')) { + return require('@versions/mock/pages/BO/modules/modulesAndServices/installedModules'); + } + if (semver.lt(psVersion, '7.2.0')) { + return require('@versions/1.7.1/pages/BO/modules/modulesAndServices/installedModules').installedModulesPage; + } + if (semver.lt(psVersion, '7.3.0')) { + return require('@versions/1.7.2/pages/BO/modules/modulesAndServices/installedModules').installedModulesPage; + } + return require('@versions/1.7.4/pages/BO/modules/modulesAndServices/installedModules').installedModulesPage; +} +/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ + +export default requirePage(); diff --git a/src/pages/BO/modules/modulesAndServices/selection.ts b/src/pages/BO/modules/modulesAndServices/selection.ts new file mode 100644 index 00000000..1897abd5 --- /dev/null +++ b/src/pages/BO/modules/modulesAndServices/selection.ts @@ -0,0 +1,25 @@ +import type {SelectionPageInterface} from '@interfaces/BO/modules/modulesAndServices/selection'; +import testContext from '@utils/test'; +import semver from 'semver'; + +const psVersion = testContext.getPSVersion(); + +/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ +function requirePage(): SelectionPageInterface { + if (semver.gte(psVersion, '7.5.0')) { + return require('@versions/mock/pages/BO/modules/modulesAndServices/selection'); + } + if (semver.lt(psVersion, '7.1.0')) { + return require('@versions/1.7.0/pages/BO/modules/modulesAndServices/selection').selectionPage; + } + if (semver.lt(psVersion, '7.2.0')) { + return require('@versions/1.7.1/pages/BO/modules/modulesAndServices/selection').selectionPage; + } + if (semver.lt(psVersion, '7.3.0')) { + return require('@versions/1.7.2/pages/BO/modules/modulesAndServices/selection').selectionPage; + } + return require('@versions/1.7.4/pages/BO/modules/modulesAndServices/selection').selectionPage; +} +/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ + +export default requirePage(); diff --git a/src/versions/1.7.0/pages/BO/modules/modulesAndServices/selection.ts b/src/versions/1.7.0/pages/BO/modules/modulesAndServices/selection.ts new file mode 100644 index 00000000..3e5ca9e6 --- /dev/null +++ b/src/versions/1.7.0/pages/BO/modules/modulesAndServices/selection.ts @@ -0,0 +1,39 @@ +// Import pages +import type {SelectionPageInterface} from '@interfaces/BO/modules/modulesAndServices/selection'; +import {SelectionPage} from '@versions/1.7.1/pages/BO/modules/modulesAndServices/selection'; +import {Page} from '@playwright/test'; + +/** + * Bo selection page, contains functions that can be used on the page + * @class + * @extends ProductsPage + */ +class SelectionVersion extends SelectionPage implements SelectionPageInterface { + /** + * @constructs + * Setting up texts and selectors to use on selection page + */ + constructor() { + super(); + + // Selectors + this.alertSuccessBlock = '#main-div div.flash-message-list.alert.alert-success'; + } + + /** + * Install the module and return success message + * @param {Page} page + * @param {string} moduleTag + * @returns {Promise} + */ + async installModule(page: Page, moduleTag: string): Promise { + await page.locator(this.searchModuleInput).fill(moduleTag); + await page.keyboard.press('Enter'); + await page.locator(this.installModuleButton).click(); + + return this.getAlertSuccessBlockContent(page); + } +} + +const selectionPage = new SelectionVersion(); +export {selectionPage, SelectionVersion as SelectionPage}; diff --git a/src/versions/1.7.1/pages/BO/modules/modulesAndServices/installedModules.ts b/src/versions/1.7.1/pages/BO/modules/modulesAndServices/installedModules.ts new file mode 100644 index 00000000..95eb1c99 --- /dev/null +++ b/src/versions/1.7.1/pages/BO/modules/modulesAndServices/installedModules.ts @@ -0,0 +1,38 @@ +// Import pages +import type {InstalledModulesPageInterface} from '@interfaces/BO/modules/modulesAndServices/installedModules'; +import {InstalledModulesPage} from '@versions/1.7.2/pages/BO/modules/modulesAndServices/installedModules'; +import {Page} from '@playwright/test'; + +/** + * Bo installed Modules page, contains functions that can be used on the page + * @class + * @extends ProductsPage + */ +class InstalledModulesVersion extends InstalledModulesPage implements InstalledModulesPageInterface { + private readonly pageTitleSelector: string; + + /** + * @constructs + * Setting up texts and selectors to use on InstalledModules page + */ + constructor() { + super(); + + this.pageTitle = 'Manage installed modules'; + + // Selectors + this.pageTitleSelector = '#main-div div.header-toolbar h2'; + } + + /** + * Get page title + * @param page {Page} Browser tab + * @returns {Promise} + */ + async getPageTitle(page: Page): Promise { + return this.getTextContent(page, this.pageTitleSelector); + } +} + +const installedModulesPage = new InstalledModulesVersion(); +export {installedModulesPage, InstalledModulesVersion as InstalledModulesPage}; diff --git a/src/versions/1.7.1/pages/BO/modules/modulesAndServices/selection.ts b/src/versions/1.7.1/pages/BO/modules/modulesAndServices/selection.ts new file mode 100644 index 00000000..32dc525b --- /dev/null +++ b/src/versions/1.7.1/pages/BO/modules/modulesAndServices/selection.ts @@ -0,0 +1,38 @@ +// Import pages +import type {SelectionPageInterface} from '@interfaces/BO/modules/modulesAndServices/selection'; +import {SelectionPage} from '@versions/1.7.2/pages/BO/modules/modulesAndServices/selection'; +import {Page} from '@playwright/test'; + +/** + * Bo selection page, contains functions that can be used on the page + * @class + * @extends ProductsPage + */ +class SelectionVersion extends SelectionPage implements SelectionPageInterface { + private readonly pageTitleSelector: string; + + /** + * @constructs + * Setting up texts and selectors to use on selection page + */ + constructor() { + super(); + + this.pageTitle = 'Module selection'; + + // Selectors + this.pageTitleSelector = '#main-div div.header-toolbar h2'; + } + + /** + * Get page title + * @param page {Page} Browser tab + * @returns {Promise} + */ + async getPageTitle(page: Page): Promise { + return this.getTextContent(page, this.pageTitleSelector); + } +} + +const selectionPage = new SelectionVersion(); +export {selectionPage, SelectionVersion as SelectionPage}; diff --git a/src/versions/1.7.2/pages/BO/modules/modulesAndServices/installedModules.ts b/src/versions/1.7.2/pages/BO/modules/modulesAndServices/installedModules.ts new file mode 100644 index 00000000..849a5efc --- /dev/null +++ b/src/versions/1.7.2/pages/BO/modules/modulesAndServices/installedModules.ts @@ -0,0 +1,39 @@ +// Import pages +import type {InstalledModulesPageInterface} from '@interfaces/BO/modules/modulesAndServices/installedModules'; +import {InstalledModulesPage} from '@versions/1.7.4/pages/BO/modules/modulesAndServices/installedModules'; +import {Page} from '@playwright/test'; +import FakerModule from '@data/faker/module'; + +/** + * Bo installed modules page, contains functions that can be used on the page + * @class + * @extends ProductsPage + */ +class InstalledModulesVersion extends InstalledModulesPage implements InstalledModulesPageInterface { + /** + * @constructs + * Setting up texts and selectors to use on installed modules page + */ + constructor() { + super(); + + // Selectors + this.searchModuleTagInput = 'div.module-top-menu input.pstaggerAddTagInput'; + } + + /** + * Search Module in Page module Catalog + * @param page {Page} Browser tab + * @param module {FakerModule} Tag of the Module + * @return {Promise} + */ + async searchModule(page: Page, module: FakerModule): Promise { + await page.locator(this.searchModuleTagInput).fill(module.tag); + await page.keyboard.press('Enter'); + + return this.isModuleVisible(page, module); + } +} + +const installedModulesPage = new InstalledModulesVersion(); +export {installedModulesPage, InstalledModulesVersion as InstalledModulesPage}; diff --git a/src/versions/1.7.2/pages/BO/modules/modulesAndServices/selection.ts b/src/versions/1.7.2/pages/BO/modules/modulesAndServices/selection.ts new file mode 100644 index 00000000..9c2da131 --- /dev/null +++ b/src/versions/1.7.2/pages/BO/modules/modulesAndServices/selection.ts @@ -0,0 +1,40 @@ +// Import pages +import type {SelectionPageInterface} from '@interfaces/BO/modules/modulesAndServices/selection'; +import {SelectionPage} from '@versions/1.7.4/pages/BO/modules/modulesAndServices/selection'; +import {Page} from '@playwright/test'; + +/** + * Bo selection page, contains functions that can be used on the page + * @class + * @extends ProductsPage + */ +class SelectionVersion extends SelectionPage implements SelectionPageInterface { + /** + * @constructs + * Setting up texts and selectors to use on selection page + */ + constructor() { + super(); + + // Selectors + this.installModuleButton = '.btn-group[action*=\'install\']'; + this.installedModulesLink = '.page-head-tabs a[href*=\'module/manage\']'; + } + + /** + * Install the module and return success message + * @param {Page} page + * @param {string} moduleTag + * @returns {Promise} + */ + async installModule(page: Page, moduleTag: string): Promise { + await page.locator(this.searchModuleInput).fill(moduleTag); + await page.keyboard.press('Enter'); + await page.locator(this.installModuleButton).click(); + + return this.getGrowlMessageContent(page); + } +} + +const selectionPage = new SelectionVersion(); +export {selectionPage, SelectionVersion as SelectionPage}; diff --git a/src/versions/1.7.4/pages/BO/modules/modulesAndServices/installedModules.ts b/src/versions/1.7.4/pages/BO/modules/modulesAndServices/installedModules.ts new file mode 100644 index 00000000..ed0928cb --- /dev/null +++ b/src/versions/1.7.4/pages/BO/modules/modulesAndServices/installedModules.ts @@ -0,0 +1,102 @@ +import {InstalledModulesPageInterface} from '@interfaces/BO/modules/modulesAndServices/installedModules'; +import BOBasePage from '@pages/BO/BOBasePage'; +import {Page} from '@playwright/test'; +import FakerModule from '@data/faker/module'; + +/** + * Installed modules page, contains selectors and functions for the page + * @class + * @extends BOBasePage + */ +class InstalledModulesPage extends BOBasePage implements InstalledModulesPageInterface { + public pageTitle: string; + + private readonly selectionLink: string; + + private readonly configureModuleButton: string; + + protected searchModuleTagInput: string; + + private readonly searchModuleButton: string; + + private readonly moduleItemName: (moduleTag: string) => string; + + private readonly actionsDropdownButton: (moduleTag: string) => string; + + private readonly actionModuleButtonInDropdownList: (action: string) => string; + + /** + * @constructs + * Setting up titles and selectors to use on modules catalog page + */ + constructor() { + super(); + + this.pageTitle = `Manage installed modules • ${global.INSTALL.SHOP_NAME}`; + + // Selectors + this.selectionLink = '#subtab-AdminModulesCatalog'; + this.configureModuleButton = '.dropdown-menu form[action*=\'configure\']'; + this.searchModuleTagInput = '#search-input-group input.pstaggerAddTagInput'; + this.searchModuleButton = '#module-search-button'; + this.moduleItemName = (moduleTag: string) => `.module-item-list[data-tech-name=${moduleTag}]`; + // Module actions in dropdown selectors + this.actionsDropdownButton = (moduleTag: string) => `div[data-tech-name=${moduleTag}] button.dropdown-toggle`; + this.actionModuleButtonInDropdownList = (action: string) => 'div.btn-group.module-actions.show' + + ` button.module_action_menu_${action}`; + } + + /* + Methods + */ + /** + * Go to the "Selection" page + * @param {Page} page + * @returns {Promise} + */ + async goToSelectionPage(page: Page): Promise { + await this.clickAndWaitForURL(page, this.selectionLink); + } + + /** + * Go to module configuration page + * @param page {Page} page + * @param moduleTag {string} Technical name of the module + * @returns {Promise} + */ + async goToModuleConfigurationPage(page:Page, moduleTag: string):Promise { + if (await this.elementNotVisible(page, this.configureModuleButton, 1000)) { + await Promise.all([ + page.locator(this.actionsDropdownButton(moduleTag)).click(), + this.waitForVisibleSelector(page, `${this.actionsDropdownButton(moduleTag)}[aria-expanded='true']`), + ]); + } + await this.clickAndWaitForURL(page, this.configureModuleButton); + } + + /** + * Return if the module is visible + * @param page {Page} Browser tab + * @param module {FakerModule} Tag of the Module + * @return {Promise} + */ + async isModuleVisible(page: Page, module: FakerModule): Promise { + return this.elementVisible(page, this.moduleItemName(module.tag), 10000); + } + + /** + * Search Module in Page module Catalog + * @param page {Page} Browser tab + * @param module {FakerModule} Tag of the Module + * @return {Promise} + */ + async searchModule(page: Page, module: FakerModule): Promise { + await page.locator(this.searchModuleTagInput).fill(module.tag); + await page.locator(this.searchModuleButton).click(); + + return this.isModuleVisible(page, module); + } +} + +const installedModulesPage = new InstalledModulesPage(); +export {installedModulesPage, InstalledModulesPage}; diff --git a/src/versions/1.7.4/pages/BO/modules/modulesAndServices/selection.ts b/src/versions/1.7.4/pages/BO/modules/modulesAndServices/selection.ts new file mode 100644 index 00000000..03648b23 --- /dev/null +++ b/src/versions/1.7.4/pages/BO/modules/modulesAndServices/selection.ts @@ -0,0 +1,68 @@ +import {Page} from '@playwright/test'; +import {SelectionPageInterface} from '../../../../../../interfaces/BO/modules/modulesAndServices/selection'; +import BOBasePage from '../../../../../../pages/BO/BOBasePage'; + +/** + * Marketplace page, contains selectors and functions for the page + * @class + * @extends BOBasePage + */ +class SelectionPage extends BOBasePage implements SelectionPageInterface { + public pageTitle: string; + + public readonly installMessageSuccessful: (moduleTag: string) => string; + + protected installedModulesLink: string; + + protected readonly searchModuleInput: string; + + private readonly searchButton: string; + + protected installModuleButton: string; + + /** + * @constructs + * Setting up titles and selectors to use on modules catalog page + */ + constructor() { + super(); + + this.pageTitle = `Module selection • ${global.INSTALL.SHOP_NAME}`; + this.installMessageSuccessful = (moduleTag: string) => `Install action on module ${moduleTag} succeeded.`; + + // Selectors + this.installedModulesLink = '#head_tabs a[href*=\'module/manage\']'; + this.searchModuleInput = '.pstaggerAddTagInput'; + this.searchButton = '#module-search-button'; + this.installModuleButton = '.form-action-button[action*=\'install\']'; + } + + /* + Methods + */ + /** + * Install the module and return success message + * @param {Page} page + * @param {string} moduleTag + * @returns {Promise} + */ + async installModule(page: Page, moduleTag: string): Promise { + await page.locator(this.searchModuleInput).fill(moduleTag); + await page.locator(this.searchButton).click(); + await page.locator(this.installModuleButton).click(); + + return this.getGrowlMessageContent(page); + } + + /** + * Go to installed modules page + * @param page {Page} page + @returns {Promise} + */ + async goToInstalledModulesPage(page: Page): Promise { + await this.clickAndWaitForURL(page, this.installedModulesLink); + } +} + +const selectionPage = new SelectionPage(); +export {selectionPage, SelectionPage}; diff --git a/src/versions/1.7.5/pages/BO/modules/marketplace/index.ts b/src/versions/1.7.5/pages/BO/modules/marketplace/index.ts new file mode 100644 index 00000000..11c28a10 --- /dev/null +++ b/src/versions/1.7.5/pages/BO/modules/marketplace/index.ts @@ -0,0 +1,79 @@ +import {MarketplacePageInterface} from '@interfaces/BO/modules/marketplace'; +import BOBasePage from '@pages/BO/BOBasePage'; +import {Page} from '@playwright/test'; + +/** + * Marketplace page, contains selectors and functions for the page + * @class + * @extends BOBasePage + */ +class Marketplace extends BOBasePage implements MarketplacePageInterface { + public readonly pageTitle: string; + + public readonly installMessageSuccessful: (moduleTag: string) => string; + + private readonly marketplaceLink: string; + + private readonly searchModuleInput: string; + + private readonly searchButton: string; + + private readonly installModuleButton: string; + + private readonly configureModuleButton: string; + + /** + * @constructs + * Setting up titles and selectors to use on marketplace page + */ + constructor() { + super(); + + this.pageTitle = `Marketplace • ${global.INSTALL.SHOP_NAME}`; + this.installMessageSuccessful = (moduleTag: string) => `Install action on module ${moduleTag} succeeded.`; + + // Selectors + this.marketplaceLink = '#subtab-AdminPsMboModule'; + this.searchModuleInput = '.pstaggerAddTagInput'; + this.searchButton = '#module-search-button'; + this.installModuleButton = '.mbo-module-card__actions form[action*=\'install\']'; + this.configureModuleButton = '.module-actions a[href*=\'configure\']'; + } + + /* + Methods + */ + /* + * Go to the "Marketplace" page + * @param {Page} page + * @returns {Promise} + */ + async goToMarketplacePage(page: Page): Promise { + await this.clickAndWaitForURL(page, this.marketplaceLink); + } + + /** + * Install the module and return success message + * @param {Page} page + * @param {string} moduleTag + * @returns {Promise} + */ + async installModule(page: Page, moduleTag: string): Promise { + await page.locator(this.searchModuleInput).fill(moduleTag); + await page.locator(this.searchButton).click(); + await page.locator(this.installModuleButton).click(); + + return this.getGrowlMessageContent(page); + } + + /** + * Go to module configuration page + * @param page {Page} page + * @returns {Promise} + */ + async goToModuleConfigurationPage(page:Page):Promise { + await this.clickAndWaitForURL(page, this.configureModuleButton); + } +} + +module.exports = new Marketplace(); diff --git a/src/versions/mock/pages/BO/modules/marketplace/index.ts b/src/versions/mock/pages/BO/modules/marketplace/index.ts new file mode 100644 index 00000000..3c313567 --- /dev/null +++ b/src/versions/mock/pages/BO/modules/marketplace/index.ts @@ -0,0 +1,53 @@ +import {MarketplacePageInterface} from '@interfaces/BO/modules/marketplace'; +import BOBasePage from '@pages/BO/BOBasePage'; + +/** + * Mock Page for unsupported version + * @class + * @extends BOBasePage + */ +class Marketplace extends BOBasePage implements MarketplacePageInterface { + public readonly pageTitle: string; + + public readonly installMessageSuccessful: (moduleTag: string) => string; + + /** + * @constructs + * Setting up titles and selectors to use on marketplace page + */ + constructor() { + super(); + + this.pageTitle = ''; + this.installMessageSuccessful = () => ''; + } + + /* + Methods + */ + /** + * Go to the "Uninstalled modules" tab + * @returns {Promise} + */ + async goToMarketplacePage(): Promise { + // do nothing. + } + + /** + * Install the module and return if installed + * @returns {Promise} + */ + async installModule(): Promise { + return ''; + } + + /** + * Go to module configuration page + * @returns {Promise} + */ + async goToModuleConfigurationPage(): Promise { + // do nothing. + } +} + +module.exports = new Marketplace(); diff --git a/src/versions/mock/pages/BO/modules/modulesAndServices/installedModules.ts b/src/versions/mock/pages/BO/modules/modulesAndServices/installedModules.ts new file mode 100644 index 00000000..e88a5eef --- /dev/null +++ b/src/versions/mock/pages/BO/modules/modulesAndServices/installedModules.ts @@ -0,0 +1,58 @@ +import {InstalledModulesPageInterface} from '@interfaces/BO/modules/modulesAndServices/installedModules'; +import BOBasePage from '@pages/BO/BOBasePage'; + +/** + * Mock Page for unsupported version + * @class + * @extends BOBasePage + */ +class InstalledModulesPage extends BOBasePage implements InstalledModulesPageInterface { + public readonly pageTitle: string; + + /** + * @constructs + * Setting up titles and selectors to use on installed modules page + */ + constructor() { + super(); + + this.pageTitle = ''; + } + + /* + Methods + */ + /** + * Go to the "Selection" tab + * @returns {Promise} + */ + async goToSelectionPage(): Promise { + // do nothing. + } + + /** + * Go to module configuration page + * @returns {Promise} + */ + async goToModuleConfigurationPage(): Promise { + // do nothing. + } + + /** + * Return if the module is visible + * @return {Promise} + */ + async isModuleVisible(): Promise { + return true; + } + + /** + * Search Module in Page module Catalog + * @return {Promise} + */ + async searchModule(): Promise { + return true; + } +} + +module.exports = new InstalledModulesPage(); diff --git a/src/versions/mock/pages/BO/modules/modulesAndServices/selection.ts b/src/versions/mock/pages/BO/modules/modulesAndServices/selection.ts new file mode 100644 index 00000000..49cc05d0 --- /dev/null +++ b/src/versions/mock/pages/BO/modules/modulesAndServices/selection.ts @@ -0,0 +1,41 @@ +import {SelectionPageInterface} from '@interfaces/BO/modules/modulesAndServices/selection'; +import BOBasePage from '@pages/BO/BOBasePage'; + +/** + * Mock Page for unsupported version + * @class + * @extends BOBasePage + */ +class SelectionPage extends BOBasePage implements SelectionPageInterface { + public readonly pageTitle: string; + + public readonly installMessageSuccessful: (moduleTag: string) => string; + + /** + * @constructs + * Setting up titles and selectors to use on selection page + */ + constructor() { + super(); + + this.pageTitle = ''; + this.installMessageSuccessful = () => ''; + } + + /* + Methods + */ + /** + * Install the module and return if installed + * @returns {Promise} + */ + async installModule(): Promise { + return ''; + } + + async goToInstalledModulesPage():Promise { + // + } +} + +module.exports = new SelectionPage(); From a16c3f06a32994a4414742ffb49774bcfe99e62a Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Thu, 26 Dec 2024 20:31:31 +0100 Subject: [PATCH 2/5] Add some fixes --- src/index.ts | 5 +- .../BO/modules/moduleCatalog/index.ts | 9 +++ src/pages/BO/modules/moduleCatalog/index.ts | 13 +++++ .../pages/BO/modules/moduleCatalog/index.ts | 56 +++++++++++++++++++ 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 src/interfaces/BO/modules/moduleCatalog/index.ts create mode 100644 src/pages/BO/modules/moduleCatalog/index.ts create mode 100644 src/versions/1.7.6/pages/BO/modules/moduleCatalog/index.ts diff --git a/src/index.ts b/src/index.ts index 01af6b9a..e7dc037b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -225,11 +225,12 @@ export {default as boLoginPage} from '@pages/BO/login'; export {default as boMaintenancePage} from '@pages/BO/shopParameters/general/maintenance'; export {default as boMarketplacePage} from '@pages/BO/modules/marketplace'; export {default as boInstalledModulesPage} from '@pages/BO/modules/modulesAndServices/installedModules'; -export {default as boSelectionPage} from '@pages/BO/modules/modulesAndServices/selection'; -export {default as boModuleManagerPage} from '@pages/BO/modules/moduleManager'; +export {default as boModuleCatalogPage} from '@pages/BO/modules/moduleCatalog'; export {default as boModuleManagerAlertsPage} from '@pages/BO/modules/moduleManager/alerts'; +export {default as boModuleManagerPage} from '@pages/BO/modules/moduleManager'; export {default as boModuleManagerUninstalledModulesPage} from '@pages/BO/modules/moduleManager/uninstalledModules'; export {default as boModuleManagerUpdatesPage} from '@pages/BO/modules/moduleManager/updates'; +export {default as boModuleSelectionPage} from '@pages/BO/modules/modulesAndServices/selection'; export {default as boMyProfilePage} from '@pages/BO/advancedParameters/team/myProfile'; export {default as boNewExperimentalFeaturesPage} from '@pages/BO/advancedParameters/newExperimentalFeatures'; export {default as boOrdersPage} from '@pages/BO/orders'; diff --git a/src/interfaces/BO/modules/moduleCatalog/index.ts b/src/interfaces/BO/modules/moduleCatalog/index.ts new file mode 100644 index 00000000..f7579bad --- /dev/null +++ b/src/interfaces/BO/modules/moduleCatalog/index.ts @@ -0,0 +1,9 @@ +import {BOBasePagePageInterface} from '@interfaces/BO'; +import type {Page} from '@playwright/test'; + +export interface ModuleCatalogPageInterface extends BOBasePagePageInterface { + readonly installMessageSuccessful: (moduleTag: string) => string; + readonly pageTitle: string; + + installModule(page: Page, moduleTag: string): Promise; +} diff --git a/src/pages/BO/modules/moduleCatalog/index.ts b/src/pages/BO/modules/moduleCatalog/index.ts new file mode 100644 index 00000000..11e351c5 --- /dev/null +++ b/src/pages/BO/modules/moduleCatalog/index.ts @@ -0,0 +1,13 @@ +import type {ModuleCatalogPageInterface} from '@interfaces/BO/modules/moduleCatalog'; +import testContext from '@utils/test'; +import semver from 'semver'; + +const psVersion = testContext.getPSVersion(); + +/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ +function requirePage(): ModuleCatalogPageInterface { + return require('@versions/1.7.6/pages/BO/modules/moduleCatalog'); +} +/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ + +export default requirePage(); \ No newline at end of file diff --git a/src/versions/1.7.6/pages/BO/modules/moduleCatalog/index.ts b/src/versions/1.7.6/pages/BO/modules/moduleCatalog/index.ts new file mode 100644 index 00000000..3df90f37 --- /dev/null +++ b/src/versions/1.7.6/pages/BO/modules/moduleCatalog/index.ts @@ -0,0 +1,56 @@ +import {ModuleCatalogPageInterface} from '@interfaces/BO/modules/moduleCatalog'; +import BOBasePage from '@pages/BO/BOBasePage'; +import {Page} from '@playwright/test'; + +/** + * Module catalog page, contains selectors and functions for the page + * @class + * @extends BOBasePage + */ +class ModuleCatalogPage extends BOBasePage implements ModuleCatalogPageInterface { + public readonly pageTitle: string; + + public readonly installMessageSuccessful: (moduleTag: string) => string; + + private readonly searchModuleInput: string; + + private readonly searchButton: string; + + private readonly installModuleButton: (moduleName: string) => string; + + /** + * @constructs + * Setting up titles and selectors to use on module catalog page + */ + constructor() { + super(); + + this.pageTitle = `Modules catalog • ${global.INSTALL.SHOP_NAME}`; + this.installMessageSuccessful = (moduleTag: string) => `Install action on module ${moduleTag} succeeded.`; + + // Selectors + this.searchModuleInput = '.pstaggerAddTagInput'; + this.searchButton = '#module-search-button'; + this.installModuleButton = (moduleTag: string) => `div[data-tech-name="${moduleTag}"] button.module_action_menu_install`; + } + + /* + Methods + */ + + /** + * Install the module and return if installed + * @param {Page} page + * @param {string} moduleTag + * @returns {Promise} + */ + async installModule(page: Page, moduleTag: string): Promise { + await page.locator(this.searchModuleInput).fill(moduleTag); + await page.locator(this.searchButton).click(); + await page.locator(this.installModuleButton(moduleTag)).click(); + + return this.getGrowlMessageContent(page); + } +} + +module.exports = new ModuleCatalogPage(); From 74941239a42346ba9179d17745e36bc57edf4c96 Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Thu, 26 Dec 2024 20:37:15 +0100 Subject: [PATCH 3/5] Fix lint errors --- src/pages/BO/modules/moduleCatalog/index.ts | 5 +---- src/versions/1.7.6/pages/BO/modules/moduleCatalog/index.ts | 2 +- src/versions/mock/pages/BO/modules/marketplace/index.ts | 2 +- .../mock/pages/BO/modules/modulesAndServices/selection.ts | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/pages/BO/modules/moduleCatalog/index.ts b/src/pages/BO/modules/moduleCatalog/index.ts index 11e351c5..70f404e7 100644 --- a/src/pages/BO/modules/moduleCatalog/index.ts +++ b/src/pages/BO/modules/moduleCatalog/index.ts @@ -1,8 +1,5 @@ import type {ModuleCatalogPageInterface} from '@interfaces/BO/modules/moduleCatalog'; import testContext from '@utils/test'; -import semver from 'semver'; - -const psVersion = testContext.getPSVersion(); /* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ function requirePage(): ModuleCatalogPageInterface { @@ -10,4 +7,4 @@ function requirePage(): ModuleCatalogPageInterface { } /* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ -export default requirePage(); \ No newline at end of file +export default requirePage(); diff --git a/src/versions/1.7.6/pages/BO/modules/moduleCatalog/index.ts b/src/versions/1.7.6/pages/BO/modules/moduleCatalog/index.ts index 3df90f37..2feace2b 100644 --- a/src/versions/1.7.6/pages/BO/modules/moduleCatalog/index.ts +++ b/src/versions/1.7.6/pages/BO/modules/moduleCatalog/index.ts @@ -39,7 +39,7 @@ class ModuleCatalogPage extends BOBasePage implements ModuleCatalogPageInterface */ /** - * Install the module and return if installed + * Install the module and return success message * @param {Page} page * @param {string} moduleTag * @returns {Promise} diff --git a/src/versions/mock/pages/BO/modules/marketplace/index.ts b/src/versions/mock/pages/BO/modules/marketplace/index.ts index 3c313567..504be4d6 100644 --- a/src/versions/mock/pages/BO/modules/marketplace/index.ts +++ b/src/versions/mock/pages/BO/modules/marketplace/index.ts @@ -34,7 +34,7 @@ class Marketplace extends BOBasePage implements MarketplacePageInterface { } /** - * Install the module and return if installed + * Install the module and return success message * @returns {Promise} */ async installModule(): Promise { diff --git a/src/versions/mock/pages/BO/modules/modulesAndServices/selection.ts b/src/versions/mock/pages/BO/modules/modulesAndServices/selection.ts index 49cc05d0..5468bfd4 100644 --- a/src/versions/mock/pages/BO/modules/modulesAndServices/selection.ts +++ b/src/versions/mock/pages/BO/modules/modulesAndServices/selection.ts @@ -26,7 +26,7 @@ class SelectionPage extends BOBasePage implements SelectionPageInterface { Methods */ /** - * Install the module and return if installed + * Install the module and return success message * @returns {Promise} */ async installModule(): Promise { From d786d96eb29f15b8cb076a4e71ba146f35c0b7cf Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Thu, 26 Dec 2024 20:40:04 +0100 Subject: [PATCH 4/5] Fix lint error --- src/pages/BO/modules/moduleCatalog/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/BO/modules/moduleCatalog/index.ts b/src/pages/BO/modules/moduleCatalog/index.ts index 70f404e7..497a408e 100644 --- a/src/pages/BO/modules/moduleCatalog/index.ts +++ b/src/pages/BO/modules/moduleCatalog/index.ts @@ -1,5 +1,4 @@ import type {ModuleCatalogPageInterface} from '@interfaces/BO/modules/moduleCatalog'; -import testContext from '@utils/test'; /* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ function requirePage(): ModuleCatalogPageInterface { From a1189e33a8f24bce8cd1822f9adadd19135b47b6 Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Fri, 27 Dec 2024 10:47:29 +0100 Subject: [PATCH 5/5] Fix review --- src/pages/BO/modules/marketplace/index.ts | 2 +- .../BO/modules/modulesAndServices/installedModules.ts | 2 +- .../pages/BO/modules/modulesAndServices/selection.ts | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/BO/modules/marketplace/index.ts b/src/pages/BO/modules/marketplace/index.ts index fadcc149..e7406bce 100644 --- a/src/pages/BO/modules/marketplace/index.ts +++ b/src/pages/BO/modules/marketplace/index.ts @@ -6,7 +6,7 @@ const psVersion = testContext.getPSVersion(); /* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ function requirePage(): MarketplacePageInterface { - if (semver.gte(psVersion, '8.0.0')) { + if (semver.gte(psVersion, '7.6.0')) { return require('@versions/mock/pages/BO/modules/marketplace'); } return require('@versions/1.7.5/pages/BO/modules/marketplace'); diff --git a/src/versions/1.7.4/pages/BO/modules/modulesAndServices/installedModules.ts b/src/versions/1.7.4/pages/BO/modules/modulesAndServices/installedModules.ts index ed0928cb..3262549c 100644 --- a/src/versions/1.7.4/pages/BO/modules/modulesAndServices/installedModules.ts +++ b/src/versions/1.7.4/pages/BO/modules/modulesAndServices/installedModules.ts @@ -27,7 +27,7 @@ class InstalledModulesPage extends BOBasePage implements InstalledModulesPageInt /** * @constructs - * Setting up titles and selectors to use on modules catalog page + * Setting up titles and selectors to use on installed modules page */ constructor() { super(); diff --git a/src/versions/1.7.4/pages/BO/modules/modulesAndServices/selection.ts b/src/versions/1.7.4/pages/BO/modules/modulesAndServices/selection.ts index 03648b23..c070eb0a 100644 --- a/src/versions/1.7.4/pages/BO/modules/modulesAndServices/selection.ts +++ b/src/versions/1.7.4/pages/BO/modules/modulesAndServices/selection.ts @@ -1,9 +1,9 @@ import {Page} from '@playwright/test'; -import {SelectionPageInterface} from '../../../../../../interfaces/BO/modules/modulesAndServices/selection'; -import BOBasePage from '../../../../../../pages/BO/BOBasePage'; +import {SelectionPageInterface} from '@interfaces/BO/modules/modulesAndServices/selection'; +import BOBasePage from '@pages/BO/BOBasePage'; /** - * Marketplace page, contains selectors and functions for the page + * Selection page, contains selectors and functions for the page * @class * @extends BOBasePage */ @@ -22,7 +22,7 @@ class SelectionPage extends BOBasePage implements SelectionPageInterface { /** * @constructs - * Setting up titles and selectors to use on modules catalog page + * Setting up titles and selectors to use on selection page */ constructor() { super();