Skip to content

Commit ca3e4b7

Browse files
test: handle the rejections of the MCP waiters that give up
1 parent 66e53c1 commit ca3e4b7

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/core/webview/__tests__/mcpEnabledChanges.spec.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ describe("changeMcpEnabled", () => {
187187
// Each caller has its own promise: one that gives up is answered at once, the other goes on waiting.
188188
expect(b).not.toBe(a)
189189
const aLeft = a.catch(() => undefined)
190+
const bGaveUp = expect(b).rejects.toThrow("gave up") // answered at once, and not left unhandled
190191
second.abort(new Error("gave up")) // ... is given up on: the value of the other save is what waits
192+
await bGaveUp
191193

192194
await vi.waitFor(() => expect(releases).toHaveLength(1))
193195
releases[0]()
@@ -205,13 +207,15 @@ describe("changeMcpEnabled", () => {
205207

206208
void changeMcpEnabled(hub, true)
207209
const waiting = changeMcpEnabled(hub, false, first.signal)
208-
void changeMcpEnabled(hub, false, second.signal)
210+
const other = changeMcpEnabled(hub, false, second.signal)
211+
const otherGaveUp = expect(other).rejects.toThrow("gave up")
209212
const rejected = expect(waiting).rejects.toThrow("gave up")
210213
first.abort(new Error("gave up"))
211214
await Promise.resolve()
212215
expect(hub.handleMcpEnabledChange).toHaveBeenCalledTimes(1) // one save is still waiting for it
213216
second.abort(new Error("gave up"))
214217
await rejected
218+
await otherGaveUp
215219

216220
releases[0]()
217221
await new Promise((resolve) => setTimeout(resolve, 20))

0 commit comments

Comments
 (0)