Skip to content

Commit 95fb89e

Browse files
authored
Merge pull request #461 from Progi1984/boOrderStatusesCreatePage
Migrate `@pages/BO/shopParameters/orderSettings/statuses/add` from Core
2 parents 98ab956 + 46b169e commit 95fb89e

File tree

4 files changed

+117
-0
lines changed
  • src
    • interfaces/BO/shopParameters/orderSettings/orderStatuses
    • pages/BO/shopParameters/orderSettings/orderStatuses
    • versions/develop/pages/BO/shopParameters/orderSettings/orderStatuses

4 files changed

+117
-0
lines changed

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ export {default as boOrdersViewBlockProductsPage} from '@pages/BO/orders/view/bl
290290
export {default as boOrdersViewBlockTabListPage} from '@pages/BO/orders/view/blockTabList';
291291
export {default as boOrderSettingsPage} from '@pages/BO/shopParameters/orderSettings';
292292
export {default as boOrderStatusesPage} from '@pages/BO/shopParameters/orderSettings/orderStatuses';
293+
export {default as boOrderStatusesCreatePage} from '@pages/BO/shopParameters/orderSettings/orderStatuses/create';
293294
export {default as boOutstandingPage} from '@pages/BO/catalog/outstanding';
294295
export {default as boPaymentMethodsPage} from '@pages/BO/payment/paymentMethods';
295296
export {default as boPaymentPreferencesPage} from '@pages/BO/payment/preferences';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type FakerOrderStatus from '@data/faker/orderStatus';
2+
import {BOBasePagePageInterface} from '@interfaces/BO';
3+
import {type Page} from '@playwright/test';
4+
5+
export interface BOOrderStatusesCreatePageInterface extends BOBasePagePageInterface {
6+
readonly pageTitleCreate: string;
7+
readonly pageTitleEdit: (name: string) => string;
8+
9+
setOrderStatus(page: Page, orderStatusData: FakerOrderStatus): Promise<string>;
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type {BOOrderStatusesCreatePageInterface} from '@interfaces/BO/shopParameters/orderSettings/orderStatuses/create';
2+
3+
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
4+
function requirePage(): BOOrderStatusesCreatePageInterface {
5+
return require('@versions/develop/pages/BO/shopParameters/orderSettings/orderStatuses/create');
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 FakerOrderStatus from '@data/faker/orderStatus';
2+
import {type BOOrderStatusesCreatePageInterface} from '@interfaces/BO/shopParameters/orderSettings/orderStatuses/create';
3+
import BOBasePage from '@pages/BO/BOBasePage';
4+
import {type Page} from '@playwright/test';
5+
6+
/**
7+
* Add order status page, contains selectors and functions for the page
8+
* @class
9+
* @extends BOBasePage
10+
*/
11+
class BOOrderStatusesCreatePage extends BOBasePage implements BOOrderStatusesCreatePageInterface {
12+
public readonly pageTitleCreate: string;
13+
14+
public readonly pageTitleEdit: (name: string) => string;
15+
16+
private readonly nameInput: string;
17+
18+
private readonly colorInput: string;
19+
20+
private readonly logableOnCheckbox: string;
21+
22+
private readonly invoiceOnCheckbox: string;
23+
24+
private readonly hiddenOnCheckbox: string;
25+
26+
private readonly sendEmailOnCheckbox: string;
27+
28+
private readonly pdfInvoiceOnCheckbox: string;
29+
30+
private readonly pdfDeliveryOnCheckbox: string;
31+
32+
private readonly shippedOnCheckbox: string;
33+
34+
private readonly paidOnCheckbox: string;
35+
36+
private readonly deliveryOnCheckbox: string;
37+
38+
private readonly saveButton: string;
39+
40+
/**
41+
* @constructs
42+
* Setting up titles and selectors to use on add order status page
43+
*/
44+
constructor() {
45+
super();
46+
47+
this.pageTitleCreate = `New order status • ${global.INSTALL.SHOP_NAME}`;
48+
this.pageTitleEdit = (name: string) => `Editing order status ${name}${global.INSTALL.SHOP_NAME}`;
49+
50+
// Form selectors
51+
this.nameInput = '#order_state_name_1';
52+
this.colorInput = '#order_state_color';
53+
this.logableOnCheckbox = '#order_state_loggable';
54+
this.invoiceOnCheckbox = '#order_state_invoice';
55+
this.hiddenOnCheckbox = '#order_state_hidden';
56+
this.sendEmailOnCheckbox = '#order_state_send_email';
57+
this.pdfInvoiceOnCheckbox = '#order_state_pdf_invoice';
58+
this.pdfDeliveryOnCheckbox = '#order_state_pdf_delivery';
59+
this.shippedOnCheckbox = '#order_state_shipped';
60+
this.paidOnCheckbox = '#order_state_paid';
61+
this.deliveryOnCheckbox = '#order_state_delivery';
62+
this.saveButton = '#save-button';
63+
}
64+
65+
/* Methods */
66+
67+
/**
68+
* Fill order status form in create or edit page and save
69+
* @param page {Page} Browser tab
70+
* @param orderStatusData {FakerOrderStatus} Data to set on order status form
71+
* @return {Promise<string>}
72+
*/
73+
async setOrderStatus(page: Page, orderStatusData: FakerOrderStatus): Promise<string> {
74+
await this.setValue(page, this.nameInput, orderStatusData.name);
75+
76+
// Set color
77+
await this.setInputValue(page, this.colorInput, orderStatusData.color);
78+
79+
await this.setHiddenCheckboxValue(page, this.logableOnCheckbox, orderStatusData.logableOn);
80+
await this.setHiddenCheckboxValue(page, this.invoiceOnCheckbox, orderStatusData.invoiceOn);
81+
await this.setHiddenCheckboxValue(page, this.hiddenOnCheckbox, orderStatusData.hiddenOn);
82+
await this.setHiddenCheckboxValue(page, this.sendEmailOnCheckbox, orderStatusData.sendEmailOn);
83+
await this.setHiddenCheckboxValue(page, this.pdfInvoiceOnCheckbox, orderStatusData.pdfInvoiceOn);
84+
await this.setHiddenCheckboxValue(page, this.pdfDeliveryOnCheckbox, orderStatusData.pdfDeliveryOn);
85+
await this.setHiddenCheckboxValue(page, this.shippedOnCheckbox, orderStatusData.shippedOn);
86+
await this.setHiddenCheckboxValue(page, this.paidOnCheckbox, orderStatusData.paidOn);
87+
await this.setHiddenCheckboxValue(page, this.deliveryOnCheckbox, orderStatusData.deliveryOn);
88+
89+
// Save order status
90+
await this.clickAndWaitForURL(page, this.saveButton);
91+
92+
// Return successful message
93+
return this.getAlertSuccessBlockParagraphContent(page);
94+
}
95+
}
96+
97+
module.exports = new BOOrderStatusesCreatePage();

0 commit comments

Comments
 (0)