mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-01 08:12:43 +00:00
test: serve a fresh mock response per fetch in the keep-alive test
The keep-alive test parked one shared Response instance in mockResolvedValue, but a Response body is single-use - as soon as more than one request lands in the 30s window the second read dies with "Body is unusable" and the ping reports a lost connection. Serve a fresh Response per call via mockImplementation, the pattern the rest of this file already uses.
This commit is contained in:
@@ -373,7 +373,10 @@ describe('JMAPClient resilience', () => {
|
||||
client.onConnectionChange(callback);
|
||||
|
||||
const echoResponse = { methodResponses: [['Core/echo', { ping: 'pong' }, '0']] };
|
||||
fetchSpy.mockResolvedValue(mockFetchResponse(200, echoResponse));
|
||||
// A Response body is single-use, so one shared instance breaks as soon
|
||||
// as anything fetches more than once in the window - serve a fresh one
|
||||
// per call like the other tests in this file.
|
||||
fetchSpy.mockImplementation(() => Promise.resolve(mockFetchResponse(200, echoResponse)));
|
||||
|
||||
// Advance past keep-alive interval (30s)
|
||||
await vi.advanceTimersByTimeAsync(30_000);
|
||||
|
||||
Reference in New Issue
Block a user