-
Notifications
You must be signed in to change notification settings - Fork 10
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 #363 from Progi1984/boTaxRulesCreatePage
Migrate `@pages/BO/international/taxes/taxRules/add` from Core
- Loading branch information
Showing
4 changed files
with
137 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
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,13 @@ | ||
import type FakerTaxRule from '@data/faker/taxRule'; | ||
import type FakerTaxRulesGroup from '@data/faker/taxRulesGroup'; | ||
import {BOBasePagePageInterface} from '@interfaces/BO'; | ||
import {type Page} from '@playwright/test'; | ||
|
||
export interface BOTaxRulesCreatePageInterface extends BOBasePagePageInterface { | ||
readonly pageTitleCreate: string; | ||
readonly pageTitleEdit: string; | ||
|
||
clickOnAddNewTaxRule(page: Page): Promise<void>; | ||
createEditTaxRules(page: Page, taxRuleData: FakerTaxRule): Promise<string>; | ||
createEditTaxRulesGroup(page: Page, taxRuleGroupData: FakerTaxRulesGroup): 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 BOTaxRulesCreatePageInterface} from '@interfaces/BO/international/taxes/taxRules/create'; | ||
|
||
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
function requirePage(): BOTaxRulesCreatePageInterface { | ||
return require('@versions/develop/pages/BO/international/taxes/taxRules/create'); | ||
} | ||
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
|
||
export default requirePage(); |
114 changes: 114 additions & 0 deletions
114
src/versions/develop/pages/BO/international/taxes/taxRules/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,114 @@ | ||
import type FakerTaxRule from '@data/faker/taxRule'; | ||
import type FakerTaxRulesGroup from '@data/faker/taxRulesGroup'; | ||
import {BOTaxRulesCreatePageInterface} from '@interfaces/BO/international/taxes/taxRules/create'; | ||
import BOBasePage from '@pages/BO/BOBasePage'; | ||
import {type Page} from '@playwright/test'; | ||
|
||
/** | ||
* Add tax rules page, contains functions that can be used on the page | ||
* @class | ||
* @extends BOBasePage | ||
*/ | ||
class BOTaxRulesCreatePage extends BOBasePage implements BOTaxRulesCreatePageInterface { | ||
public readonly pageTitleCreate: string; | ||
|
||
public readonly pageTitleEdit: string; | ||
|
||
private readonly addNewTaxRuleButton: string; | ||
|
||
private readonly taxRuleGroupForm: string; | ||
|
||
private readonly nameInput: string; | ||
|
||
private readonly statusInput: (id: string) => string; | ||
|
||
private readonly saveTaxButton: string; | ||
|
||
private readonly taxRuleForm: string; | ||
|
||
private readonly countrySelect: string; | ||
|
||
private readonly behaviourSelect: string; | ||
|
||
private readonly taxSelect: string; | ||
|
||
private readonly descriptionInput: string; | ||
|
||
private readonly saveAndStayButton: string; | ||
|
||
/** | ||
* @constructs | ||
* Setting up texts and selectors to use on add tax rules page | ||
*/ | ||
constructor() { | ||
super(); | ||
|
||
this.pageTitleCreate = 'Tax Rules > Add new'; | ||
this.pageTitleEdit = 'Tax Rules > Edit'; | ||
|
||
// Selectors | ||
// Header buttons | ||
this.addNewTaxRuleButton = 'a[data-role=page-header-desc-tax_rule-link]'; | ||
|
||
// New tax rule group form | ||
this.taxRuleGroupForm = '#tax_rules_group_form'; | ||
this.nameInput = `${this.taxRuleGroupForm} #name`; | ||
this.statusInput = (id: string) => `${this.taxRuleGroupForm} input#active_${id}`; | ||
this.saveTaxButton = `${this.taxRuleGroupForm} #tax_rules_group_form_submit_btn`; | ||
|
||
// New tax rule form | ||
this.taxRuleForm = '#tax_rule_form'; | ||
this.countrySelect = `${this.taxRuleForm} #country`; | ||
this.behaviourSelect = `${this.taxRuleForm} #behavior`; | ||
this.taxSelect = `${this.taxRuleForm} #id_tax`; | ||
this.descriptionInput = `${this.taxRuleForm} #description`; | ||
this.saveAndStayButton = `${this.taxRuleForm} #tax_rule_form_submit_btn_1`; | ||
} | ||
|
||
/* | ||
Methods | ||
*/ | ||
|
||
/** | ||
* Fill form for add/edit tax rules group | ||
* @param page {Page} Browser tab | ||
* @param taxRuleGroupData {FakerTaxRulesGroup} Data to set on tax rule group data | ||
* @returns {Promise<string>} | ||
*/ | ||
async createEditTaxRulesGroup(page: Page, taxRuleGroupData: FakerTaxRulesGroup): Promise<string> { | ||
await this.setValue(page, this.nameInput, taxRuleGroupData.name); | ||
await this.setChecked(page, this.statusInput(taxRuleGroupData.enabled ? 'on' : 'off')); | ||
// Save Tax rules group | ||
await this.clickAndWaitForURL(page, this.saveTaxButton); | ||
|
||
return this.getAlertSuccessBlockContent(page); | ||
} | ||
|
||
/** | ||
* Fill form for add/edit tax rules group | ||
* @param page {Page} Browser tab | ||
* @param taxRuleData {FakerTaxRule} Data to set on new/edit tax rule data | ||
* @returns {Promise<string>} | ||
*/ | ||
async createEditTaxRules(page: Page, taxRuleData: FakerTaxRule): Promise<string> { | ||
await this.selectByVisibleText(page, this.countrySelect, taxRuleData.country); | ||
await this.selectByVisibleText(page, this.behaviourSelect, taxRuleData.behaviour); | ||
await this.selectByVisibleText(page, this.taxSelect, taxRuleData.name); | ||
await this.setValue(page, this.descriptionInput, taxRuleData.description); | ||
// Save Tax rules | ||
await page.locator(this.saveAndStayButton).click(); | ||
|
||
return this.getAlertSuccessBlockContent(page); | ||
} | ||
|
||
/** | ||
* Click on add new tax rule | ||
* @param page {Page} Browser tab | ||
* @return {Promise<void>} | ||
*/ | ||
async clickOnAddNewTaxRule(page: Page): Promise<void> { | ||
await page.locator(this.addNewTaxRuleButton).click(); | ||
} | ||
} | ||
|
||
module.exports = new BOTaxRulesCreatePage(); |