feat: Admin Area General Settings and Categories 1.05

This commit is contained in:
OpenVelo Agent
2026-07-22 14:09:02 +00:00
parent 6f4c655e62
commit 60f6f2765b
7 changed files with 399 additions and 43 deletions
@@ -87,6 +87,73 @@ describe('GeneralSettingsSchema - validation rules', () => {
expect(r.data.pageTitle).toBe('OpenVelo');
}
});
it('rejects a non-datetime eventStartUtc ("not-a-date")', () => {
const r = GeneralSettingsSchema.safeParse({
pageTitle: 'T',
logo: '',
welcomeMarkdown: '',
themeKey: 'classic',
eventStartUtc: 'not-a-date',
eventEndUtc: '2026-02-01T00:00:00Z',
defaultChallengeIp: '127.0.0.1',
registrationsEnabled: false,
});
expect(r.success).toBe(false);
if (!r.success) {
const paths = r.error.issues.map((i) => i.path.join('.'));
expect(paths).toContain('eventStartUtc');
expect(r.error.issues.some((i) => /datetime/i.test(i.message))).toBe(true);
}
});
it('rejects a non-datetime eventEndUtc and reports the issue on eventEndUtc', () => {
const r = GeneralSettingsSchema.safeParse({
pageTitle: 'T',
logo: '',
welcomeMarkdown: '',
themeKey: 'classic',
eventStartUtc: '2026-08-15T10:30:00.000Z',
eventEndUtc: 'also-not-a-date',
defaultChallengeIp: '127.0.0.1',
registrationsEnabled: false,
});
expect(r.success).toBe(false);
if (!r.success) {
const paths = r.error.issues.map((i) => i.path.join('.'));
expect(paths).toContain('eventEndUtc');
expect(paths).not.toContain('eventStartUtc');
expect(r.error.issues.some((i) => /datetime/i.test(i.message))).toBe(true);
}
});
it('rejects both fields as non-datetime strings (the Job negative case)', () => {
const r = GeneralSettingsSchema.safeParse({
pageTitle: 'T',
logo: '',
welcomeMarkdown: '',
themeKey: 'classic',
eventStartUtc: 'not-a-date',
eventEndUtc: 'also-not-a-date',
defaultChallengeIp: '127.0.0.1',
registrationsEnabled: false,
});
expect(r.success).toBe(false);
});
it('accepts empty strings (unconfigured event window) for both datetime fields', () => {
const r = GeneralSettingsSchema.safeParse({
pageTitle: 'T',
logo: '',
welcomeMarkdown: '',
themeKey: 'classic',
eventStartUtc: '',
eventEndUtc: '',
defaultChallengeIp: '127.0.0.1',
registrationsEnabled: false,
});
expect(r.success).toBe(true);
});
});
describe('AdminGeneralService.updateSettings - happy path', () => {