Skip to content
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/interfaces/BO/payment/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {type Page} from '@playwright/test';
export interface BOPaymentPreferencesPageInterface extends BOBasePagePageInterface {
readonly pageTitle: string;

getGroupRestrictionNames(page: Page): Promise<string[]>;
setCarrierRestriction(page: Page, carrierID: number, paymentModule: string, valueWanted: boolean): Promise<string>;
setCountryRestriction(page: Page, countryID: number, paymentModule: string, valueWanted: boolean): Promise<string>;
setCurrencyRestriction(page: Page, paymentModule: string, valueWanted: boolean): Promise<string>;
Expand Down
26 changes: 26 additions & 0 deletions src/versions/develop/pages/BO/payment/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class BOPaymentPreferencesPage extends BOBasePage implements BOPaymentPreference

private readonly groupRestrictionsSaveButton: string;

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

private readonly groupRestrictionsTableRows: string;

private readonly carrierRestrictionsCheckbox: (paymentModule: string, carrierID: number) => string;

private readonly carrierRestrictionSaveButton: string;
Expand All @@ -42,6 +46,9 @@ class BOPaymentPreferencesPage extends BOBasePage implements BOPaymentPreference
this.countryRestrictionsCheckbox = (paymentModule: string, countryID: number) => 'input[id^="form_country_restrictions_'
+ `${paymentModule}_"][value="${countryID}"]`;
this.groupRestrictionsSaveButton = '#form-group-restrictions-save-button';
// One row per customer group in the group restrictions table, the group name being the first cell.
this.groupRestrictionsTableRows = `div.card:has(${this.groupRestrictionsSaveButton}) table tbody tr`;
this.groupRestrictionsTableRow = (row: number) => `${this.groupRestrictionsTableRows}:nth-child(${row})`;
// Selectors fot carrier restriction
this.carrierRestrictionsCheckbox = (paymentModule: string, carrierID: number) => '#form_carrier_restrictions_'
+ `${paymentModule}_${carrierID}`;
Expand Down Expand Up @@ -123,6 +130,25 @@ class BOPaymentPreferencesPage extends BOBasePage implements BOPaymentPreference
await page.locator(this.carrierRestrictionSaveButton).click();
return this.getAlertSuccessBlockParagraphContent(page);
}

/**
* Get the names of the customer groups listed in the group restrictions table.
* In a multishop context, only the groups of the currently selected shop should be listed.
* @param page {Page} Browser tab
* @returns {Promise<string[]>}
*/
async getGroupRestrictionNames(page: Page): Promise<string[]> {
await this.waitForVisibleSelector(page, this.groupRestrictionsSaveButton);

const rowsNumber = await page.locator(this.groupRestrictionsTableRows).count();
const groupNames: string[] = [];

for (let row = 1; row <= rowsNumber; row++) {
groupNames.push(await this.getTextContent(page, `${this.groupRestrictionsTableRow(row)} td:first-child`));
}

return groupNames;
}
}

module.exports = new BOPaymentPreferencesPage();
Loading