diff --git a/src/index.ts b/src/index.ts index d4a814ceb..3ec2f2216 100644 --- a/src/index.ts +++ b/src/index.ts @@ -463,6 +463,7 @@ export {default as foHummingbirdTermsAndConditionsOfUsePage} from '@pages/FO/hum // Export Modules export {default as modAutoupgradeBoMain} from '@pages/BO/modules/autoupgrade'; +export {default as modAutoupgradeBoModal} from '@pages/BO/modules/autoupgrade/modal'; export {default as modBlockwishlistBoMain} from '@pages/BO/modules/blockwishlist'; export {default as modBlockwishlistBoStatistics} from '@pages/BO/modules/blockwishlist/statistics'; export {default as modContactFormBoMain} from '@pages/BO/modules/contactform'; diff --git a/src/interfaces/BO/dashboard/index.ts b/src/interfaces/BO/dashboard/index.ts index 2728a476f..3a6ed87f1 100644 --- a/src/interfaces/BO/dashboard/index.ts +++ b/src/interfaces/BO/dashboard/index.ts @@ -19,7 +19,6 @@ export interface DashboardPageInterface extends BOBasePagePageInterface { clickOnReturnExchangeLink(page: Page): Promise; clickOnTotalSubscribersLink(page: Page): Promise; clickOnVisitsLink(page: Page): Promise; - closeDialogUpdateNotification(page: Page): Promise; closeHelpCard(page: Page): Promise; getFormActivityOverviewValue(page: Page, inputName: string): Promise; getBestSellersTabTitle(page: Page): Promise; diff --git a/src/interfaces/BO/modules/autoupgrade/modal.ts b/src/interfaces/BO/modules/autoupgrade/modal.ts new file mode 100644 index 000000000..5985b7ea8 --- /dev/null +++ b/src/interfaces/BO/modules/autoupgrade/modal.ts @@ -0,0 +1,11 @@ +import {ModuleConfigurationPageInterface} from '@interfaces/BO/modules/moduleConfiguration'; +import type {Page} from '@playwright/test'; + +export interface ModuleAutoupgradeModalPageInterface extends ModuleConfigurationPageInterface { + clickOnUpdateButton(page:Page):Promise; + closeDialogUpdateNotification(page: Page): Promise; + getPSVersionFromTheModal(page:Page):Promise; + getSupportLinkFromModal(page:Page):Promise; + getUpdateLinkFromModal(page:Page):Promise; + openUpdateLinkFromTheModal(page:Page):Promise; +} diff --git a/src/pages/BO/modules/autoupgrade/modal.ts b/src/pages/BO/modules/autoupgrade/modal.ts new file mode 100644 index 000000000..04629cd67 --- /dev/null +++ b/src/pages/BO/modules/autoupgrade/modal.ts @@ -0,0 +1,10 @@ +import type {ModuleAutoupgradeModalPageInterface} from '@interfaces/BO/modules/autoupgrade/modal'; + +/* eslint-disable global-require, @typescript-eslint/no-require-imports */ +function requirePage(): ModuleAutoupgradeModalPageInterface { + return require('@versions/develop/pages/BO/modules/autoupgrade/modal').autoupgradeModal; +} + +/* eslint-enable global-require, @typescript-eslint/no-require-imports */ + +export default requirePage(); diff --git a/src/versions/develop/pages/BO/dashboard/index.ts b/src/versions/develop/pages/BO/dashboard/index.ts index 1c854d1b9..1bcce8cb3 100644 --- a/src/versions/develop/pages/BO/dashboard/index.ts +++ b/src/versions/develop/pages/BO/dashboard/index.ts @@ -151,12 +151,6 @@ class Dashboard extends BOBasePage implements DashboardPageInterface { private readonly helpCardDocumentTitle: string; - private readonly dialogUpdateNotification: string; - - private readonly remindMeLaterButton: string; - - private readonly remindMeLaterSevenDaysButton: string; - /** * @constructs * Setting up titles and selectors to use on dashboard page @@ -174,10 +168,6 @@ class Dashboard extends BOBasePage implements DashboardPageInterface { this.helpCardButton = '#toolbar-nav a.btn-help'; this.helpCardDocument = '#help-container div.page-wrap'; this.helpCardDocumentTitle = '#help-container section.article h1'; - // Selectors of update dialog - this.dialogUpdateNotification = '#dialog-update-notification'; - this.remindMeLaterButton = '#remin-me-later-update'; - this.remindMeLaterSevenDaysButton = `${this.remindMeLaterButton} button[value='7_days']`; // Selectors of Products and sales block this.recentOrdersTitle = '#dash_recent_orders div.panel-heading'; this.recentOrdersTable = '#table_recent_orders'; @@ -765,20 +755,6 @@ class Dashboard extends BOBasePage implements DashboardPageInterface { async getHelpDocumentTitle(page: Page): Promise { return this.getTextContent(page, this.helpCardDocumentTitle); } - - /** - * Close dialog update notification - * @param page {Page} Browser tab - * @returns {Promise} - */ - async closeDialogUpdateNotification(page: Page): Promise { - if (await this.elementVisible(page, this.dialogUpdateNotification, 5000)) { - await page.locator(this.remindMeLaterButton).click(); - await page.locator(this.remindMeLaterSevenDaysButton).click(); - } - - return this.elementNotVisible(page, this.dialogUpdateNotification, 5000); - } } module.exports = new Dashboard(); diff --git a/src/versions/develop/pages/BO/modules/autoupgrade/modal.ts b/src/versions/develop/pages/BO/modules/autoupgrade/modal.ts new file mode 100644 index 000000000..8f5b75e8c --- /dev/null +++ b/src/versions/develop/pages/BO/modules/autoupgrade/modal.ts @@ -0,0 +1,106 @@ +import {ModuleAutoupgradeModalPageInterface} from '@interfaces/BO/modules/autoupgrade/modal'; +import type {Page} from '@playwright/test'; +import {ModuleConfigurationPage} from '@versions/develop/pages/BO/modules/moduleConfiguration'; + +/** + * Module configuration page for module : Autoupgrade, contains selectors and functions for the page + * @class + * @extends ModuleConfiguration + */ +class AutoupgradeModal extends ModuleConfigurationPage implements ModuleAutoupgradeModalPageInterface { + private readonly dialogUpdateNotification: string; + + private readonly remindMeLaterButton: string; + + private readonly remindMeLaterSevenDaysButton: string; + + private readonly dialogNotificationSection: string; + + private readonly updateLink: string; + + private readonly supportLink: string; + + private readonly psVersionLink: string; + + private readonly updateButton: string; + + /** + * @constructs + */ + constructor() { + super(); + + // Selectors of update dialog + this.dialogUpdateNotification = '#dialog-update-notification'; + this.remindMeLaterButton = '#remin-me-later-update'; + this.remindMeLaterSevenDaysButton = `${this.remindMeLaterButton} button[value='7_days']`; + this.dialogNotificationSection = 'div.dialog-notification__section'; + this.updateLink = `${this.dialogNotificationSection}:nth-child(1) .dialog-notification__link`; + this.supportLink = `${this.dialogNotificationSection}:nth-child(4) .dialog-notification__link`; + this.psVersionLink = `${this.dialogNotificationSection}.dialog-notification__section-content`; + this.updateButton = '.dialog-notification__button.btn-primary'; + } + + // Methods of update + /** + * Close dialog update notification + * @param page {Page} Browser tab + * @returns {Promise} + */ + async closeDialogUpdateNotification(page: Page): Promise { + if (await this.elementVisible(page, this.dialogUpdateNotification, 5000)) { + await page.locator(this.remindMeLaterButton).click(); + await page.locator(this.remindMeLaterSevenDaysButton).click(); + } + + return this.elementNotVisible(page, this.dialogUpdateNotification, 5000); + } + + /** + * Get update link from modal + * @param page {Page} Browser tab + * @returns {Promise} + */ + async getUpdateLinkFromModal(page: Page): Promise { + return this.getAttributeContent(page, this.updateLink, 'href'); + } + + /** + * Get support link from modal + * @param page {Page} Browser tab + * @returns {Promise} + */ + async getSupportLinkFromModal(page: Page): Promise { + return this.getAttributeContent(page, this.supportLink, 'href'); + } + + /** + * Open update link from the modal + * @param page {Page} Browser tab + * @returns {Promise { + return this.openLinkWithTargetBlank(page, this.updateLink, '.post-title'); + } + + /** + * Get PS version from the modal + * @param page {Page} Browser tab + * @returns {Promise} + */ + async getPSVersionFromTheModal(page: Page): Promise { + return this.getTextContent(page, this.psVersionLink); + } + + /** + * Click on update button + * @param page {Page} Browser tab + * @returns {Promise} + */ + async clickOnUpdateButton(page: Page): Promise { + await this.clickAndWaitForURL(page, this.updateButton); + } +} + +const autoupgradeModal = new AutoupgradeModal(); +export {autoupgradeModal, AutoupgradeModal};