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
1 change: 1 addition & 0 deletions src/interfaces/BO/catalog/discountsV2/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export interface BODiscountsCreatePageInterface extends BOBasePagePageInterface
readonly pageTitle: string;

createDiscount(page: Page, discountData: FakerDiscount): Promise<string>;
getErrorMessageInvalidInput(page: Page, input: string): Promise<string>;
}
6 changes: 0 additions & 6 deletions src/versions/9.1/pages/BO/catalog/discountsV2/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ class BODiscountsCreatePage extends BODiscountsCreatePageVersion implements BODi
constructor() {
super();

this.errorMessageNameRequired = 'The field names is required at least in your default language.';
this.errorMessageMinPurchaseAmount = 'This value should be greater than 0.';
this.errorMessageMinPurchaseAmountNotnumber = 'Please enter a valid money amount.';
this.errorMessageDiscountValue = (discountValue: string) => `Reduction value "${discountValue}" is invalid. `
+ 'It must be greater than 0.';

// Selectors
this.minimumAmountValueInput = '#discount_conditions_cart_minimum_amount_value';
this.minimumAmountCurrencySelect = '#select2-discount_conditions_cart_minimum_amount_currency-container';
Expand Down
47 changes: 43 additions & 4 deletions src/versions/develop/pages/BO/catalog/discountsV2/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 BODiscountsCreatePage extends BOBasePage implements BODiscountsCreatePageInterface {
public readonly pageTitle: string;

public errorMessage: string;

public errorMessageNameRequired: string;

public errorMessageMinPurchaseAmount: string;
Expand All @@ -19,6 +21,8 @@ class BODiscountsCreatePage extends BOBasePage implements BODiscountsCreatePageI

public errorMessageDiscountValue: (discountValue: string) => string;

public readonly discountInformationBlock: string;

public readonly discountNameInput: string;

public readonly discountDescriptionTextarea: string;
Expand All @@ -37,6 +41,8 @@ class BODiscountsCreatePage extends BOBasePage implements BODiscountsCreatePageI

public readonly productSegmentRadioButton: string;

public readonly discountConditionCartBlock: string;

public readonly noMinimumPurchaseRadioButton: string;

public readonly minimumPurchaseAmountRadioButton: string;
Expand All @@ -51,6 +57,8 @@ class BODiscountsCreatePage extends BOBasePage implements BODiscountsCreatePageI

public readonly minimumProductQuantityInput: string;

public readonly discountValueBlock: string;

protected discountValueInput: string;

public readonly discountReductionTypeSelect: string;
Expand Down Expand Up @@ -78,12 +86,15 @@ class BODiscountsCreatePage extends BOBasePage implements BODiscountsCreatePageI

this.pageTitle = `Discounts • ${global.INSTALL.SHOP_NAME}`;
// @todo
this.errorMessageNameRequired = 'The form contains errors. Please fix them and save again.';
this.errorMessageMinPurchaseAmount = 'The form contains errors. Please fix them and save again.';
this.errorMessageMinPurchaseAmountNotnumber = 'The form contains errors. Please fix them and save again.';
this.errorMessageDiscountValue = () => 'The form contains errors. Please fix them and save again.';
this.errorMessage = 'The form contains errors. Please fix them and save again.';
this.errorMessageNameRequired = 'The field names is required at least in your default language.';
this.errorMessageMinPurchaseAmount = 'This value should be greater than 0.';
this.errorMessageMinPurchaseAmountNotnumber = 'Please enter a valid money amount.';
this.errorMessageDiscountValue = (discountValue: string) => `Reduction value "${discountValue}" is invalid. `
+ 'It must be greater than 0.';

// Selectors
this.discountInformationBlock = '#discount_information';
this.discountNameInput = '#discount_information_names_1';
this.discountDescriptionTextarea = '#discount_information_description';
// Select customer eligibiliyty
Expand All @@ -96,6 +107,7 @@ class BODiscountsCreatePage extends BOBasePage implements BODiscountsCreatePageI
this.specificProductInput = '#discount_conditions_product_specific_products_search_input';
this.productSegmentRadioButton = '#discount_conditions_product_children_selector_2';
// Cart conditions
this.discountConditionCartBlock = '#discount_conditions_cart';
this.noMinimumPurchaseRadioButton = '#discount_conditions_cart_children_selector_0';
this.minimumPurchaseAmountRadioButton = '#discount_conditions_cart_children_selector_1';
this.minimumAmountValueInput = '#discount_conditions_cart_minimum_amount_value_amount';
Expand All @@ -104,6 +116,7 @@ class BODiscountsCreatePage extends BOBasePage implements BODiscountsCreatePageI
this.minimumProductQuantityRadioButton = '#discount_conditions_cart_children_selector_2';
this.minimumProductQuantityInput = '#discount_conditions_cart_minimum_product_quantity';
// Choose a discount value
this.discountValueBlock = '#discount_value';
this.discountValueInput = '#discount_value_reduction_value_amount';
this.discountReductionTypeSelect = '#discount_value_reduction_type';
this.discountIncludTaxSelect = '#discount_value_reduction_include_tax';
Expand Down Expand Up @@ -179,6 +192,32 @@ class BODiscountsCreatePage extends BOBasePage implements BODiscountsCreatePageI

return this.getAlertBlockContent(page);
}

/**
* Get error message invalid input
* @param page {Page} Browser tab
* @param input {string} The invalid input to get his error message
* @return {Promise<string>}
*/
async getErrorMessageInvalidInput(page: Page, input: string): Promise<string> {
let selector: string = '';

switch (input) {
case 'name':
selector = this.discountInformationBlock;
break;
case 'amount':
selector = this.discountConditionCartBlock;
break;
case 'value':
selector = this.discountValueBlock;
break;
default:
// Do nothing
}

return this.getTextContent(page, `${selector} .alert-text`);
}
}

const boDiscountsCreatePage = new BODiscountsCreatePage();
Expand Down
Loading