Skip to content

Commit c378a89

Browse files
committed
Migrate @pages/BO/international/locations/states/add from Core
1 parent e4ac49a commit c378a89

File tree

4 files changed

+92
-0
lines changed
  • src

4 files changed

+92
-0
lines changed

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ export {default as boSqlManagerPage} from '@pages/BO/advancedParameters/database
321321
export {default as boSqlManagerCreatePage} from '@pages/BO/advancedParameters/database/sqlManager/create';
322322
export {default as boSqlManagerViewPage} from '@pages/BO/advancedParameters/database/sqlManager/view';
323323
export {default as boStatesPage} from '@pages/BO/international/locations/states';
324+
export {default as boStatesCreatePage} from '@pages/BO/international/locations/states/create';
324325
export {default as boStatisticsPage} from '@pages/BO/statistics';
325326
export {default as boStockPage} from '@pages/BO/catalog/stock';
326327
export {default as boStockMovementsPage} from '@pages/BO/catalog/stock/movements';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type FakerState from '@data/faker/state';
2+
import {BOBasePagePageInterface} from '@interfaces/BO';
3+
import {type Page} from '@playwright/test';
4+
5+
export interface BOStatesCreatePageInterface extends BOBasePagePageInterface {
6+
readonly pageTitleCreate: string;
7+
readonly pageTitleEdit: string;
8+
9+
createEditState(page: Page, stateData: FakerState): Promise<string>;
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {type BOStatesCreatePageInterface} from '@interfaces/BO/international/locations/states/create';
2+
3+
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
4+
function requirePage(): BOStatesCreatePageInterface {
5+
return require('@versions/develop/pages/BO/international/locations/states/create');
6+
}
7+
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
8+
9+
export default requirePage();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import type FakerState from '@data/faker/state';
2+
import {type BOStatesCreatePageInterface} from '@interfaces/BO/international/locations/states/create';
3+
import BOBasePage from '@pages/BO/BOBasePage';
4+
import {type Page} from '@playwright/test';
5+
6+
/**
7+
* Add state page, contains functions that can be used on the page
8+
* @class
9+
* @extends BOBasePage
10+
*/
11+
class BOStatesCreatePage extends BOBasePage implements BOStatesCreatePageInterface {
12+
public readonly pageTitleCreate: string;
13+
14+
public readonly pageTitleEdit: string;
15+
16+
private readonly nameInput: string;
17+
18+
private readonly isoCodeInput: string;
19+
20+
private readonly countrySelect: string;
21+
22+
private readonly zoneSelect: string;
23+
24+
private readonly statusToggle: (toggle: number) => string;
25+
26+
private readonly saveStateButton: string;
27+
28+
/**
29+
* @constructs
30+
* Setting up texts and selectors to use on add state page
31+
*/
32+
constructor() {
33+
super();
34+
35+
this.pageTitleCreate = `New state • ${global.INSTALL.SHOP_NAME}`;
36+
this.pageTitleEdit = 'Editing state';
37+
38+
// Selectors
39+
this.nameInput = '#state_name';
40+
this.isoCodeInput = '#state_iso_code';
41+
this.countrySelect = '#state_id_country';
42+
this.zoneSelect = '#state_id_zone';
43+
this.statusToggle = (toggle: number) => `#state_active_${toggle}`;
44+
this.saveStateButton = '#save-button';
45+
}
46+
47+
/*
48+
Methods
49+
*/
50+
/**
51+
* Fill form for add/edit state
52+
* @param page {Page} Browser tab
53+
* @param stateData {FakerState} Data to set on new/edit state form
54+
* @returns {Promise<string>}
55+
*/
56+
async createEditState(page: Page, stateData: FakerState): Promise<string> {
57+
// Fill form
58+
await this.setValue(page, this.nameInput, stateData.name);
59+
await this.setValue(page, this.isoCodeInput, stateData.isoCode);
60+
await this.selectByVisibleText(page, this.countrySelect, stateData.country);
61+
await this.selectByVisibleText(page, this.zoneSelect, stateData.zone);
62+
await this.setChecked(page, this.statusToggle(stateData.status ? 1 : 0));
63+
64+
// Save zone
65+
await this.clickAndWaitForURL(page, this.saveStateButton);
66+
67+
// Return successful message
68+
return this.getAlertSuccessBlockParagraphContent(page);
69+
}
70+
}
71+
72+
module.exports = new BOStatesCreatePage();

0 commit comments

Comments
 (0)