ac6c834525
- main.ts awaits DatabaseInitService.init() before app.listen(), ensuring
migrations + seed run before the HTTP server accepts traffic.
- AppModule now uses NestModule with consumer.apply() no longer needed for
CSRF (registered globally via app.use after body parsers in main.ts).
- JwtAuthGuard extended from AuthGuard('jwt') so protected endpoints
actually validate the bearer token.
- Admin controller now uses Zod-validated DTOs for body/path/query:
createUser, updateUserRole, userIdParam, listUsersQuery; with @Public
/ @Roles decorators and AdminGuard applied.
- Multer upload module + controller (POST /api/v1/uploads/category-icon
and /challenge-file) with safe-filename strategy, configured
UPLOAD_SIZE_LIMIT, admin-only via AdminGuard, served via /uploads
static handler.
- ThemeLoaderService now requires all 10 canonical theme ids at startup,
backfilling missing themes from built-ins with a warning; validates the
configured themeKey setting and falls back to 'classic' if invalid;
gracefully tolerates missing setting table during early boot.
- Test suite expanded to 76 tests / 17 suites; new specs:
admin-validation, uploads, theme-required, database-init.
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { ThemeLoaderService, BUILTIN_THEMES } from '../../backend/src/common/utils/theme-loader.service';
|
|
|
|
describe('ThemeLoaderService builtins', () => {
|
|
it('includes all 10 canonical theme ids', () => {
|
|
const ids = BUILTIN_THEMES.map((t) => t.id).sort();
|
|
expect(ids).toEqual([
|
|
'classic', 'crimson', 'cyber', 'forest', 'midnight',
|
|
'monochrome', 'neon', 'ocean', 'paper', 'sunset',
|
|
]);
|
|
});
|
|
|
|
it('every builtin theme has full tokens', () => {
|
|
for (const t of BUILTIN_THEMES) {
|
|
expect(t.tokens.primary).toMatch(/^#/);
|
|
expect(t.tokens.radii.sm).toBeTruthy();
|
|
expect(t.tokens.spacingScale.length).toBeGreaterThan(0);
|
|
}
|
|
});
|
|
|
|
it('falls back to default for unknown id', () => {
|
|
const config = { get: jest.fn((k: string, d: any) => d) } as any;
|
|
const settings = { get: jest.fn().mockResolvedValue('classic') } as any;
|
|
const svc = new ThemeLoaderService(config, settings);
|
|
return svc.onModuleInit().then(() => {
|
|
const t = svc.getTheme('totally-unknown');
|
|
expect(t.id).toBe('classic');
|
|
});
|
|
});
|
|
}); |