feat: Admin Area General Settings and Categories 1.05
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user