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();
+5 -1
View File
@@ -80,7 +80,11 @@ describe('the SSE filter while tiles own the terminal', () => {
const app = readFileSync(resolve(import.meta.dirname, '../src/web/public/app.js'), 'utf8');
const start = app.indexOf('const _sseParams = new URLSearchParams(');
expect(start).toBeGreaterThan(-1);
const block = app.slice(start, app.indexOf('this.eventSource = new EventSource(', start));
// Both ends must be found: a missing end marker makes slice() take the
// rest of app.js, and the checks below would then pass on any text.
const end = app.indexOf('const eventSource = new EventSource(', start);
expect(end).toBeGreaterThan(start);
const block = app.slice(start, end);
expect(block).toContain('this._sseFilterSessionId(this.activeSessionId)');
expect(block).not.toMatch(/set\('sessions', this\.activeSessionId\)/);
});