Repository navigation
Commit 7a1a710
committed
test(tools): name the abort listener the cancelled-stream release must drop
The getState() cancellation case asserted that task.off() was called with
expect.any(Function). A function-shaped matcher cannot fail: it passes when the release
deregisters a different callback, and it passes when the listener was never registered at
all, which is the half of the contract this case exists for. The state the case seeds is
also the state the listener is attached to, so the reference is available - capture it,
pin the registration before the release, and assert the release against the same value.
Measured with git grep -n -e expect.any(Function) over src at this head: 57 occurrences in
27 files, one of them on an off() call (this line) and none on a once() call; at the merge
base 37 occurrences in 18 files. The matcher is common in this tree, the listener-removal
shape was not, so this settles the row rather than generalising it.
Gates (node v22.23.4): vitest.core.config.ts writeToFileTool-partial-state-cleanup.spec.ts
10 passed. Negative control with task.once(RooCodeEventName.TaskAborted, state.abortCleanup)
deleted from WriteToFileTool.ts (git show HEAD of the file, written back and compared
byte-for-byte): 4 failed | 6 passed - this case fails on both halves of the pairing, which
the class matcher passed silently.1 parent 7dd3077 commit 7a1a710
1 file changed
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
230 | 242 | | |
231 | 243 | | |
232 | 244 | | |
| |||
238 | 250 | | |
239 | 251 | | |
240 | 252 | | |
241 | | - | |
| 253 | + | |
242 | 254 | | |
243 | 255 | | |
244 | 256 | | |
| |||
0 commit comments