@@ -10,31 +10,31 @@ import {type Page} from '@playwright/test';
1010 * @extends BOBasePage
1111 */
1212class BOTaxRulesCreatePage extends BOBasePage implements BOTaxRulesCreatePageInterface {
13- public readonly pageTitleCreate : string ;
13+ public pageTitleCreate : string ;
1414
15- public readonly pageTitleEdit : string ;
15+ public pageTitleEdit : string ;
1616
17- private readonly addNewTaxRuleButton : string ;
17+ protected addNewTaxRuleButton : string ;
1818
19- private readonly taxRuleGroupForm : string ;
19+ protected taxRuleGroupForm : string ;
2020
21- private readonly nameInput : string ;
21+ protected nameInput : string ;
2222
23- private readonly statusInput : ( id : string ) => string ;
23+ protected statusInput : ( id : string ) => string ;
2424
25- private readonly saveTaxButton : string ;
25+ protected saveTaxButton : string ;
2626
27- private readonly taxRuleForm : string ;
27+ protected taxRuleForm : string ;
2828
29- private readonly countrySelect : string ;
29+ protected countrySelect : string ;
3030
31- private readonly behaviourSelect : string ;
31+ protected behaviourSelect : string ;
3232
33- private readonly taxSelect : string ;
33+ protected taxSelect : string ;
3434
35- private readonly descriptionInput : string ;
35+ protected descriptionInput : string ;
3636
37- private readonly saveAndStayButton : string ;
37+ protected saveAndStayButton : string ;
3838
3939 /**
4040 * @constructs
@@ -43,26 +43,26 @@ class BOTaxRulesCreatePage extends BOBasePage implements BOTaxRulesCreatePageInt
4343 constructor ( ) {
4444 super ( ) ;
4545
46- this . pageTitleCreate = 'Tax Rules > Add new' ;
47- this . pageTitleEdit = 'Tax Rules > Edit ' ;
46+ this . pageTitleCreate = `New tax rule • ${ global . INSTALL . SHOP_NAME } ` ;
47+ this . pageTitleEdit = 'Editing tax rule ' ;
4848
4949 // Selectors
5050 // Header buttons
51- this . addNewTaxRuleButton = 'a[data-role=page-header-desc-tax_rule-link] ' ;
51+ this . addNewTaxRuleButton = '#tax_rules_group_tax_rules_add_tax_rule_btn ' ;
5252
5353 // New tax rule group form
54- this . taxRuleGroupForm = '#tax_rules_group_form ' ;
55- this . nameInput = `${ this . taxRuleGroupForm } #name ` ;
56- this . statusInput = ( id : string ) => `${ this . taxRuleGroupForm } input#active_ ${ id } ` ;
57- this . saveTaxButton = `${ this . taxRuleGroupForm } #tax_rules_group_form_submit_btn ` ;
54+ this . taxRuleGroupForm = 'form[name="tax_rules_group"] ' ;
55+ this . nameInput = `${ this . taxRuleGroupForm } #tax_rules_group_name ` ;
56+ this . statusInput = ( id : string ) => `${ this . taxRuleGroupForm } input#tax_rules_group_is_enabled_ ${ id } ` ;
57+ this . saveTaxButton = `${ this . taxRuleGroupForm } #save-and-stay-button ` ;
5858
5959 // New tax rule form
60- this . taxRuleForm = '#tax_rule_form ' ;
61- this . countrySelect = ` ${ this . taxRuleForm } #country` ;
62- this . behaviourSelect = ` ${ this . taxRuleForm } #behavior` ;
63- this . taxSelect = ` ${ this . taxRuleForm } #id_tax` ;
64- this . descriptionInput = ` ${ this . taxRuleForm } #description` ;
65- this . saveAndStayButton = ` ${ this . taxRuleForm } #tax_rule_form_submit_btn_1` ;
60+ this . taxRuleForm = 'iframe[name="tax-rule-form-modal-iframe"] ' ;
61+ this . countrySelect = '#tax_rule_country' ;
62+ this . behaviourSelect = '#tax_rule_behavior' ;
63+ this . taxSelect = '#tax_rule_tax' ;
64+ this . descriptionInput = '#tax_rule_description' ;
65+ this . saveAndStayButton = '#tax-rule-form-modal .btn-confirm-submit' ;
6666 }
6767
6868 /*
@@ -77,11 +77,11 @@ class BOTaxRulesCreatePage extends BOBasePage implements BOTaxRulesCreatePageInt
7777 */
7878 async createEditTaxRulesGroup ( page : Page , taxRuleGroupData : FakerTaxRulesGroup ) : Promise < string > {
7979 await this . setValue ( page , this . nameInput , taxRuleGroupData . name ) ;
80- await this . setChecked ( page , this . statusInput ( taxRuleGroupData . enabled ? 'on ' : 'off ' ) ) ;
80+ await this . setChecked ( page , this . statusInput ( taxRuleGroupData . enabled ? '1 ' : '0 ' ) ) ;
8181 // Save Tax rules group
8282 await this . clickAndWaitForURL ( page , this . saveTaxButton ) ;
8383
84- return this . getAlertSuccessBlockContent ( page ) ;
84+ return this . getAlertSuccessBlockParagraphContent ( page ) ;
8585 }
8686
8787 /**
@@ -91,14 +91,17 @@ class BOTaxRulesCreatePage extends BOBasePage implements BOTaxRulesCreatePageInt
9191 * @returns {Promise<string> }
9292 */
9393 async createEditTaxRules ( page : Page , taxRuleData : FakerTaxRule ) : Promise < string > {
94- await this . selectByVisibleText ( page , this . countrySelect , taxRuleData . country ) ;
95- await this . selectByVisibleText ( page , this . behaviourSelect , taxRuleData . behaviour ) ;
96- await this . selectByVisibleText ( page , this . taxSelect , taxRuleData . name ) ;
97- await this . setValue ( page , this . descriptionInput , taxRuleData . description ) ;
98- // Save Tax rules
94+ await page . locator ( this . addNewTaxRuleButton ) . click ( ) ;
95+ await page . locator ( this . taxRuleForm ) . waitFor ( { state : 'visible' } ) ;
96+
97+ const iframeLocator = await page . frameLocator ( this . taxRuleForm ) ;
98+ await iframeLocator . locator ( this . countrySelect ) . selectOption ( { label : taxRuleData . country } ) ;
99+ await iframeLocator . locator ( this . behaviourSelect ) . selectOption ( { label : taxRuleData . behaviour } ) ;
100+ await iframeLocator . locator ( this . taxSelect ) . selectOption ( { label : taxRuleData . name } ) ;
101+ await iframeLocator . locator ( this . descriptionInput ) . fill ( taxRuleData . description ) ;
99102 await page . locator ( this . saveAndStayButton ) . click ( ) ;
100103
101- return this . getAlertSuccessBlockContent ( page ) ;
104+ return this . getAlertSuccessBlockParagraphContent ( page ) ;
102105 }
103106
104107 /**
@@ -111,4 +114,5 @@ class BOTaxRulesCreatePage extends BOBasePage implements BOTaxRulesCreatePageInt
111114 }
112115}
113116
114- module . exports = new BOTaxRulesCreatePage ( ) ;
117+ const boTaxRulesCreatePage = new BOTaxRulesCreatePage ( ) ;
118+ export { boTaxRulesCreatePage , BOTaxRulesCreatePage } ;
0 commit comments