fix: address the release-prep review of #678

test/tile-grid-sse-filter.test.ts: search for the renamed 'const eventSource = new EventSource(' end marker and require both ends, so the connect-URL check covers that block again instead of the rest of app.js
test/sse-connect-timeout.test.ts: cover the replaced-EventSource guard in _handleSseConnectionFailure() (a late error from a replaced attempt leaves the new one alone)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-10-24 14:36:42 +02:00
1 parent f4f9001a4b
commit 5222239966
2 files changed
+25 -1

No files matched your search

+20
View File
@@ -194,6 +194,26 @@ describe('SSE connect timeout', () => {
expect(app.reconnectAttempts).toBe(1);
});
it('a late error from a replaced EventSource leaves the connection that replaced it alone', () => {
const app = makeApp();
app.connectSSE();
const first = FakeEventSource.all[0];
app.connectSSE(); // e.g. the user pressed Retry
const second = FakeEventSource.all[1];
// A browser that still fires onerror on the closed first attempt.
first.fail();
expect(app.eventSource).toBe(second);
expect(second.closed).toBe(false);
expect(app.reconnectAttempts).toBe(0);
// No retry was scheduled, and the second attempt keeps its own deadline.
vi.advanceTimersByTime(TIMEOUT - 1);
expect(FakeEventSource.all).toHaveLength(2);
expect(second.closed).toBe(false);
vi.advanceTimersByTime(1);
expect(second.closed).toBe(true);
expect(app.reconnectAttempts).toBe(1);
});
it('connectSSE() while offline cancels the pending timer (the online event reconnects)', () => {
const app = makeApp();
app.connectSSE();