diff --git a/packages/core/src/common/finite-state-machine/validate-transition-definition.spec.ts b/packages/core/src/common/finite-state-machine/validate-transition-definition.spec.ts index 5772e662b5..87dfe755ee 100644 --- a/packages/core/src/common/finite-state-machine/validate-transition-definition.spec.ts +++ b/packages/core/src/common/finite-state-machine/validate-transition-definition.spec.ts @@ -74,7 +74,7 @@ describe('FSM validateTransitionDefinition()', () => { const result = validateTransitionDefinition(valid, 'Start'); - expect(result.valid).toBe(false); + expect(result.valid).toBe(true); expect(result.error).toBe('The following states are unreachable: Unreachable'); }); diff --git a/packages/core/src/common/finite-state-machine/validate-transition-definition.ts b/packages/core/src/common/finite-state-machine/validate-transition-definition.ts index f37ed7b55d..aa5c49e6a2 100644 --- a/packages/core/src/common/finite-state-machine/validate-transition-definition.ts +++ b/packages/core/src/common/finite-state-machine/validate-transition-definition.ts @@ -53,17 +53,15 @@ export function validateTransitionDefinition( }; } - if (!allStatesReached()) { - return { - valid: false, - error: `The following states are unreachable: ${Object.entries(result) - .filter(([s, v]) => !(v as ValidationResult).reachable) - .map(([s]) => s) - .join(', ')}`, - }; - } else { - return { - valid: true, - }; - } + const error = !allStatesReached() + ? `The following states are unreachable: ${Object.entries(result) + .filter(([s, v]) => !(v as ValidationResult).reachable) + .map(([s]) => s) + .join(', ')}` + : undefined; + + return { + valid: true, + error, + }; } diff --git a/packages/core/src/service/helpers/fulfillment-state-machine/fulfillment-state-machine.ts b/packages/core/src/service/helpers/fulfillment-state-machine/fulfillment-state-machine.ts index 99bf3f753f..03bfc149c7 100644 --- a/packages/core/src/service/helpers/fulfillment-state-machine/fulfillment-state-machine.ts +++ b/packages/core/src/service/helpers/fulfillment-state-machine/fulfillment-state-machine.ts @@ -63,6 +63,9 @@ export class FulfillmentStateMachine { Logger.error(`The fulfillment process has an invalid configuration:`); throw new Error(validationResult.error); } + if (validationResult.valid && validationResult.error) { + Logger.warn(`Fulfillment process: ${validationResult.error}`); + } return { transitions: allTransitions, onTransitionStart: async (fromState, toState, data) => { diff --git a/packages/core/src/service/helpers/order-state-machine/order-state-machine.ts b/packages/core/src/service/helpers/order-state-machine/order-state-machine.ts index 6c1a985c4d..23e27acf42 100644 --- a/packages/core/src/service/helpers/order-state-machine/order-state-machine.ts +++ b/packages/core/src/service/helpers/order-state-machine/order-state-machine.ts @@ -56,6 +56,9 @@ export class OrderStateMachine { Logger.error(`The order process has an invalid configuration:`); throw new Error(validationResult.error); } + if (validationResult.valid && validationResult.error) { + Logger.warn(`Order process: ${validationResult.error}`); + } return { transitions: allTransitions, onTransitionStart: async (fromState, toState, data) => { diff --git a/packages/core/src/service/helpers/payment-state-machine/payment-state-machine.ts b/packages/core/src/service/helpers/payment-state-machine/payment-state-machine.ts index d96e74d030..3a59dc1746 100644 --- a/packages/core/src/service/helpers/payment-state-machine/payment-state-machine.ts +++ b/packages/core/src/service/helpers/payment-state-machine/payment-state-machine.ts @@ -58,6 +58,9 @@ export class PaymentStateMachine { Logger.error(`The payment process has an invalid configuration:`); throw new Error(validationResult.error); } + if (validationResult.valid && validationResult.error) { + Logger.warn(`Payment process: ${validationResult.error}`); + } return { transitions: allTransitions, onTransitionStart: async (fromState, toState, data) => {