Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/utils/workflows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand Down
6 changes: 3 additions & 3 deletions src/views/workflows/partials/StepDefinitionForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down