From f869001ab694ad8d3ddde94ab845606cb351f1b4 Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Wed, 18 Dec 2024 13:11:42 +0100 Subject: [PATCH 1/3] Add data and pages for autoupgrade module --- src/data/demo/modules.ts | 4 ++ src/index.ts | 1 + .../BO/modules/autoupgrade/index.ts | 9 ++++ src/pages/BO/modules/autoupgrade/index.ts | 17 ++++++ .../pages/BO/modules/autoupgrade/index.ts | 54 +++++++++++++++++++ 5 files changed, 85 insertions(+) create mode 100644 src/interfaces/BO/modules/autoupgrade/index.ts create mode 100644 src/pages/BO/modules/autoupgrade/index.ts create mode 100644 src/versions/develop/pages/BO/modules/autoupgrade/index.ts diff --git a/src/data/demo/modules.ts b/src/data/demo/modules.ts index 9260b56a..c926a0b7 100644 --- a/src/data/demo/modules.ts +++ b/src/data/demo/modules.ts @@ -158,4 +158,8 @@ export default { tag: 'statsstock', name: 'Available quantities', }), + autoupgrade: new FakerModule({ + tag: 'autoupgrade', + name: '1-Click Upgrade', + }), }; diff --git a/src/index.ts b/src/index.ts index 9c899505..8afb50fe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -308,6 +308,7 @@ export {default as foHummingbirdProductPage} from '@pages/FO/hummingbird/product export {default as foHummingbirdSearchResultsPage} from '@pages/FO/hummingbird/searchResults'; // Export Modules +export {default as modAutoupgradeBoMain} from '@pages/BO/modules/autoupgrade'; export {default as modBlockwishlistBoMain} from '@pages/BO/modules/blockwishlist'; export {default as modBlockwishlistBoStatistics} from '@pages/BO/modules/blockwishlist/statistics'; export {default as modKeycloakConnectorDemoBoMain} from '@pages/BO/modules/keycloakConnectorDemo'; diff --git a/src/interfaces/BO/modules/autoupgrade/index.ts b/src/interfaces/BO/modules/autoupgrade/index.ts new file mode 100644 index 00000000..b9a81264 --- /dev/null +++ b/src/interfaces/BO/modules/autoupgrade/index.ts @@ -0,0 +1,9 @@ +import {ModuleConfigurationPageInterface} from '@interfaces/BO/modules/moduleConfiguration'; +import type {Page} from '@playwright/test'; + +export interface ModuleAutoupgradeMainPageInterface extends ModuleConfigurationPageInterface { + readonly pageTitle: string; + + goToMaintenancePage(page:Page): Promise; + isRequirementsAlertDangerVisible(page:Page): Promise; +} diff --git a/src/pages/BO/modules/autoupgrade/index.ts b/src/pages/BO/modules/autoupgrade/index.ts new file mode 100644 index 00000000..94358018 --- /dev/null +++ b/src/pages/BO/modules/autoupgrade/index.ts @@ -0,0 +1,17 @@ +import type {ModuleAutoupgradeMainPageInterface} from '@interfaces/BO/modules/autoupgrade'; +import testContext from '@utils/test'; +import semver from 'semver'; + +const psVersion = testContext.getPSVersion(); + +/* eslint-disable global-require, @typescript-eslint/no-require-imports */ +function requirePage(): ModuleAutoupgradeMainPageInterface { + if (semver.gte(psVersion, '0.0.0')) { + return require('@versions/develop/pages/BO/modules/autoupgrade'); + } + return require('@versions/develop/pages/BO/modules/autoupgrade'); +} + +/* eslint-enable global-require, @typescript-eslint/no-require-imports */ + +export default requirePage(); diff --git a/src/versions/develop/pages/BO/modules/autoupgrade/index.ts b/src/versions/develop/pages/BO/modules/autoupgrade/index.ts new file mode 100644 index 00000000..91cb3b38 --- /dev/null +++ b/src/versions/develop/pages/BO/modules/autoupgrade/index.ts @@ -0,0 +1,54 @@ +import {ModuleAutoupgradeMainPageInterface} from '@interfaces/BO/modules/autoupgrade'; +import ModuleConfiguration from '@pages/BO/modules/moduleConfiguration'; +import type {Page} from '@playwright/test'; + +/** + * Module configuration page for module : Autoupgrade, contains selectors and functions for the page + * @class + * @extends ModuleConfiguration + */ +class Autoupgrade extends ModuleConfiguration implements ModuleAutoupgradeMainPageInterface { + public readonly pageTitle: string; + + private readonly currentConfigurationTable: string; + + private readonly maintenanceModeLink: string; + + private readonly alertDangerPreUpgrade: string; + + /** + * @constructs + */ + constructor() { + super(); + + this.pageTitle = `Update assistant > Update assistant • ${global.INSTALL.SHOP_NAME}`; + + // Selectors + this.currentConfigurationTable = '#currentConfiguration table'; + this.maintenanceModeLink = `${this.currentConfigurationTable} a[href*='shop/maintenance']`; + this.alertDangerPreUpgrade = `#${this.currentConfigurationTable} p.alert.alert-danger`; + } + + // Methods + // Pre-upgrade checklist table + /** + * Go to maintenance page + * @param page {Page} Browser tab + * @return {Promise} Opened tab after the click + */ + async goToMaintenancePage(page: Page): Promise { + return this.openLinkWithTargetBlank(page, this.maintenanceModeLink); + } + + /** + * Is requirements alert danger visible + * @param page {Page} Browser tab + * @return {Promise} + */ + async isRequirementsAlertDangerVisible(page: Page): Promise { + return this.elementVisible(page, this.alertDangerPreUpgrade, 2000); + } +} + +module.exports = new Autoupgrade(); From 4fce08144e82a586aacfdf7dd38d0cead6171e69 Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Wed, 18 Dec 2024 14:25:22 +0100 Subject: [PATCH 2/3] Fix review --- src/pages/BO/modules/autoupgrade/index.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/pages/BO/modules/autoupgrade/index.ts b/src/pages/BO/modules/autoupgrade/index.ts index 94358018..bdd33189 100644 --- a/src/pages/BO/modules/autoupgrade/index.ts +++ b/src/pages/BO/modules/autoupgrade/index.ts @@ -1,14 +1,8 @@ import type {ModuleAutoupgradeMainPageInterface} from '@interfaces/BO/modules/autoupgrade'; import testContext from '@utils/test'; -import semver from 'semver'; - -const psVersion = testContext.getPSVersion(); /* eslint-disable global-require, @typescript-eslint/no-require-imports */ function requirePage(): ModuleAutoupgradeMainPageInterface { - if (semver.gte(psVersion, '0.0.0')) { - return require('@versions/develop/pages/BO/modules/autoupgrade'); - } return require('@versions/develop/pages/BO/modules/autoupgrade'); } From de92e2d474f0cc26396057df8f85efdf71d19e99 Mon Sep 17 00:00:00 2001 From: nesrineabdmouleh Date: Wed, 18 Dec 2024 14:27:50 +0100 Subject: [PATCH 3/3] Fix review --- src/pages/BO/modules/autoupgrade/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/BO/modules/autoupgrade/index.ts b/src/pages/BO/modules/autoupgrade/index.ts index bdd33189..07bb6416 100644 --- a/src/pages/BO/modules/autoupgrade/index.ts +++ b/src/pages/BO/modules/autoupgrade/index.ts @@ -1,5 +1,4 @@ import type {ModuleAutoupgradeMainPageInterface} from '@interfaces/BO/modules/autoupgrade'; -import testContext from '@utils/test'; /* eslint-disable global-require, @typescript-eslint/no-require-imports */ function requirePage(): ModuleAutoupgradeMainPageInterface {