From a74172bb27b898256cd5e6a434ef45c55c4edccc Mon Sep 17 00:00:00 2001 From: Daniel Meyer Date: Thu, 19 Dec 2024 10:25:13 +0100 Subject: [PATCH] fix: add review feedback --- .../shop-admin/Rule/AssignEntitiesToRule.ts | 30 +++++++++---------- src/types/ShopwareTypes.ts | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/tasks/shop-admin/Rule/AssignEntitiesToRule.ts b/src/tasks/shop-admin/Rule/AssignEntitiesToRule.ts index e8cba24..14b017f 100644 --- a/src/tasks/shop-admin/Rule/AssignEntitiesToRule.ts +++ b/src/tasks/shop-admin/Rule/AssignEntitiesToRule.ts @@ -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); @@ -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('", "')}".`); } } } diff --git a/src/types/ShopwareTypes.ts b/src/types/ShopwareTypes.ts index a3589df..121f9ca 100644 --- a/src/types/ShopwareTypes.ts +++ b/src/types/ShopwareTypes.ts @@ -243,7 +243,7 @@ export enum RuleType { promotionCart = 'promotionCartRule', } -export interface RuleAssignmentEntities { +export interface RuleAssignmentEntity { entity: { id: string; name: string;