Skip to content

Commit eb56f4d

Browse files
authored
Merge pull request #990 from PrestaEdit/fix-9858-payment-group-restrictions-shop-filter
Add getGroupRestrictionNames to BO payment preferences page object
2 parents 73ac4de + 0b83d19 commit eb56f4d

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/interfaces/BO/payment/preferences.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {type Page} from '@playwright/test';
44
export interface BOPaymentPreferencesPageInterface extends BOBasePagePageInterface {
55
readonly pageTitle: string;
66

7+
getGroupRestrictionNames(page: Page): Promise<string[]>;
78
setCarrierRestriction(page: Page, carrierID: number, paymentModule: string, valueWanted: boolean): Promise<string>;
89
setCountryRestriction(page: Page, countryID: number, paymentModule: string, valueWanted: boolean): Promise<string>;
910
setCurrencyRestriction(page: Page, paymentModule: string, valueWanted: boolean): Promise<string>;

src/versions/develop/pages/BO/payment/preferences.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class BOPaymentPreferencesPage extends BOBasePage implements BOPaymentPreference
2020

2121
private readonly groupRestrictionsSaveButton: string;
2222

23+
private readonly groupRestrictionsTableRow: (row: number) => string;
24+
25+
private readonly groupRestrictionsTableRows: string;
26+
2327
private readonly carrierRestrictionsCheckbox: (paymentModule: string, carrierID: number) => string;
2428

2529
private readonly carrierRestrictionSaveButton: string;
@@ -42,6 +46,9 @@ class BOPaymentPreferencesPage extends BOBasePage implements BOPaymentPreference
4246
this.countryRestrictionsCheckbox = (paymentModule: string, countryID: number) => 'input[id^="form_country_restrictions_'
4347
+ `${paymentModule}_"][value="${countryID}"]`;
4448
this.groupRestrictionsSaveButton = '#form-group-restrictions-save-button';
49+
// One row per customer group in the group restrictions table, the group name being the first cell.
50+
this.groupRestrictionsTableRows = `div.card:has(${this.groupRestrictionsSaveButton}) table tbody tr`;
51+
this.groupRestrictionsTableRow = (row: number) => `${this.groupRestrictionsTableRows}:nth-child(${row})`;
4552
// Selectors fot carrier restriction
4653
this.carrierRestrictionsCheckbox = (paymentModule: string, carrierID: number) => '#form_carrier_restrictions_'
4754
+ `${paymentModule}_${carrierID}`;
@@ -123,6 +130,25 @@ class BOPaymentPreferencesPage extends BOBasePage implements BOPaymentPreference
123130
await page.locator(this.carrierRestrictionSaveButton).click();
124131
return this.getAlertSuccessBlockParagraphContent(page);
125132
}
133+
134+
/**
135+
* Get the names of the customer groups listed in the group restrictions table.
136+
* In a multishop context, only the groups of the currently selected shop should be listed.
137+
* @param page {Page} Browser tab
138+
* @returns {Promise<string[]>}
139+
*/
140+
async getGroupRestrictionNames(page: Page): Promise<string[]> {
141+
await this.waitForVisibleSelector(page, this.groupRestrictionsSaveButton);
142+
143+
const rowsNumber = await page.locator(this.groupRestrictionsTableRows).count();
144+
const groupNames: string[] = [];
145+
146+
for (let row = 1; row <= rowsNumber; row++) {
147+
groupNames.push(await this.getTextContent(page, `${this.groupRestrictionsTableRow(row)} td:first-child`));
148+
}
149+
150+
return groupNames;
151+
}
126152
}
127153

128154
module.exports = new BOPaymentPreferencesPage();

0 commit comments

Comments
 (0)