@@ -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
128154module . exports = new BOPaymentPreferencesPage ( ) ;
0 commit comments