test(ui): model browser context in plugin SSE reconnect fixture

Provide the minimal web-renderer window before importing the real ServerEvents singleton, after installing the existing network mock. The accepted lifecycle guard intentionally leaves Node imports passive; the reconnect test must explicitly supply its intended browser context.

Preserve reconnect and hidden-cache assertions, require initial constructor auto-connect through the mocked transport, and restore the exact previous global descriptor while closing mock sources. No production networking behavior is changed.

Confirmed the original natural-exit failure and the corrected test pass. The 71-file CI UI workload passes 480/480 with force-exit removed; lifecycle 2/2, compaction 11/11, neighboring stores 141/141 and UI typecheck pass. Independent delta review found no findings and verified cleanup for absent, data and accessor descriptors. Full-browser and remote CI qualification follow on this commit; historical failures remain recorded.
This commit is contained in:
Pascal André 2026-10-02 02:54:39 +02:00
parent 1795cce6aa
commit c4e36a7cbd
No known key found for this signature in database

View file

@ -13,9 +13,22 @@ test("renderer SSE reconnect invalidates every cached worktree without reading h
sources.push(source)
return source
})
// This fixture models a web renderer, not the intentionally passive Node
// import. No native bridge or network globals are needed by the mock above.
const windowDescriptor = Object.getOwnPropertyDescriptor(globalThis, "window")
t.after(() => {
sources.forEach((source) => source.close())
if (windowDescriptor) Object.defineProperty(globalThis, "window", windowDescriptor)
else Reflect.deleteProperty(globalThis, "window")
assert.deepEqual(Object.getOwnPropertyDescriptor(globalThis, "window"), windowDescriptor)
})
Object.defineProperty(globalThis, "window", { configurable: true, value: {} })
const { serverEvents } = await import("../lib/server-events")
await import("./plugin-controls-events")
await tick()
assert.equal(sources.length, 1, "the renderer auto-connects through the mocked browser transport")
assert.equal(sources[0].closed, false)
assert.equal(typeof sources[0].onopen, "function")
sources[0].onopen!()
let nativeStatuses = 0
t.after(serverEvents.on("instance.eventStatus", () => { nativeStatuses++ }))