diff --git a/src/index.ts b/src/index.ts index 764dad67..bc624e2c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -203,7 +203,8 @@ export {default as boCurrenciesPage} from '@pages/BO/international/localization/ export {default as boCustomersPage} from '@pages/BO/customers'; export {default as boDashboardPage} from '@pages/BO/dashboard'; export {default as boDbBackupPage} from '@pages/BO/advancedParameters/database/dbBackup'; -export {default as boDesignPositionsPage} from '@pages/BO/design/positions/index'; +export {default as boDesignEmailThemesPage} from '@pages/BO/design/emailThemes'; +export {default as boDesignPositionsPage} from '@pages/BO/design/positions'; export {default as boDesignPositionsHookModulePage} from '@pages/BO/design/positions/hookModule'; export {default as boInformationPage} from '@pages/BO/advancedParameters/information'; export {default as boLocalizationPage} from '@pages/BO/international/localization'; diff --git a/src/interfaces/BO/design/emailThemes/index.ts b/src/interfaces/BO/design/emailThemes/index.ts new file mode 100644 index 00000000..4540a6c0 --- /dev/null +++ b/src/interfaces/BO/design/emailThemes/index.ts @@ -0,0 +1,10 @@ +import {BOBasePagePageInterface} from '@interfaces/BO'; +import {type Page} from '@playwright/test'; + +export interface BODesignEmailThemesPageInterface extends BOBasePagePageInterface { + readonly emailThemeConfigurationSuccessfulMessage: string; + readonly pageTitle: string; + + previewEmailTheme(page: Page, name: string): Promise; + selectDefaultEmailTheme(page: Page, emailTheme: string): Promise; +} diff --git a/src/pages/BO/design/emailThemes/index.ts b/src/pages/BO/design/emailThemes/index.ts new file mode 100644 index 00000000..268c5dc6 --- /dev/null +++ b/src/pages/BO/design/emailThemes/index.ts @@ -0,0 +1,9 @@ +import {BODesignEmailThemesPageInterface} from '@interfaces/BO/design/emailThemes'; + +/* eslint-disable global-require, @typescript-eslint/no-var-requires */ +function requirePage(): BODesignEmailThemesPageInterface { + return require('@versions/develop/pages/BO/design/emailThemes'); +} +/* eslint-enable global-require, @typescript-eslint/no-var-requires */ + +export default requirePage(); diff --git a/src/versions/develop/pages/BO/design/emailThemes/index.ts b/src/versions/develop/pages/BO/design/emailThemes/index.ts new file mode 100644 index 00000000..5c0a3c2f --- /dev/null +++ b/src/versions/develop/pages/BO/design/emailThemes/index.ts @@ -0,0 +1,92 @@ +import {type BODesignEmailThemesPageInterface} from '@interfaces/BO/design/emailThemes'; +import BOBasePage from '@pages/BO/BOBasePage'; +import {type Page} from '@playwright/test'; + +/** + * Email theme page, contains functions that can be used on the page + * @class + * @extends BOBasePage + */ +class BODesignEmailThemesPage extends BOBasePage implements BODesignEmailThemesPageInterface { + public readonly pageTitle: string; + + public readonly emailThemeConfigurationSuccessfulMessage: string; + + private readonly defaultEmailThemeSelect: string; + + private readonly configurationFormSaveButton: string; + + private readonly emailThemeTable: string; + + private readonly tableBody: string; + + private readonly tableRows: string; + + private readonly columnName: string; + + private readonly columnActionPreviewLink: string; + + /** + * @constructs + * Setting up texts and selectors to use on email theme page + */ + constructor() { + super(); + + this.pageTitle = `Email theme • ${global.INSTALL.SHOP_NAME}`; + this.emailThemeConfigurationSuccessfulMessage = 'Email theme configuration saved successfully'; + + // Configuration form selectors + this.defaultEmailThemeSelect = '#form_defaultTheme'; + this.configurationFormSaveButton = '#save-configuration-form'; + + // Email Theme table selectors + this.emailThemeTable = 'table.grid-table'; + this.tableBody = `${this.emailThemeTable} tbody`; + this.tableRows = `${this.tableBody} tr`; + this.columnName = 'td.column-name'; + this.columnActionPreviewLink = 'td.action-type a.preview-link'; + } + + /* Configuration form methods */ + + /** + * Choose default email theme and save configuration + * @param page {Page} Browser tab + * @param emailTheme {string} Value of email theme to select + * @return {Promise} + */ + async selectDefaultEmailTheme(page: Page, emailTheme: string): Promise { + await this.selectByVisibleText(page, this.defaultEmailThemeSelect, emailTheme); + await this.clickAndWaitForLoadState(page, this.configurationFormSaveButton); + + return this.getAlertSuccessBlockParagraphContent(page); + } + + /* Email themes grid methods */ + /** + * Preview email theme + * @param page {Page} Browser tab + * @param name {string} Value of theme to choose + * @return {Promise} + */ + async previewEmailTheme(page: Page, name: string): Promise { + const rowLocator = page + .locator(this.tableRows) + .filter({hasText: name}) + .first(); + + if ((await rowLocator.textContent()) === null) { + throw Error(`${name} was not found in theme emails table`); + } + + await Promise.all([ + rowLocator + .locator(this.columnActionPreviewLink) + .evaluate((el: HTMLElement) => el.click()), + page.waitForURL('**/mail_theme/preview/**'), + ]); + } +} + +module.exports = new BODesignEmailThemesPage();