Typecheck tests against current types

tsx runs tests without type checking and tsconfig.json covers only src,
so 71 type errors had accumulated unnoticed. tsconfig.tests.json now
checks every test and helper, and npm run typecheck includes it.

Fixtures gain the fields the DTOs have grown since they were written
(manualQuantity, circuit apparent power/cos phi, downstream board loads,
section totals, building, cover and board info fields). Repository
lookups that return "row ?? null" now declare the null in their type,
which their callers already handle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian Appel 2026-10-29 13:17:45 +01:00
parent a8cc7eca5e
commit 7222398628
37 changed files with 166 additions and 56 deletions

View file

@ -6,8 +6,12 @@
* Die App wird nur DYNAMISCH in createApp() importiert, damit das Routen-Inventar greift.
* Testdaten sind synthetisch; die Datenbank liegt nur im Speicher dieses Testprozesses.
*/
import path from "node:path";
import type { Express } from "express";
import type { collectRoutes } from "./route-inventory.ts";
// Express 5 typisiert app.router nur als Router; zur Laufzeit trägt er den
// Layer-Stack, den das generische Routen-Inventar durchläuft.
type InventoriedExpress = Express & Parameters<typeof collectRoutes>[0];
type Headers = Record<string, string>;
type Case = { method: string; path: string; body?: unknown };
@ -46,22 +50,22 @@ export async function signIn(baseUrl: string, username: string): Promise<Headers
}
const config = {
async createApp(): Promise<Express> {
async createApp(): Promise<InventoriedExpress> {
process.env.LB_DATABASE_PATH = ":memory:";
process.env.LOG_LEVEL ??= "error";
delete process.env.AUTH_BOOTSTRAP_USERNAME;
delete process.env.AUTH_BOOTSTRAP_PASSWORT;
const { migrate } = await import("drizzle-orm/better-sqlite3/migrator");
const { db } = await import("../../src/db/client.js");
migrate(db, { migrationsFolder: path.resolve("src", "db", "migrations") });
const { migrateDatabase } = await import("../support/migrate-database.js");
migrateDatabase(db);
const { userService } = await import("../../src/server/composition/auth.js");
for (const username of TEST_USERS) {
await userService.createUser({ username, name: username, role: "user", initialPassword: START_PASSWORD });
}
const { createApp } = await import("../../src/server/app.js");
return createApp();
return createApp() as InventoriedExpress;
},
// Ohne Login erreichbar: Healthcheck und die offenen Pfade von createAuthGuard.