Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate @pages/BO/customerService/merchandiseReturns/edit from Core #354

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export {default as boMaintenancePage} from '@pages/BO/shopParameters/general/mai
export {default as boMarketplacePage} from '@pages/BO/modules/marketplace';
export {default as boInstalledModulesPage} from '@pages/BO/modules/modulesAndServices/installedModules';
export {default as boMerchandiseReturnsPage} from '@pages/BO/customerService/merchandiseReturns';
export {default as boMerchandiseReturnsEditPage} from '@pages/BO/customerService/merchandiseReturns/edit';
export {default as boModuleCatalogPage} from '@pages/BO/modules/moduleCatalog';
export {default as boModuleManagerAlertsPage} from '@pages/BO/modules/moduleManager/alerts';
export {default as boModuleManagerPage} from '@pages/BO/modules/moduleManager';
Expand Down
13 changes: 13 additions & 0 deletions src/interfaces/BO/customerService/merchandiseReturns/edit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {BOBasePagePageInterface} from '@interfaces/BO';
import {type Page} from '@playwright/test';

export interface BOMerchandiseReturnsEditPageInterface extends BOBasePagePageInterface {
readonly pageTitle: string;

clickOnCancelButton(page: Page): Promise<void>;
clickOnDeleteLastProductButton(page: Page, row?: number): Promise<string>;
deleteProduct(page: Page, row?: number): Promise<string>;
downloadPDF(page: Page): Promise<string | null>;
getFileName(page: Page): Promise<string>;
setStatus(page: Page, status: string, saveAndStay?: boolean): Promise<string>;
}
9 changes: 9 additions & 0 deletions src/pages/BO/customerService/merchandiseReturns/edit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {type BOMerchandiseReturnsEditPageInterface} from '@interfaces/BO/customerService/merchandiseReturns/edit';

/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
function requirePage(): BOMerchandiseReturnsEditPageInterface {
return require('@versions/develop/pages/BO/customerService/merchandiseReturns/edit');
}
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */

export default requirePage();
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import {type BOMerchandiseReturnsEditPageInterface} from '@interfaces/BO/customerService/merchandiseReturns/edit';
import BOBasePage from '@pages/BO/BOBasePage';
import {type Page} from '@playwright/test';

/**
* Edit merchandise returns page, contains selectors and functions for the page
* @class
* @extends BOBasePage
*/
class BOMerchandiseReturnsEditPage extends BOBasePage implements BOMerchandiseReturnsEditPageInterface {
public readonly pageTitle: string;

private readonly status: string;

private readonly productsTableRow: (row: number) => string;

private readonly productsTableDeleteColumn: (row: number) => string;

private readonly continueButton: string;

private readonly cancelButton: string;

private readonly orderReturnSaveButton: string;

private readonly orderReturnCancelButton: string;

private readonly saveAndStayButton: string;

private readonly fileName: string;

/**
* @constructs
* Setting up titles and selectors to use on edit merchandise return page
*/
constructor() {
super();

this.pageTitle = 'Merchandise Returns > Edit •';

// Selectors
this.status = '#state';
this.productsTableRow = (row: number) => `table tbody tr:nth-child(${row})`;
this.productsTableDeleteColumn = (row: number) => `${this.productsTableRow(row)} td a.btn-default`;
this.orderReturnSaveButton = '#order_return_form_submit_btn';
this.orderReturnCancelButton = '#order_return_form_cancel_btn';
this.saveAndStayButton = 'button[name=submitAddorder_returnAndStay]';
this.fileName = '#fieldset_0 div.form-wrapper div:nth-child(8) div p:nth-child(1)';
// Selectors in security page
this.continueButton = 'body div.container div.action-container a.btn-continue';
this.cancelButton = 'body div.container div.action-container a.btn-cancel';
}

/*
Methods
*/
/**
* Set merchandise return status
* @param page {Page} Browser tab
* @param status {string} Status to select
* @param saveAndStay {boolean} True if we need to click on save and stay button
* @returns {Promise<string>}
*/
async setStatus(page: Page, status: string, saveAndStay: boolean = false): Promise<string> {
await this.selectByVisibleText(page, this.status, status);
if (saveAndStay) {
await this.clickAndWaitForURL(page, this.saveAndStayButton);
} else {
await this.clickAndWaitForURL(page, this.orderReturnSaveButton);
}
return this.getAlertSuccessBlockContent(page);
}

/**
* Get file name
* @param page {Page} Browser tab
* @returns {Promise<string>}
*/
async getFileName(page: Page): Promise<string> {
return this.getTextContent(page, this.fileName);
}

/**
* Download PDF
* @param page {Page} Browser tab
* @returns {Promise<string | null>}
*/
async downloadPDF(page: Page): Promise<string | null> {
return this.clickAndWaitForDownload(page, `${this.fileName} a`);
}

/**
* Click on cancel button
* @param page {Page} Browser tab
* @returns {Promise<void>}
*/
async clickOnCancelButton(page: Page): Promise<void> {
await this.waitForSelectorAndClick(page, this.orderReturnCancelButton);
await this.clickAndWaitForURL(page, this.orderReturnCancelButton);
}

/**
* Click on delete last product button
* @param page {Page} Browser tab
* @param row {number} Row in products table
* @returns {Promise<string>}
*/
async clickOnDeleteLastProductButton(page: Page, row: number = 1): Promise<string> {
await this.clickAndWaitForURL(page, this.productsTableDeleteColumn(row));

return this.getTextContent(page, this.alertBlock);
}

/**
* Delete product
* @param page {Page} Browser tab
* @param row {number} Row in products table
* @returns {Promise<string>}
*/
async deleteProduct(page: Page, row: number = 1): Promise<string> {
await this.clickAndWaitForURL(page, this.productsTableDeleteColumn(row));

return this.getTextContent(page, this.alertBlock);
}
}

module.exports = new BOMerchandiseReturnsEditPage();
Loading