mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-25 00:13:00 +00:00
Typecheck the test tree, and fix what it found
server/tsconfig.json has include: ["src"], so tests/ was never typechecked.
A service that gained a constructor parameter did not break its hand-wired
call sites at compile time — the argument arrived as undefined and threw at
runtime, if anything read it at all. The notifications sweep hit 46 such
sites and only a stash-diff against a throwaway tsconfig found them.
tsconfig.tests.json makes that permanent. It is not wired into CI yet: the
tree still reports 170 errors, and turning it on now would block every
unrelated PR.
Three of the first fixes were not type noise.
DAY-SVC-034 asserted that createAccommodation rolls back a failed
reservation insert. That method moved to AccommodationsService in the
days/accommodations split, so the case was calling undefined — which throws,
which satisfied .toThrow(). The rollback has been unchecked ever since,
while the case reported green. Repointed at the owner; the invariant holds.
host-rpc.test.ts typed its response as RpcResponse & Partial<RpcError>.
Both carry ok, one as true and one as false, so the intersection is never
and all 97 property reads in the file were errors nobody could see.
auth.controller.test.ts passes {} as the body in cases that stub the service
and assert on the mapping around it. That is correct as written — the point
of several of them is that the error path never reads the body — so anyBody()
names the intent instead of inventing fields the assertions do not read.
Three changePassword calls were genuinely missing the @Res() argument.
This commit is contained in:
@@ -102,7 +102,21 @@ const registry = createTestPluginRegistry([
|
||||
const factory = new PluginRpcHostFactory(dbs, registry as unknown as PluginRpcRegistryService);
|
||||
const stubRouter: PluginCallRouter = { callPlugin: async () => undefined, emitPluginEvent: () => {} };
|
||||
const makeHost = (id: string, ...perms: string[]) => factory.create(id, new Set(perms), stubRouter);
|
||||
type Res = RpcResponse & Partial<RpcError>;
|
||||
/**
|
||||
* A response read loosely, on purpose.
|
||||
*
|
||||
* `RpcResponse & Partial<RpcError>` collapsed to `never`: both carry `ok`, one
|
||||
* as the literal `true` and the other as `false`, so the intersection has no
|
||||
* inhabitant and every `.ok` / `.result` / `.error` below was an error the
|
||||
* build never saw, because tests/ sits outside tsconfig's include. The union
|
||||
* would be the honest runtime type, but `dispatch` here is asserted on from
|
||||
* both sides in the same expression, so this widens instead of narrowing.
|
||||
*/
|
||||
type Res = Pick<RpcResponse, 'k' | 'id'> & {
|
||||
ok: boolean;
|
||||
result?: unknown;
|
||||
error?: RpcError['error'];
|
||||
};
|
||||
// The acting user is a REST arg, not a defaulted one: an explicit `undefined` has to
|
||||
// stay undefined (that is the userless-context case), and a default parameter would
|
||||
// quietly turn it back into user 5.
|
||||
|
||||
Reference in New Issue
Block a user