Skip to content

Commit

Permalink
Merge pull request #152 from Progi1984/boDesignEmailThemesPage
Browse files Browse the repository at this point in the history
Migrate `@pages/BO/design/emailThemes` from Core
  • Loading branch information
Progi1984 authored Sep 24, 2024
2 parents 0597de4 + c12de9e commit 025c1a9
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
10 changes: 10 additions & 0 deletions src/interfaces/BO/design/emailThemes/index.ts
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>;
}
9 changes: 9 additions & 0 deletions src/pages/BO/design/emailThemes/index.ts
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();
92 changes: 92 additions & 0 deletions src/versions/develop/pages/BO/design/emailThemes/index.ts
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();

0 comments on commit 025c1a9

Please sign in to comment.