Commit 5e309bf
test: stub user-preference fetches in the global setup to stop a cross-test leak (#60)
Admin surfaces load user preferences on mount (e.g. module-inserter
favourites via useModuleInserterPreference → getUserPreference), firing a
real fetch to /admin/api/cms/me/preferences/<key>. In tests that hits
localhost and rejects with ECONNREFUSED. The preference store is a
module-level singleton whose load promise can outlive the component that
triggered it, so the rejection surfaces during a LATER test's cleanup() as
an AggregateError — a render-timing-dependent cross-test flake.
It was masked while canvas frames mounted slowly (the tests timed out before
the preference fetch settled) and reappeared once frames mount synchronously
(#58), failing the release Verify step on canvasFrameMounting's first test.
Return the server's "never set" envelope ({ value: null }) for preference
GETs in the global test preload, so the load resolves cleanly to each
caller's own default with no network call. Tests that need specific
preference data still override globalThis.fetch in their own setup;
getUserPreference callers that inject a fetchImpl bypass this entirely.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent bb36941 commit 5e309bf
1 file changed
Lines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 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 | + | |
118 | 160 | | |
119 | 161 | | |
120 | 162 | | |
| |||
0 commit comments