diff --git a/src/templates/github/milestone.ts b/src/templates/github/milestone.ts index 0d9ec08..6321134 100644 --- a/src/templates/github/milestone.ts +++ b/src/templates/github/milestone.ts @@ -31,6 +31,8 @@ const template: TemplateDefinition = { label: 'Closed Issues', type: 'number' as const, defaultValue: 34, + min: 0, + max: 1000, group: 'Content' as const, }, { @@ -38,6 +40,8 @@ const template: TemplateDefinition = { label: 'Total Issues', type: 'number' as const, defaultValue: 42, + min: 0, + max: 1000, group: 'Content' as const, }, { diff --git a/src/templates/github/sponsors-goal.ts b/src/templates/github/sponsors-goal.ts index 2251869..6820e88 100644 --- a/src/templates/github/sponsors-goal.ts +++ b/src/templates/github/sponsors-goal.ts @@ -33,6 +33,8 @@ const template: TemplateDefinition = { label: 'Raised', type: 'number' as const, defaultValue: 420, + min: 0, + max: 10000, group: 'Content' as const, }, { @@ -40,6 +42,8 @@ const template: TemplateDefinition = { label: 'Goal', type: 'number' as const, defaultValue: 1000, + min: 0, + max: 10000, group: 'Content' as const, }, { diff --git a/tests/templates/registry.test.ts b/tests/templates/registry.test.ts index 9760d52..8837925 100644 --- a/tests/templates/registry.test.ts +++ b/tests/templates/registry.test.ts @@ -65,6 +65,17 @@ describe('Template Registry', () => { } }); + it('every number field default fits inside its slider range', () => { + for (const t of getAllTemplates()) { + for (const field of t.fields.filter((f) => f.type === 'number')) { + const value = Number(t.defaults[field.key] ?? field.defaultValue); + const where = `${t.id}.${field.key}`; + expect(value, where).toBeGreaterThanOrEqual(field.min ?? 0); + expect(value, where).toBeLessThanOrEqual(field.max ?? 100); + } + } + }); + it('template IDs should be unique', () => { const templates = getAllTemplates(); const ids = templates.map((t) => t.id);