Skip to content

Commit

Permalink
fix: add review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
GitEvil committed Dec 19, 2024
1 parent 74aebce commit a74172b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions src/tasks/shop-admin/Rule/AssignEntitiesToRule.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {Locator, test as base} from '@playwright/test';
import type {Task} from '../../../types/Task';
import type {FixtureTypes} from '../../../types/FixtureTypes';
import {RuleType} from '../../../types/ShopwareTypes';
import {RuleAssignmentEntities} from '../../../types/ShopwareTypes';
import { Locator, test as base } from '@playwright/test';
import type { Task } from '../../../types/Task';
import type { FixtureTypes } from '../../../types/FixtureTypes';
import { RuleType } from '../../../types/ShopwareTypes';
import { RuleAssignmentEntity } from '../../../types/ShopwareTypes';

export const AssignEntitiesToRule = base.extend<{ AssignEntitiesToRule: Task }, FixtureTypes>({
AssignEntitiesToRule: async ({ AdminRuleDetail }, use ) => {
const task = (assignableEntities: RuleAssignmentEntities[]) => {
const task = (assignableEntities: RuleAssignmentEntity[]) => {
return async function AssignEntitiesToRule() {
async function entityAssignment(entityName: string, card: Locator) {
const entityCard = await AdminRuleDetail.getEntityCard(card);
Expand All @@ -15,28 +15,28 @@ export const AssignEntitiesToRule = base.extend<{ AssignEntitiesToRule: Task },
await AdminRuleDetail.page.locator('.sw-data-grid__row').filter({hasText: entityName}).getByRole('checkbox').click();
await AdminRuleDetail.page.locator('.sw-button--primary').getByText('Add').click();
}
for (const entity of assignableEntities) {
switch (entity.ruleType) {
for (const assignableEntity of assignableEntities) {
switch (assignableEntity.ruleType) {
case RuleType.shippingAvailability:
await entityAssignment(entity.entity.name, AdminRuleDetail.shippingMethodAvailabilityRulesCard);
await entityAssignment(assignableEntity.entity.name, AdminRuleDetail.shippingMethodAvailabilityRulesCard);
break;
case RuleType.taxAvailability:
await entityAssignment(entity.entity.name, AdminRuleDetail.taxProviderRulesCard);
await entityAssignment(assignableEntity.entity.name, AdminRuleDetail.taxProviderRulesCard);
break;
case RuleType.paymentAvailability:
await entityAssignment(entity.entity.name, AdminRuleDetail.paymentMethodsAvailabilityRulesCard);
await entityAssignment(assignableEntity.entity.name, AdminRuleDetail.paymentMethodsAvailabilityRulesCard);
break;
case RuleType.promotionOrder:
await entityAssignment(entity.entity.name, AdminRuleDetail.promotionOrderRulesCard);
await entityAssignment(assignableEntity.entity.name, AdminRuleDetail.promotionOrderRulesCard);
break;
case RuleType.promotionCustomer:
await entityAssignment(entity.entity.name, AdminRuleDetail.promotionCustomerRulesCard);
await entityAssignment(assignableEntity.entity.name, AdminRuleDetail.promotionCustomerRulesCard);
break;
case RuleType.promotionCart:
await entityAssignment(entity.entity.name, AdminRuleDetail.promotionCartRulesCard);
await entityAssignment(assignableEntity.entity.name, AdminRuleDetail.promotionCartRulesCard);
break;
default:
throw new Error(`Unknown rule type "${entity.ruleType}". Valid rule types: "${Object.values(RuleType).join('", "')}".`);
throw new Error(`Unknown rule type "${assignableEntity.ruleType}". Valid rule types: "${Object.values(RuleType).join('", "')}".`);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/ShopwareTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export enum RuleType {
promotionCart = 'promotionCartRule',
}

export interface RuleAssignmentEntities {
export interface RuleAssignmentEntity {
entity: {
id: string;
name: string;
Expand Down

0 comments on commit a74172b

Please sign in to comment.