-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #444 from Progi1984/boShippingPreferencesPage
Migrate `@pages/BO/shipping/preferences` from Core
- Loading branch information
Showing
4 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type FakerCarrier from '@data/faker/carrier'; | ||
import {BOBasePagePageInterface} from '@interfaces/BO'; | ||
import {type Page} from '@playwright/test'; | ||
|
||
export interface BOShippingPreferencesInterface extends BOBasePagePageInterface { | ||
readonly pageTitle: string; | ||
|
||
setCarrierSortOrderBy(page: Page, sortBy: string, orderBy?: string): Promise<string>; | ||
setDefaultCarrier(page: Page, carrier: FakerCarrier): Promise<string>; | ||
setHandlingCharges(page: Page, value: string): Promise<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type {BOShippingPreferencesInterface} from '@interfaces/BO/shipping/preferences'; | ||
|
||
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
function requirePage(): BOShippingPreferencesInterface { | ||
return require('@versions/develop/pages/BO/shipping/preferences'); | ||
} | ||
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
|
||
export default requirePage(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import type FakerCarrier from '@data/faker/carrier'; | ||
import {type BOShippingPreferencesInterface} from '@interfaces/BO/shipping/preferences'; | ||
import BOBasePage from '@pages/BO/BOBasePage'; | ||
import {type Page} from '@playwright/test'; | ||
|
||
class BOShippingPreferences extends BOBasePage implements BOShippingPreferencesInterface { | ||
public readonly pageTitle: string; | ||
|
||
private readonly handlingForm: string; | ||
|
||
private readonly handlingChargesInput: string; | ||
|
||
private readonly saveHandlingButton: string; | ||
|
||
private readonly carrierOptionForm: string; | ||
|
||
private readonly defaultCarrierSelect: string; | ||
|
||
private readonly sortBySelect: string; | ||
|
||
private readonly orderBySelect: string; | ||
|
||
private readonly saveCarrierOptionsButton: string; | ||
|
||
constructor() { | ||
super(); | ||
|
||
this.pageTitle = 'Preferences •'; | ||
this.successfulUpdateMessage = 'Update successful'; | ||
|
||
// Handling form selectors | ||
this.handlingForm = '#handling'; | ||
this.handlingChargesInput = '#handling_shipping_handling_charges'; | ||
this.saveHandlingButton = `${this.handlingForm} button`; | ||
|
||
// Carrier options selectors | ||
this.carrierOptionForm = '#carrier-options'; | ||
this.defaultCarrierSelect = '#carrier-options_default_carrier'; | ||
this.sortBySelect = '#carrier-options_carrier_default_order_by'; | ||
this.orderBySelect = '#carrier-options_carrier_default_order_way'; | ||
this.saveCarrierOptionsButton = `${this.carrierOptionForm} button`; | ||
} | ||
|
||
/* Handling methods */ | ||
|
||
/** | ||
* Set handling charges button | ||
* @param page {Page} Browser tab | ||
* @param value {string} The handling charges value | ||
* @returns {Promise<string>} | ||
*/ | ||
async setHandlingCharges(page: Page, value: string): Promise<string> { | ||
await this.setValue(page, this.handlingChargesInput, value); | ||
|
||
// Save handling form and return successful message | ||
await page.locator(this.saveHandlingButton).click(); | ||
return this.getAlertSuccessBlockParagraphContent(page); | ||
} | ||
|
||
/* Carrier options methods */ | ||
|
||
/** | ||
* Set default carrier in carrier options form | ||
* @param page {Page} Browser tab | ||
* @param carrier {FakerCarrier} List of carriers | ||
* @return {Promise<string>} | ||
*/ | ||
async setDefaultCarrier(page: Page, carrier: FakerCarrier): Promise<string> { | ||
await this.selectByVisibleText( | ||
page, | ||
this.defaultCarrierSelect, | ||
`${carrier.id} - ${carrier.name} (${carrier.transitName})`, | ||
); | ||
|
||
// Save configuration and return successful message | ||
await page.locator(this.saveCarrierOptionsButton).click(); | ||
return this.getAlertSuccessBlockParagraphContent(page); | ||
} | ||
|
||
/** | ||
* Set carriers sort By 'Price' or 'Position' / order by 'Ascending' or 'descending' in carrier options form | ||
* @param page {Page} Browser tab | ||
* @param sortBy {String} Sort by 'Price' or 'Position' | ||
* @param orderBy {String} Order by 'Ascending' or 'Descending' | ||
* @returns {Promise<string>} | ||
*/ | ||
async setCarrierSortOrderBy(page: Page, sortBy: string, orderBy: string = 'Ascending'): Promise<string> { | ||
await this.selectByVisibleText(page, this.sortBySelect, sortBy); | ||
await this.selectByVisibleText(page, this.orderBySelect, orderBy); | ||
|
||
// Save configuration and return successful message | ||
await page.locator(this.saveCarrierOptionsButton).click(); | ||
return this.getAlertSuccessBlockParagraphContent(page); | ||
} | ||
} | ||
|
||
module.exports = new BOShippingPreferences(); |