Skip to content

Commit

Permalink
Merge pull request #427 from Progi1984/modContactFormBoMain
Browse files Browse the repository at this point in the history
Migrate `@pages/BO/modules/contactform` from Core
  • Loading branch information
Progi1984 authored Feb 20, 2025
2 parents 3d1cd15 + e633525 commit 8cff347
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ export {default as foHummingbirdSitemapPage} from '@pages/FO/hummingbird/sitemap
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 modContactFormBoMain} from '@pages/BO/modules/contactform';
export {default as modKeycloakConnectorDemoBoMain} from '@pages/BO/modules/keycloakConnectorDemo';
export {default as modProductCommentsBoMain} from '@pages/BO/modules/productcomments';
export {default as modPsCategoryProductsBoMain} from '@pages/BO/modules/ps_categoryproducts';
Expand Down
9 changes: 9 additions & 0 deletions src/interfaces/BO/modules/contactform/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {ModuleConfigurationPageInterface} from '@interfaces/BO/modules/moduleConfiguration';
import {Page} from '@playwright/test';

export interface ModuleContactFormMainPageInterface extends ModuleConfigurationPageInterface {
readonly pageTitle: string;

setReceiveCustomersMessageByEmail(page: Page, toEnable: boolean): Promise<string>;
setSendConfirmationEmail(page: Page, toEnable: boolean): Promise<string>;
}
9 changes: 9 additions & 0 deletions src/pages/BO/modules/contactform/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type {ModuleContactFormMainPageInterface} from '@interfaces/BO/modules/contactform';

/* eslint-disable global-require, @typescript-eslint/no-require-imports */
function requirePage(): ModuleContactFormMainPageInterface {
return require('@versions/develop/pages/BO/modules/contactform');
}
/* eslint-enable global-require, @typescript-eslint/no-require-imports */

export default requirePage();
64 changes: 64 additions & 0 deletions src/versions/develop/pages/BO/modules/contactform/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import {type ModuleContactFormMainPageInterface} from '@interfaces/BO/modules/contactform';
import ModuleConfiguration from '@pages/BO/modules/moduleConfiguration';
import {Page} from '@playwright/test';

/**
* Module configuration page for module : contactform, contains selectors and functions for the page
* @class
* @extends ModuleConfiguration
*/
class ModuleContactFormMainPage extends ModuleConfiguration implements ModuleContactFormMainPageInterface {
public readonly pageTitle: string;

private readonly sendConfirmationEmailToggle: (toggle: string) => string;

private readonly sendNotificationEmailToggle: (toggle: string) => string;

private readonly saveButton: string;

/**
* @constructs
* Setting up titles and selectors to use on contact form page
*/
constructor() {
super();

this.pageTitle = 'Contact form';
this.successfulUpdateMessage = 'The settings have been successfully updated.';

// Selectors
this.sendConfirmationEmailToggle = (toggle: string) => `#CONTACTFORM_SEND_CONFIRMATION_EMAIL_${toggle}`;
this.sendNotificationEmailToggle = (toggle: string) => `#CONTACTFORM_SEND_NOTIFICATION_EMAIL_${toggle}`;
this.saveButton = '#module_form_submit_btn';
}

/* Methods */

/**
* Set send confirmation email
* @param page {Page} Browser tab
* @param toEnable {boolean} True if we need to enable send confirmation email
* @returns {Promise<number>}
*/
async setSendConfirmationEmail(page: Page, toEnable: boolean): Promise<string> {
await this.setChecked(page, this.sendConfirmationEmailToggle(toEnable ? 'on' : 'off'));
await this.clickAndWaitForLoadState(page, this.saveButton);

return this.getAlertSuccessBlockContent(page);
}

/**
* Set send confirmation email
* @param page {Page} Browser tab
* @param toEnable {boolean} True if we need to enable receive customers message by email
* @returns {Promise<number>}
*/
async setReceiveCustomersMessageByEmail(page: Page, toEnable: boolean): Promise<string> {
await this.setChecked(page, this.sendNotificationEmailToggle(toEnable ? 'on' : 'off'));
await this.clickAndWaitForLoadState(page, this.saveButton);

return this.getAlertSuccessBlockContent(page);
}
}

module.exports = new ModuleContactFormMainPage();

0 comments on commit 8cff347

Please sign in to comment.