Skip to content

Commit

Permalink
fix: task and types
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Meyer committed Dec 16, 2024
1 parent 38f3163 commit 74aebce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/tasks/shop-admin/Rule/AssignEntitiesToRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ 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';
import {RuleAssignmentEntities} from '../../../types/ShopwareTypes';

export const AssignEntitiesToRule = base.extend<{ AssignEntitiesToRule: Task }, FixtureTypes>({
AssignEntitiesToRule: async ({ AdminRuleDetail }, use ) => {
const task = (assignableEntities: RuleAssignmentEntity[]) => {
const task = (assignableEntities: RuleAssignmentEntities[]) => {
return async function AssignEntitiesToRule() {
async function entityAssignment(entityName: string, card: Locator) {
const entityCard = await AdminRuleDetail.getEntityCard(card);
Expand All @@ -18,22 +18,22 @@ export const AssignEntitiesToRule = base.extend<{ AssignEntitiesToRule: Task },
for (const entity of assignableEntities) {
switch (entity.ruleType) {
case RuleType.shippingAvailability:
await entityAssignment(entity.name, AdminRuleDetail.shippingMethodAvailabilityRulesCard);
await entityAssignment(entity.entity.name, AdminRuleDetail.shippingMethodAvailabilityRulesCard);
break;
case RuleType.taxAvailability:
await entityAssignment(entity.name, AdminRuleDetail.taxProviderRulesCard);
await entityAssignment(entity.entity.name, AdminRuleDetail.taxProviderRulesCard);
break;
case RuleType.paymentAvailability:
await entityAssignment(entity.name, AdminRuleDetail.paymentMethodsAvailabilityRulesCard);
await entityAssignment(entity.entity.name, AdminRuleDetail.paymentMethodsAvailabilityRulesCard);
break;
case RuleType.promotionOrder:
await entityAssignment(entity.name, AdminRuleDetail.promotionOrderRulesCard);
await entityAssignment(entity.entity.name, AdminRuleDetail.promotionOrderRulesCard);
break;
case RuleType.promotionCustomer:
await entityAssignment(entity.name, AdminRuleDetail.promotionCustomerRulesCard);
await entityAssignment(entity.entity.name, AdminRuleDetail.promotionCustomerRulesCard);
break;
case RuleType.promotionCart:
await entityAssignment(entity.name, AdminRuleDetail.promotionCartRulesCard);
await entityAssignment(entity.entity.name, AdminRuleDetail.promotionCartRulesCard);
break;
default:
throw new Error(`Unknown rule type "${entity.ruleType}". Valid rule types: "${Object.values(RuleType).join('", "')}".`);
Expand Down
7 changes: 5 additions & 2 deletions src/types/ShopwareTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,12 @@ export enum RuleType {
promotionCustomer = 'promotionCustomerRule',
promotionCart = 'promotionCartRule',
}
export interface RuleAssignmentEntity {

export interface RuleAssignmentEntities {
entity: {
id: string;
name: string;
ruleType: RuleType;
}
ruleType: RuleType
}

0 comments on commit 74aebce

Please sign in to comment.