Files
orca/src/main/ipc/runtime-environment-diagnostics-broadcast.test.ts
T
Brennan BensonandMerge Sim aabcc57366 fix(runtime): publish remote control outages to host surfaces (#17531)
* fix(runtime): publish remote control diagnostics to renderer

* test(runtime): account for diagnostics bridge listener

* fix(i18n): add runtime connection state labels

* test(runtime): clean up shared control connection

* fix(runtime): fence diagnostics by shared-control capability

* fix(runtime): preserve authoritative transport state

* fix(runtime): preserve diagnostic overlay lifecycle

* fix(runtime): avoid publishing unchanged diagnostics state

---------

Co-authored-by: Merge Sim <sim@local>
2026-08-31 12:25:17 -07:00

41 lines
1.3 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from 'vitest'
const getAllWindows = vi.hoisted(() => vi.fn())
vi.mock('electron', () => ({ BrowserWindow: { getAllWindows } }))
import {
publishRuntimeEnvironmentDiagnostics,
RUNTIME_ENVIRONMENT_DIAGNOSTICS_CHANNEL
} from './runtime-environment-diagnostics-broadcast'
describe('runtime environment diagnostics broadcast', () => {
beforeEach(() => getAllWindows.mockReset())
it('publishes to live renderer windows and skips destroyed windows', () => {
const live = { isDestroyed: () => false, webContents: { send: vi.fn() } }
const destroyed = { isDestroyed: () => true, webContents: { send: vi.fn() } }
getAllWindows.mockReturnValue([live, destroyed])
const event = {
environmentId: 'env-a',
transportGeneration: 2,
diagnostics: {
state: 'reconnecting' as const,
pendingRequestCount: 0,
subscriptionCount: 1,
reconnectAttempt: 1,
lastConnectedAt: 1,
lastClose: null,
lastError: 'offline'
}
}
publishRuntimeEnvironmentDiagnostics(event)
expect(live.webContents.send).toHaveBeenCalledWith(
RUNTIME_ENVIRONMENT_DIAGNOSTICS_CHANNEL,
event
)
expect(destroyed.webContents.send).not.toHaveBeenCalled()
})
})