Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/interfaces/BO/catalog/brands/addresses/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;
getValue(page: Page, field: string): Promise<string>;
}
1 change: 1 addition & 0 deletions src/interfaces/BO/customers/addresses/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export interface BOAddressesCreatePageInterface extends BOBasePagePageInterface
waitForNavigation?: boolean,
): Promise<string|null>;
getSelectedCountry(page: Page): Promise<string>;
getValue(page: Page, field: string): Promise<string>;
}
36 changes: 36 additions & 0 deletions src/versions/develop/pages/BO/catalog/brands/addresses/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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<string>}
*/
async getValue(page: Page, field: string): Promise<string> {
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();
29 changes: 29 additions & 0 deletions src/versions/develop/pages/BO/customers/addresses/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,35 @@ class BOAddressesCreatePage extends BOBasePage implements BOAddressesCreatePageI
async getSelectedCountry(page: Page): Promise<string> {
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<string>}
*/
async getValue(page: Page, field: string): Promise<string> {
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();
2 changes: 1 addition & 1 deletion src/versions/develop/pages/BO/customers/addresses/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Loading