wip league admin tools
This commit is contained in:
@@ -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([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user