Skip to content

Commit

Permalink
feat: Add Rule Detail page object (#156)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Meyer <[email protected]>
  • Loading branch information
GitEvil and Daniel Meyer authored Nov 12, 2024
1 parent a63fa80 commit 689baaf
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/page-objects/AdministrationPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ShippingListing } from './administration/ShippingListing';
import { LandingPageCreate } from './administration/LandingPageCreate';
import { LandingPageDetail } from './administration/LandingPageDetail';
import { Categories } from './administration/Categories';
import { RuleDetail } from './administration/RuleDetail';

export interface AdministrationPageTypes {
AdminProductDetail: ProductDetail;
Expand All @@ -29,6 +30,7 @@ export interface AdministrationPageTypes {
AdminCategories: Categories;
AdminLandingPageCreate: LandingPageCreate;
AdminLandingPageDetail: LandingPageDetail;
AdminRuleDetail: RuleDetail;
}

export const AdminPageObjects = {
Expand All @@ -45,6 +47,7 @@ export const AdminPageObjects = {
Categories,
LandingPageCreate,
LandingPageDetail,
RuleDetail,
}

export const test = base.extend<FixtureTypes>({
Expand Down Expand Up @@ -100,4 +103,7 @@ export const test = base.extend<FixtureTypes>({
AdminLandingPageCreate: async ({ AdminPage }, use) => {
await use(new LandingPageCreate(AdminPage));
},
AdminRuleDetail: async ({ AdminPage }, use) => {
await use(new RuleDetail(AdminPage));
},
});
17 changes: 17 additions & 0 deletions src/page-objects/administration/RuleDetail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Page, Locator } from '@playwright/test';
import type { PageObject } from '../../types/PageObject';

export class RuleDetail implements PageObject {

public readonly nameInput: Locator;
public readonly priorityInput: Locator;

constructor(public readonly page: Page) {
this.nameInput = page.getByLabel('Name');
this.priorityInput = page.getByLabel('Priority')
}

url(ruleId: string, tabName = 'base') {
return `#/sw/settings/rule/detail/${ruleId}/${tabName}`
}
}
13 changes: 8 additions & 5 deletions src/services/TestDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,13 @@ export class TestDataService {
* @param overrides - Specific data overrides that will be applied to the payment method data struct.
*/
async createBasicRule(
overrides: Partial<Rule> = {}
overrides: Partial<Rule> = {},
conditionType = 'cartCartAmount',
operator = '>=',
amount = 1,
): Promise<Rule> {

const basicRule = this.getBasicRuleStruct(overrides);
const basicRule = this.getBasicRuleStruct(overrides, conditionType, operator, amount);

const ruleResponse = await this.AdminApiClient.post('rule?_response=detail', {
data: basicRule,
Expand Down Expand Up @@ -1347,9 +1350,9 @@ export class TestDataService {

getBasicRuleStruct(
overrides: Partial<Rule> = {},
conditionType = 'cartCartAmount',
operator = '>=',
amount = 1,
conditionType: string,
operator: string,
amount: number,
): Partial<Rule> {

const { id: ruleId, uuid: ruleUuid } = this.IdProvider.getIdPair();
Expand Down

0 comments on commit 689baaf

Please sign in to comment.