-
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 #457 from Progi1984/boStatesCreatePage
Migrate `@pages/BO/international/locations/states/add` from Core
- Loading branch information
Showing
4 changed files
with
92 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
10 changes: 10 additions & 0 deletions
10
src/interfaces/BO/international/locations/states/create.ts
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,10 @@ | ||
import type FakerState from '@data/faker/state'; | ||
import {BOBasePagePageInterface} from '@interfaces/BO'; | ||
import {type Page} from '@playwright/test'; | ||
|
||
export interface BOStatesCreatePageInterface extends BOBasePagePageInterface { | ||
readonly pageTitleCreate: string; | ||
readonly pageTitleEdit: string; | ||
|
||
createEditState(page: Page, stateData: FakerState): 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 BOStatesCreatePageInterface} from '@interfaces/BO/international/locations/states/create'; | ||
|
||
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
function requirePage(): BOStatesCreatePageInterface { | ||
return require('@versions/develop/pages/BO/international/locations/states/create'); | ||
} | ||
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
|
||
export default requirePage(); |
72 changes: 72 additions & 0 deletions
72
src/versions/develop/pages/BO/international/locations/states/create.ts
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,72 @@ | ||
import type FakerState from '@data/faker/state'; | ||
import {type BOStatesCreatePageInterface} from '@interfaces/BO/international/locations/states/create'; | ||
import BOBasePage from '@pages/BO/BOBasePage'; | ||
import {type Page} from '@playwright/test'; | ||
|
||
/** | ||
* Add state page, contains functions that can be used on the page | ||
* @class | ||
* @extends BOBasePage | ||
*/ | ||
class BOStatesCreatePage extends BOBasePage implements BOStatesCreatePageInterface { | ||
public readonly pageTitleCreate: string; | ||
|
||
public readonly pageTitleEdit: string; | ||
|
||
private readonly nameInput: string; | ||
|
||
private readonly isoCodeInput: string; | ||
|
||
private readonly countrySelect: string; | ||
|
||
private readonly zoneSelect: string; | ||
|
||
private readonly statusToggle: (toggle: number) => string; | ||
|
||
private readonly saveStateButton: string; | ||
|
||
/** | ||
* @constructs | ||
* Setting up texts and selectors to use on add state page | ||
*/ | ||
constructor() { | ||
super(); | ||
|
||
this.pageTitleCreate = `New state • ${global.INSTALL.SHOP_NAME}`; | ||
this.pageTitleEdit = 'Editing state'; | ||
|
||
// Selectors | ||
this.nameInput = '#state_name'; | ||
this.isoCodeInput = '#state_iso_code'; | ||
this.countrySelect = '#state_id_country'; | ||
this.zoneSelect = '#state_id_zone'; | ||
this.statusToggle = (toggle: number) => `#state_active_${toggle}`; | ||
this.saveStateButton = '#save-button'; | ||
} | ||
|
||
/* | ||
Methods | ||
*/ | ||
/** | ||
* Fill form for add/edit state | ||
* @param page {Page} Browser tab | ||
* @param stateData {FakerState} Data to set on new/edit state form | ||
* @returns {Promise<string>} | ||
*/ | ||
async createEditState(page: Page, stateData: FakerState): Promise<string> { | ||
// Fill form | ||
await this.setValue(page, this.nameInput, stateData.name); | ||
await this.setValue(page, this.isoCodeInput, stateData.isoCode); | ||
await this.selectByVisibleText(page, this.countrySelect, stateData.country); | ||
await this.selectByVisibleText(page, this.zoneSelect, stateData.zone); | ||
await this.setChecked(page, this.statusToggle(stateData.status ? 1 : 0)); | ||
|
||
// Save zone | ||
await this.clickAndWaitForURL(page, this.saveStateButton); | ||
|
||
// Return successful message | ||
return this.getAlertSuccessBlockParagraphContent(page); | ||
} | ||
} | ||
|
||
module.exports = new BOStatesCreatePage(); |