diff --git a/src/interfaces/BO/catalog/brands/addresses/create.ts b/src/interfaces/BO/catalog/brands/addresses/create.ts index 3462ee059..6d86f4980 100644 --- a/src/interfaces/BO/catalog/brands/addresses/create.ts +++ b/src/interfaces/BO/catalog/brands/addresses/create.ts @@ -4,6 +4,8 @@ import {type Page} from '@playwright/test'; export interface BOBrandAdressesCreatePageInterface extends BOBasePagePageInterface { readonly pageTitle: string; + readonly pageTitleEdit: string; createEditBrandAddress(page: Page, brandAddressData: FakerBrandAddress): Promise; + getValue(page: Page, field: string): Promise; } diff --git a/src/interfaces/BO/customers/addresses/create.ts b/src/interfaces/BO/customers/addresses/create.ts index 351e7dd8e..1f642a22f 100644 --- a/src/interfaces/BO/customers/addresses/create.ts +++ b/src/interfaces/BO/customers/addresses/create.ts @@ -13,4 +13,5 @@ export interface BOAddressesCreatePageInterface extends BOBasePagePageInterface waitForNavigation?: boolean, ): Promise; getSelectedCountry(page: Page): Promise; + getValue(page: Page, field: string): Promise; } diff --git a/src/versions/develop/pages/BO/catalog/brands/addresses/create.ts b/src/versions/develop/pages/BO/catalog/brands/addresses/create.ts index 475022e1e..4d712840e 100644 --- a/src/versions/develop/pages/BO/catalog/brands/addresses/create.ts +++ b/src/versions/develop/pages/BO/catalog/brands/addresses/create.ts @@ -11,6 +11,8 @@ import {type Page} from '@playwright/test'; class BOBrandAdressesCreatePage extends BOBasePage implements BOBrandAdressesCreatePageInterface { public readonly pageTitle: string; + public readonly pageTitleEdit: string; + private readonly brandSelect: string; private readonly lastnameInput: string; @@ -45,6 +47,7 @@ class BOBrandAdressesCreatePage extends BOBasePage implements BOBrandAdressesCre super(); this.pageTitle = `New brand address • ${global.INSTALL.SHOP_NAME}`; + this.pageTitleEdit = `Editing brand address • ${global.INSTALL.SHOP_NAME}`; // Selectors this.brandSelect = 'select#manufacturer_address_id_manufacturer'; @@ -102,6 +105,39 @@ class BOBrandAdressesCreatePage extends BOBasePage implements BOBrandAdressesCre await this.clickAndWaitForURL(page, this.saveButton, 'load', 30000, {delay: 500}); return this.getAlertSuccessBlockParagraphContent(page); } + + /** + * Get value of an input or select in the manufacturer address form + * @param page {Page} Browser tab + * @param field {string} Field name + * @returns {Promise} + */ + async getValue(page: Page, field: string): Promise { + switch (field) { + case 'manufacturerId': + return this.getTextContent(page, `${this.brandSelect} option[selected]`); + case 'firstName': + return this.getInputValue(page, this.firstnameInput); + case 'lastName': + return this.getInputValue(page, this.lastnameInput); + case 'address': + return this.getInputValue(page, this.addressInput); + case 'city': + return this.getInputValue(page, this.cityInput); + case 'postCode': + return this.getInputValue(page, this.postalCodeInput); + case 'countryId': + return this.getTextContent(page, `${this.countrySelect} option[selected]`); + case 'phone': + return this.getInputValue(page, this.homePhoneInput); + case 'mobilePhone': + return this.getInputValue(page, this.mobilePhoneInput); + case 'other': + return this.getInputValue(page, this.otherInput); + default: + throw new Error(`Field ${field} was not found`); + } + } } module.exports = new BOBrandAdressesCreatePage(); diff --git a/src/versions/develop/pages/BO/customers/addresses/create.ts b/src/versions/develop/pages/BO/customers/addresses/create.ts index 78f3ce245..3c278ea04 100644 --- a/src/versions/develop/pages/BO/customers/addresses/create.ts +++ b/src/versions/develop/pages/BO/customers/addresses/create.ts @@ -162,6 +162,35 @@ class BOAddressesCreatePage extends BOBasePage implements BOAddressesCreatePageI async getSelectedCountry(page: Page): Promise { return this.getTextContent(page, `${this.customerAddressCountryOption}[selected]`, false); } + + /** + * Get value of an input or select in the address form + * @param page {Page} Browser tab + * @param field {string} Field name + * @returns {Promise} + */ + async getValue(page: Page, field: string): Promise { + switch (field) { + case 'firstName': + return this.getInputValue(page, this.customerAddressFirstNameInput); + case 'lastName': + return this.getInputValue(page, this.customerLastNameInput); + case 'address': + return this.getInputValue(page, this.customerAddressInput); + case 'city': + return this.getInputValue(page, this.customerAddressCityInput); + case 'phone': + return this.getAttributeContent(page, this.customerAddressPhoneInput, 'value'); + case 'postCode': + return this.getInputValue(page, this.customerAddressPostCodeInput); + case 'company': + return this.getInputValue(page, this.customerAddressCompanyInput); + case 'vatNumber': + return this.getInputValue(page, this.customerAddressVatNumberInput); + default: + throw new Error(`Field ${field} was not found`); + } + } } module.exports = new BOAddressesCreatePage(); diff --git a/src/versions/develop/pages/BO/customers/addresses/index.ts b/src/versions/develop/pages/BO/customers/addresses/index.ts index fc3c39a10..612fe2323 100644 --- a/src/versions/develop/pages/BO/customers/addresses/index.ts +++ b/src/versions/develop/pages/BO/customers/addresses/index.ts @@ -254,7 +254,7 @@ class BOAddressesPage extends BOBasePage implements BOAddressesPageInterface { page.locator(this.addressesListTableDeleteLink(row)).click(), this.waitForVisibleSelector(page, this.deleteAddressModal), ]); - await page.locator(this.deleteAddressModalDeleteButton).click(); + await this.clickAndWaitForURL(page, this.deleteAddressModalDeleteButton); return this.getAlertSuccessBlockParagraphContent(page); }