Skip to content
Draft
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/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export {default as boBrandsPage} from '@pages/BO/catalog/brands';
export {default as boCarriersPage} from '@pages/BO/shipping/carriers';
export {default as boCarriersCreatePage} from '@pages/BO/shipping/carriers/create';
export {default as boCartRulesPage} from '@pages/BO/catalog/discounts';
export {default as boDiscountsPage} from '@pages/BO/catalog/discounts/discounts';
export {default as boCartRulesCreatePage} from '@pages/BO/catalog/discounts/create';
export {default as boCatalogPriceRulesPage} from '@pages/BO/catalog/discounts/catalogPriceRules';
export {default as boCatalogPriceRulesCreatePage} from '@pages/BO/catalog/discounts/catalogPriceRules/create';
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/BO/advancedParameters/featureFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface BOFeatureFlagInterface extends BOBasePagePageInterface {
readonly featureFlagAdminAPI: string;
readonly featureFlagAdminAPIMultistore: string;
readonly featureFlagImprovedShipment: string;
readonly featureFlagDiscount: string;
readonly featureFlagProductPageV2: string;
readonly pageTitle: string;

Expand Down
8 changes: 8 additions & 0 deletions src/interfaces/BO/catalog/discounts/discounts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {BOBasePagePageInterface} from '@interfaces/BO';
import type {Page} from '@playwright/test';

export interface BODiscountsPageInterface extends BOBasePagePageInterface {
readonly pageTitle: string;

addNewDiscountByType(page: Page, discountType: string): Promise<void>;
}
9 changes: 9 additions & 0 deletions src/pages/BO/catalog/discounts/discounts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {type BODiscountsPageInterface} from '@interfaces/BO/catalog/discounts/discounts';

/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
function requirePage(): BODiscountsPageInterface {
return require('@versions/develop/pages/BO/catalog/discounts/discounts');
}
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */

export default requirePage();
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class BOFeatureFlag extends BOBasePage implements BOFeatureFlagInterface {

public readonly featureFlagImprovedShipment: string;

public readonly featureFlagDiscount: string;

public readonly featureFlagMultipleImageFormats: string;

private readonly featureFlagSwitchButton: (status: string, feature: string, toggle: number) => string;
Expand Down Expand Up @@ -46,6 +48,7 @@ class BOFeatureFlag extends BOBasePage implements BOFeatureFlagInterface {
this.featureFlagAdminAPI = 'admin_api';
this.featureFlagAdminAPIMultistore = 'admin_api_multistore';
this.featureFlagImprovedShipment = 'improved_shipment';
this.featureFlagDiscount = 'discount';
// Selectors
this.featureFlagSwitchButton = (status: string, feature: string, toggle: number) => `#feature_flag_${
status}_feature_flags_${feature}_enabled_${toggle}`;
Expand Down Expand Up @@ -75,6 +78,7 @@ class BOFeatureFlag extends BOBasePage implements BOFeatureFlagInterface {
isStable = false;
break;
case this.featureFlagImprovedShipment:
case this.featureFlagDiscount:
isStable = false;
break;
default:
Expand Down
50 changes: 50 additions & 0 deletions src/versions/develop/pages/BO/catalog/discounts/discounts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import BOBasePage from '@pages/BO/BOBasePage';
import {
type Page,
} from '@playwright/test';
import type {BODiscountsPageInterface} from '@interfaces/BO/catalog/discounts/discounts';

class BODiscountsPage extends BOBasePage implements BODiscountsPageInterface {
public readonly pageTitle: string;

protected readonly addNewDiscountButton: string;

protected readonly newDiscountForm: string;

protected readonly discountTypeOption: (discountType: string) => string;

protected readonly discountTypeSubmit: string;

/**
* @constructs
* Setting up texts and selectors to use on cart rules page
*/
constructor() {
super();

this.pageTitle = 'Discounts •';

// Selectors
this.newDiscountForm = '#discount_type_selector';
this.addNewDiscountButton = '#page-header-desc-configuration-add_discount';
this.discountTypeOption = (discountType: string) => `${this.newDiscountForm} .form-check-radio:has(`
+ '[name="discount_type_selector[discount_type_selector]"]'
+ `[value="${discountType}"])`;
this.discountTypeSubmit = '#discountTypeSubmit';
}

/**
* Open modal select type and create new discount by type
*
* @param page {Page} Browser tab
* @param discountType {string} Discount to select (cart_level, product_level, ...)
* @returns {Promise<void>}
*/
async addNewDiscountByType(page: Page, discountType: string): Promise<void> {
await this.waitForSelectorAndClick(page, this.addNewDiscountButton);
await this.waitForSelectorAndClick(page, this.discountTypeOption(discountType));
await this.waitForSelectorAndClick(page, this.discountTypeSubmit);
}
}

module.exports = new BODiscountsPage();