mirror of
https://github.com/NeuralNomadsAI/CodeNomad.git
synced 2026-10-21 05:06:37 +00:00
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:
parent
1795cce6aa
commit
c4e36a7cbd
1 changed files with 13 additions and 0 deletions
|
|
@ -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++ }))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue