Skip to content

Commit a87722d

Browse files
committed
test(runtime): narrow res.response in the rewritten api-dispatch pins; test-typecheck debt re-recorded downward
The two #27506 cases in http-dispatcher.actions-type-dispatch.test.ts read `res.response.…` unnarrowed, which grew the ledgered TS18048 debt for the file (24 recorded, 28 measured). They now bind the envelope once and refuse loudly when it is absent, and the pin they replaced carried two of the ledgered accesses, so the file's debt shrinks 24 -> 22; `gen:test-typecheck-debt` re-recorded that number (no other entry moves). Claude-Session: https://claude.ai/code/session_01L6bhgWdZYC1P9NBFo7ef6W Co-authored-by: Claude <noreply@anthropic.com>
1 parent f72f7d0 commit a87722d

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

‎packages/runtime/src/http-dispatcher.actions-type-dispatch.test.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,11 @@ describe('REST /actions — client-side action types (#3915)', () => {
399399
// `/api/v1/auth/` targets receive the caller's organization scope, as
400400
// the console's api handler sends it.
401401
expect(JSON.parse(String(init.body))).toEqual(expect.objectContaining({ name: 'Core' }));
402-
expect(res.response.status).toBe(200);
402+
const answer = res.response;
403+
if (!answer) throw new Error('the door answered without a response envelope');
404+
expect(answer.status).toBe(200);
403405
// The target's own envelope is unwrapped once: `data` is its `data`.
404-
expect(res.response.body.data).toEqual({ id: 'team_1' });
406+
expect(answer.body.data).toEqual({ id: 'team_1' });
405407
});
406408

407409
it('answers 503 (not a 4xx "call it yourself") for a same-origin `type: api` action when the kernel has no HTTP server to forward through, and still names the target', async () => {
@@ -417,10 +419,12 @@ describe('REST /actions — client-side action types (#3915)', () => {
417419

418420
const res = await dispatcher.handleActions('/sys_team/create_team', 'POST', {}, ctxFor());
419421

420-
expect(res.response.status).toBe(503);
421-
expect(res.response.body.error.message).toContain('/api/v1/auth/organization/create-team');
422-
expect(res.response.body.error.message).toContain('getRawApp');
423-
expect(res.response.body.error.message).not.toMatch(/not found/i);
422+
const answer = res.response;
423+
if (!answer) throw new Error('the door answered without a response envelope');
424+
expect(answer.status).toBe(503);
425+
expect(answer.body.error.message).toContain('/api/v1/auth/organization/create-team');
426+
expect(answer.body.error.message).toContain('getRawApp');
427+
expect(answer.body.error.message).not.toMatch(/not found/i);
424428
expect(executeAction).not.toHaveBeenCalled();
425429
});
426430
});

‎packages/runtime/test-typecheck-debt.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"TS18048: 'res.response' is possibly 'undefined'.": 14
4444
},
4545
"src/http-dispatcher.actions-type-dispatch.test.ts": {
46-
"TS18048: 'res.response' is possibly 'undefined'.": 24,
46+
"TS18048: 'res.response' is possibly 'undefined'.": 22,
4747
"TS2493: Tuple type '…' of length '0' has no element at index '1'.": 6
4848
},
4949
"src/http-dispatcher.kernel-resolver.test.ts": {

0 commit comments

Comments
 (0)