Skip to content

Commit 518916f

Browse files
committed
Migrate @pages/BO/international/taxes/add from Core
1 parent c378a89 commit 518916f

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ export {default as boSuppliersCreatePage} from '@pages/BO/catalog/suppliers/crea
331331
export {default as boSuppliersPage} from '@pages/BO/catalog/suppliers';
332332
export {default as boSuppliersViewPage} from '@pages/BO/catalog/suppliers/view';
333333
export {default as boTaxesPage} from '@pages/BO/international/taxes';
334+
export {default as boTaxesCreatePage} from '@pages/BO/international/taxes/create';
334335
export {default as boTaxRulesPage} from '@pages/BO/international/taxes/taxRules';
335336
export {default as boTaxRulesCreatePage} from '@pages/BO/international/taxes/taxRules/create';
336337
export {default as boThemeAdvancedConfigurationPage} from '@pages/BO/design/themeAndLogo/advancedConfiguration';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type FakerTax from '@data/faker/tax';
2+
import {BOBasePagePageInterface} from '@interfaces/BO';
3+
import {type Page} from '@playwright/test';
4+
5+
export interface BOTaxesCreatePageInterface extends BOBasePagePageInterface {
6+
readonly pageTitleCreate: string;
7+
readonly pageTitleEdit: string;
8+
9+
createEditTax(page: Page, taxData: FakerTax): Promise<string>;
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {type BOTaxesCreatePageInterface} from '@interfaces/BO/international/taxes/create';
2+
3+
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
4+
function requirePage(): BOTaxesCreatePageInterface {
5+
return require('@versions/develop/pages/BO/international/taxes/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,94 @@
1+
import FakerTax from '@data/faker/tax';
2+
import {type BOTaxesCreatePageInterface} from '@interfaces/BO/international/taxes/create';
3+
import BOBasePage from '@pages/BO/BOBasePage';
4+
import { Page } from '@playwright/test';
5+
6+
/**
7+
* Add tax page, contains functions that can be used on the page
8+
* @class
9+
* @extends BOBasePage
10+
*/
11+
class BOTaxesCreatePage extends BOBasePage implements BOTaxesCreatePageInterface {
12+
public readonly pageTitleCreate: string;
13+
14+
public readonly pageTitleEdit: string;
15+
16+
private readonly successfulUpdateStatusMessage: string;
17+
18+
private readonly nameEnInput: string;
19+
20+
private readonly nameFrInput: string;
21+
22+
private readonly inputLangDropdownButton: string;
23+
24+
private readonly inputLangChoiceSpan: (lang: string) => string;
25+
26+
private readonly rateInput: string;
27+
28+
private readonly statusToggleInput: (toggle: number) => string;
29+
30+
private readonly saveTaxButton: string;
31+
32+
/**
33+
* @constructs
34+
* Setting up texts and selectors to use on add tax page
35+
*/
36+
constructor() {
37+
super();
38+
39+
this.pageTitleCreate = `New tax • ${global.INSTALL.SHOP_NAME}`;
40+
this.pageTitleEdit = 'Editing tax';
41+
this.successfulUpdateStatusMessage = 'The status has been successfully updated.';
42+
43+
// Selectors
44+
this.nameEnInput = '#tax_name_1';
45+
this.nameFrInput = '#tax_name_2';
46+
this.inputLangDropdownButton = 'button#tax_name_dropdown';
47+
this.inputLangChoiceSpan = (lang: string) => `div.dropdown-menu span[data-locale='${lang}']`;
48+
this.rateInput = '#tax_rate';
49+
this.statusToggleInput = (toggle: number) => `#tax_is_enabled_${toggle}`;
50+
this.saveTaxButton = '#save-button';
51+
}
52+
53+
/*
54+
Methods
55+
*/
56+
57+
/**
58+
* Change language for input name
59+
* @param page {Page} Browser tab
60+
* @param lang {string} Value of language to change
61+
* @return {Promise<void>}
62+
*/
63+
async changeInputLanguage(page: Page, lang: string): Promise<void> {
64+
await Promise.all([
65+
page.locator(this.inputLangDropdownButton).click(),
66+
this.waitForVisibleSelector(page, `${this.inputLangDropdownButton}[aria-expanded='true']`),
67+
]);
68+
await Promise.all([
69+
page.locator(this.inputLangChoiceSpan(lang)).click(),
70+
this.waitForVisibleSelector(page, `${this.inputLangDropdownButton}[aria-expanded='false']`),
71+
]);
72+
}
73+
74+
/**
75+
* Fill form for add/edit tax
76+
* @param page {Page} Browser tab
77+
* @param taxData {FakerTax} Data to set on new/edit tax page
78+
* @returns {Promise<string>}
79+
*/
80+
async createEditTax(page: Page, taxData: FakerTax): Promise<string> {
81+
await this.changeInputLanguage(page, 'en');
82+
await this.setValue(page, this.nameEnInput, taxData.name);
83+
await this.changeInputLanguage(page, 'fr');
84+
await this.setValue(page, this.nameFrInput, taxData.frName);
85+
await this.setValue(page, this.rateInput, taxData.rate);
86+
await this.setChecked(page, this.statusToggleInput(taxData.enabled ? 1 : 0));
87+
// Save Tax
88+
await this.clickAndWaitForURL(page, this.saveTaxButton);
89+
90+
return this.getAlertSuccessBlockParagraphContent(page);
91+
}
92+
}
93+
94+
module.exports = new BOTaxesCreatePage();

0 commit comments

Comments
 (0)