Commit cbc3ffd
committed
test(plugin-auth): type the audit sink spy so its call log is a real tuple (#8144)
`vi.fn(async () => undefined)` types `mock.calls` as `[][]` — a zero-length
tuple — so every `calls[0][0]` in this file reached past the end of a tuple the
type system believed was empty (TS2493 x3), and the dereference that followed
was `possibly undefined` (TS18048 x3). Reading the argument back is the entire
point of these cases, so the fix is to declare what the spy receives rather than
to soften the read: the spy's implementation now names its parameter, and the
call log is pulled through `recordedEvents` / `firstEvent`, which name the
"never called" case instead of letting it surface as a TypeError.
Pinning the element type to `AuthSessionAuditEventInput` also makes these
assertions type-check against the real event surface instead of `any`: a
renamed field now fails at compile time rather than quietly comparing
`undefined` to `undefined`. One `(c: any[])` map goes away with it.
Behaviour unchanged — 1113/1113 plugin-auth tests pass, same 20 cases.
Why now: #8225 lowered this package's TEST_DEBT ceiling 131 -> 111 after this
branch was cut, so these six errors stopped being slack and became a violation
in the merge queue. Measured at 117 against the merged tree, 111 after this
commit — exactly the ceiling, ledger untouched.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PEVB6w7D7uCszR9Mw1BL731 parent ea2b923 commit cbc3ffd
1 file changed
Lines changed: 46 additions & 6 deletions
Lines changed: 46 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
| |||
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
35 | 75 | | |
36 | | - | |
| 76 | + | |
37 | 77 | | |
38 | 78 | | |
39 | 79 | | |
| |||
51 | 91 | | |
52 | 92 | | |
53 | 93 | | |
54 | | - | |
| 94 | + | |
55 | 95 | | |
56 | 96 | | |
57 | 97 | | |
| |||
74 | 114 | | |
75 | 115 | | |
76 | 116 | | |
77 | | - | |
| 117 | + | |
78 | 118 | | |
79 | 119 | | |
80 | 120 | | |
| |||
90 | 130 | | |
91 | 131 | | |
92 | 132 | | |
93 | | - | |
| 133 | + | |
94 | 134 | | |
95 | 135 | | |
96 | 136 | | |
| |||
160 | 200 | | |
161 | 201 | | |
162 | 202 | | |
163 | | - | |
| 203 | + | |
164 | 204 | | |
165 | 205 | | |
166 | 206 | | |
| |||
0 commit comments