wip league admin tools

This commit is contained in:
2025-12-28 12:04:12 +01:00
parent 5dc8c2399c
commit 6edf12fda8
401 changed files with 15365 additions and 6047 deletions

View File

@@ -0,0 +1,34 @@
import { describe, it, expect } from 'vitest';
import * as fs from 'fs/promises';
import * as path from 'path';
describe('Schedule boundary: view-model constructors must not depend on DTOs or mappers', () => {
it('rejects schedule ViewModels importing from mappers or types/generated', async () => {
const websiteRoot = path.resolve(__dirname, '../../..');
const viewModelFiles = [
'lib/view-models/LeagueScheduleViewModel.ts',
'lib/view-models/LeagueAdminScheduleViewModel.ts',
];
const forbiddenImportRegex =
/^\s*import[\s\S]*from\s+['"][^'"]*(\/mappers\/|\/types\/generated\/)[^'"]*['"]/gm;
const offenders: Array<{ file: string; matches: string[] }> = [];
for (const rel of viewModelFiles) {
const abs = path.join(websiteRoot, rel);
const content = await fs.readFile(abs, 'utf-8');
const matches = Array.from(content.matchAll(forbiddenImportRegex)).map((m) => m[0]).filter(Boolean);
if (matches.length > 0) {
offenders.push({ file: rel, matches });
}
}
expect(offenders, `Forbidden imports found:\n${offenders
.map((o) => `- ${o.file}\n${o.matches.map((m) => ` ${m}`).join('\n')}`)
.join('\n')}`).toEqual([]);
});
});