-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from Progi1984/boDesignEmailThemesPage
Migrate `@pages/BO/design/emailThemes` from Core
- Loading branch information
Showing
4 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<void>; | ||
selectDefaultEmailTheme(page: Page, emailTheme: string): Promise<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string>} | ||
*/ | ||
async selectDefaultEmailTheme(page: Page, emailTheme: string): Promise<string> { | ||
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<void>} | ||
*/ | ||
async previewEmailTheme(page: Page, name: string): Promise<void> { | ||
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(); |