Skip to content

Commit 73227b2

Browse files
authored
Merge pull request #447 from Progi1984/boZonesCreatePage
Migrate `@pages/BO/international/locations/add` from Core
2 parents c818870 + 74953dd commit 73227b2

File tree

4 files changed

+80
-1
lines changed

4 files changed

+80
-1
lines changed

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ export {default as boThemeAndLogoChooseLayoutsPage} from '@pages/BO/design/theme
337337
export {default as boThemeAndLogoImportPage} from '@pages/BO/design/themeAndLogo/themeAndLogo/import';
338338
export {default as boThemePagesConfigurationPage} from '@pages/BO/design/themeAndLogo/pagesConfiguration';
339339
export {default as boTranslationsPage} from '@pages/BO/international/translations';
340-
export {default as boZonesPages} from '@pages/BO/international/locations';
340+
export {default as boZonesPage} from '@pages/BO/international/locations';
341+
export {default as boZonesCreatePage} from '@pages/BO/international/locations/create';
341342
// Export Pages FO
342343
export * as FOBasePage from '@pages/FO/FOBasePage';
343344
// Export Pages FO/Classic
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type FakerZone from '@data/faker/zone';
2+
import {BOBasePagePageInterface} from '@interfaces/BO';
3+
import {type Page} from '@playwright/test';
4+
5+
export interface BOZonesCreatePageInterface extends BOBasePagePageInterface {
6+
readonly pageTitleCreate: string;
7+
readonly pageTitleEdit: string;
8+
9+
createEditZone(page: Page, zoneData: FakerZone): Promise<string>;
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {type BOZonesCreatePageInterface} from '@interfaces/BO/international/locations/create';
2+
3+
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
4+
function requirePage(): BOZonesCreatePageInterface {
5+
return require('@versions/develop/pages/BO/international/locations/create');
6+
}
7+
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
8+
9+
export default requirePage();
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import type FakerZone from '@data/faker/zone';
2+
import {type BOZonesCreatePageInterface} from '@interfaces/BO/international/locations/create';
3+
import BOBasePage from '@pages/BO/BOBasePage';
4+
import {type Page} from '@playwright/test';
5+
6+
/**
7+
* Add zone page, contains functions that can be used on the page
8+
* @class
9+
* @extends BOBasePage
10+
*/
11+
class BOZonesCreatePage extends BOBasePage implements BOZonesCreatePageInterface {
12+
public readonly pageTitleCreate: string;
13+
14+
public readonly pageTitleEdit: string;
15+
16+
private readonly nameInput: string;
17+
18+
private readonly statusToggle: (toggle: number) => string;
19+
20+
private readonly saveZoneButton: string;
21+
22+
/**
23+
* @constructs
24+
* Setting up texts and selectors to use on add zone page
25+
*/
26+
constructor() {
27+
super();
28+
29+
this.pageTitleCreate = `New zone • ${global.INSTALL.SHOP_NAME}`;
30+
this.pageTitleEdit = 'Editing zone';
31+
32+
// Selectors
33+
this.nameInput = '#zone_name';
34+
this.statusToggle = (toggle: number) => `#zone_enabled_${toggle}`;
35+
this.saveZoneButton = '#save-button';
36+
}
37+
38+
/*
39+
Methods
40+
*/
41+
/**
42+
* Fill form for add/edit zone
43+
* @param page {Page} Browser tab
44+
* @param zoneData {FakerZone} Data to set on new/edit zone page
45+
* @returns {Promise<string>}
46+
*/
47+
async createEditZone(page: Page, zoneData: FakerZone): Promise<string> {
48+
await this.setValue(page, this.nameInput, zoneData.name);
49+
await this.setChecked(page, this.statusToggle(zoneData.status ? 1 : 0));
50+
51+
// Save zone
52+
await this.clickAndWaitForURL(page, this.saveZoneButton);
53+
54+
// Return successful message
55+
return this.getAlertSuccessBlockParagraphContent(page);
56+
}
57+
}
58+
59+
module.exports = new BOZonesCreatePage();

0 commit comments

Comments
 (0)