diff --git a/src/utils/workflows.spec.ts b/src/utils/workflows.spec.ts index 1721d5e..0e29a9e 100644 --- a/src/utils/workflows.spec.ts +++ b/src/utils/workflows.spec.ts @@ -23,6 +23,10 @@ describe('workflows utils', () => { }); describe('parseGracePeriodInput', () => { + it('accepts numeric values from number-backed inputs', () => { + expect(parseGracePeriodInput(7)).toEqual({ value: 7 }); + expect(parseGracePeriodInput(0)).toEqual({ value: 0 }); + }); it('returns fallback for empty input', () => { expect(parseGracePeriodInput('')).toEqual({ value: DEFAULT_GRACE_PERIOD_DAYS, diff --git a/src/utils/workflows.ts b/src/utils/workflows.ts index 4abc896..bb23c0d 100644 --- a/src/utils/workflows.ts +++ b/src/utils/workflows.ts @@ -10,10 +10,10 @@ export function toGracePeriodInputValue( } export function parseGracePeriodInput( - input: string, + input: string | number | null | undefined, fallback = DEFAULT_GRACE_PERIOD_DAYS, ): { value: number; error?: string } { - const trimmed = input.trim(); + const trimmed = String(input ?? '').trim(); if (trimmed === '') { return { value: fallback }; } diff --git a/src/views/workflows/partials/StepDefinitionForm.vue b/src/views/workflows/partials/StepDefinitionForm.vue index 0c56fc9..430c88f 100644 --- a/src/views/workflows/partials/StepDefinitionForm.vue +++ b/src/views/workflows/partials/StepDefinitionForm.vue @@ -343,18 +343,18 @@ function initForm() { function validate(): boolean { Object.keys(errors).forEach((key) => delete errors[key]); errorMessage.value = ''; - + const normalizedGracePeriodInput = String(gracePeriodDaysInput.value ?? ''); if (!form.name?.trim()) { errors.name = 'Step name is required'; return false; } - if (gracePeriodDaysInput.value.trim() === '') { + if (normalizedGracePeriodInput.trim() === '') { // Empty input is treated as "use current upstream default" rather than // persisting a nullable value for steps. form.gracePeriodDays = effectiveDefaultGracePeriodDays; } else { - const parsedGracePeriod = parseGracePeriodInput(gracePeriodDaysInput.value); + const parsedGracePeriod = parseGracePeriodInput(normalizedGracePeriodInput); if (parsedGracePeriod.error) { errors.gracePeriodDays = parsedGracePeriod.error; return false;