Repository navigation
Commit dd76f1a
committed
test(test-utils): type the Memento and secrets doubles and make freshness the helper's contract
The three fixture declarations in core/config/__tests__/ContextProxy.spec.ts were typed as any, so the file
carried three of the five no-explicit-any suppressions it has. The shape they need already existed, privately,
inside test-utils/vscode.ts: makeExtensionContext built its own local makeMemento(). That shape is now
exported as makeFreshMemento and makeFreshSecrets, with typed double aliases (MementoDouble, SecretsDouble),
and makeExtensionContext consumes the exported form so there is one definition rather than two local ones.
This repo types ExtensionContext.globalState as Memento plus setKeysForSync and has no top-level vscode.Secrets,
so the doubles are built from ExtensionContext["secrets"] and carry setKeysForSync: the double is typed to the
interface instead of the call sites being loosened, and no call site needed a cast.
Freshness is named, not inferred: the export is called makeFresh* and says in a comment that every call
returns a new object with new spies, because a module-scope Memento in a shared test helper is a silent
cross-test leak. The Memento double now keeps a real per-call store, and the pinned assertion writes a key
through one double and asserts the next double cannot see it - its negative control (one shared store for
every call) reddens exactly that assertion and nothing else, which is what shows the assertion is not
vacuous. The secrets and extension doubles keep their payloads inline at the call site so the test still
reads as the scenario rather than as the plumbing.
Tests did not change meaning while their fixtures changed type: before, 67 passed of 67; after, 68 passed of
68, the single addition being the helper's own freshness assertion. tsc --noEmit over the tree is 0, which is
the check that matters here because the change widens a module surface. eslint with the lowered entry is
clean, so 2 is the real violation count rather than a permissive one.
Suppression entry for core/config/__tests__/ContextProxy.spec.ts goes 5 -> 2, a decrease of 3, which is what
the never-increase rule wants. The two survivors are the inline predicates at :1232 and :1248 (
(call: any[]) => call[0] === "customSupportPrompts"), which are outside this assignment and were left alone.
upstream/main carries the same 5 for this file, so the baseline was not inherited looser than main's. The
prune run reported no other entry changing, so this commit's suppressions diff is that one entry and the
file is written by editing that entry in place so the diff shows one line rather than a re-emitted file.
Test-only: no file outside src/test-utils and one spec changed, plus the suppression entry. Co-Authored-By:
Claude <[email protected]>1 parent ac3db54 commit dd76f1a
3 files changed
Lines changed: 110 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
9 | 17 | | |
10 | 18 | | |
11 | 19 | | |
| |||
24 | 32 | | |
25 | 33 | | |
26 | 34 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
30 | 38 | | |
31 | 39 | | |
32 | 40 | | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
36 | | - | |
| 44 | + | |
37 | 45 | | |
38 | 46 | | |
39 | | - | |
| 47 | + | |
40 | 48 | | |
41 | 49 | | |
42 | | - | |
| 50 | + | |
43 | 51 | | |
44 | 52 | | |
45 | 53 | | |
46 | | - | |
| 54 | + | |
47 | 55 | | |
48 | 56 | | |
49 | 57 | | |
| |||
56 | 64 | | |
57 | 65 | | |
58 | 66 | | |
59 | | - | |
| 67 | + | |
60 | 68 | | |
61 | 69 | | |
62 | 70 | | |
63 | 71 | | |
64 | 72 | | |
65 | 73 | | |
66 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
67 | 87 | | |
68 | 88 | | |
69 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
539 | | - | |
| 539 | + | |
540 | 540 | | |
541 | 541 | | |
542 | 542 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
138 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
139 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
140 | 213 | | |
141 | 214 | | |
142 | | - | |
143 | | - | |
| 215 | + | |
| 216 | + | |
144 | 217 | | |
145 | 218 | | |
146 | 219 | | |
| |||
0 commit comments