Skip to content

Commit 3e139f9

Browse files
authored
Merge pull request #444 from Progi1984/boShippingPreferencesPage
Migrate `@pages/BO/shipping/preferences` from Core
2 parents 85d2a8c + fcec1ca commit 3e139f9

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ export {default as boSearchPage} from '@pages/BO/shopParameters/search';
311311
export {default as boSearchAliasPage} from '@pages/BO/shopParameters/search/alias';
312312
export {default as boSearchAliasCreatePage} from '@pages/BO/shopParameters/search/alias/create';
313313
export {default as boSecurityPage} from '@pages/BO/advancedParameters/security';
314+
export {default as boShippingPreferencesPage} from '@pages/BO/shipping/preferences';
314315
export {default as boShopParametersPage} from '@pages/BO/shopParameters/general';
315316
export {default as boShoppingCartsPage} from '@pages/BO/orders/shoppingCarts';
316317
export {default as boShoppingCartsViewPage} from '@pages/BO/orders/shoppingCarts/view';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type FakerCarrier from '@data/faker/carrier';
2+
import {BOBasePagePageInterface} from '@interfaces/BO';
3+
import {type Page} from '@playwright/test';
4+
5+
export interface BOShippingPreferencesInterface extends BOBasePagePageInterface {
6+
readonly pageTitle: string;
7+
8+
setCarrierSortOrderBy(page: Page, sortBy: string, orderBy?: string): Promise<string>;
9+
setDefaultCarrier(page: Page, carrier: FakerCarrier): Promise<string>;
10+
setHandlingCharges(page: Page, value: string): Promise<string>;
11+
}

src/pages/BO/shipping/preferences.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type {BOShippingPreferencesInterface} from '@interfaces/BO/shipping/preferences';
2+
3+
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
4+
function requirePage(): BOShippingPreferencesInterface {
5+
return require('@versions/develop/pages/BO/shipping/preferences');
6+
}
7+
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
8+
9+
export default requirePage();
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import type FakerCarrier from '@data/faker/carrier';
2+
import {type BOShippingPreferencesInterface} from '@interfaces/BO/shipping/preferences';
3+
import BOBasePage from '@pages/BO/BOBasePage';
4+
import {type Page} from '@playwright/test';
5+
6+
class BOShippingPreferences extends BOBasePage implements BOShippingPreferencesInterface {
7+
public readonly pageTitle: string;
8+
9+
private readonly handlingForm: string;
10+
11+
private readonly handlingChargesInput: string;
12+
13+
private readonly saveHandlingButton: string;
14+
15+
private readonly carrierOptionForm: string;
16+
17+
private readonly defaultCarrierSelect: string;
18+
19+
private readonly sortBySelect: string;
20+
21+
private readonly orderBySelect: string;
22+
23+
private readonly saveCarrierOptionsButton: string;
24+
25+
constructor() {
26+
super();
27+
28+
this.pageTitle = 'Preferences •';
29+
this.successfulUpdateMessage = 'Update successful';
30+
31+
// Handling form selectors
32+
this.handlingForm = '#handling';
33+
this.handlingChargesInput = '#handling_shipping_handling_charges';
34+
this.saveHandlingButton = `${this.handlingForm} button`;
35+
36+
// Carrier options selectors
37+
this.carrierOptionForm = '#carrier-options';
38+
this.defaultCarrierSelect = '#carrier-options_default_carrier';
39+
this.sortBySelect = '#carrier-options_carrier_default_order_by';
40+
this.orderBySelect = '#carrier-options_carrier_default_order_way';
41+
this.saveCarrierOptionsButton = `${this.carrierOptionForm} button`;
42+
}
43+
44+
/* Handling methods */
45+
46+
/**
47+
* Set handling charges button
48+
* @param page {Page} Browser tab
49+
* @param value {string} The handling charges value
50+
* @returns {Promise<string>}
51+
*/
52+
async setHandlingCharges(page: Page, value: string): Promise<string> {
53+
await this.setValue(page, this.handlingChargesInput, value);
54+
55+
// Save handling form and return successful message
56+
await page.locator(this.saveHandlingButton).click();
57+
return this.getAlertSuccessBlockParagraphContent(page);
58+
}
59+
60+
/* Carrier options methods */
61+
62+
/**
63+
* Set default carrier in carrier options form
64+
* @param page {Page} Browser tab
65+
* @param carrier {FakerCarrier} List of carriers
66+
* @return {Promise<string>}
67+
*/
68+
async setDefaultCarrier(page: Page, carrier: FakerCarrier): Promise<string> {
69+
await this.selectByVisibleText(
70+
page,
71+
this.defaultCarrierSelect,
72+
`${carrier.id} - ${carrier.name} (${carrier.transitName})`,
73+
);
74+
75+
// Save configuration and return successful message
76+
await page.locator(this.saveCarrierOptionsButton).click();
77+
return this.getAlertSuccessBlockParagraphContent(page);
78+
}
79+
80+
/**
81+
* Set carriers sort By 'Price' or 'Position' / order by 'Ascending' or 'descending' in carrier options form
82+
* @param page {Page} Browser tab
83+
* @param sortBy {String} Sort by 'Price' or 'Position'
84+
* @param orderBy {String} Order by 'Ascending' or 'Descending'
85+
* @returns {Promise<string>}
86+
*/
87+
async setCarrierSortOrderBy(page: Page, sortBy: string, orderBy: string = 'Ascending'): Promise<string> {
88+
await this.selectByVisibleText(page, this.sortBySelect, sortBy);
89+
await this.selectByVisibleText(page, this.orderBySelect, orderBy);
90+
91+
// Save configuration and return successful message
92+
await page.locator(this.saveCarrierOptionsButton).click();
93+
return this.getAlertSuccessBlockParagraphContent(page);
94+
}
95+
}
96+
97+
module.exports = new BOShippingPreferences();

0 commit comments

Comments
 (0)