mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 09:07:40 +00:00
* chore(session): delete three session paths nothing calls any more - session:set-sync IPC (bridge, type member, web adapter stub); quit uses app:stage-before-unload-sync - the session-write persist gate (shouldSchedulePersist / subscribeToPersistGateOpen); the one production subscriber passes neither - reconcileDeadSessions and the binding's reconcileIfSessionDead; the live reconcileIfSessionMissing path stays Tests that drove these are retargeted to the live paths or removed. * chore(session): name shouldPersistWorkspaceSession in the deferral comment
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
const { handlers } = vi.hoisted(() => ({
|
|
handlers: new Map<string, (event: { returnValue?: unknown }, ...args: unknown[]) => unknown>()
|
|
}))
|
|
|
|
vi.mock('electron', () => ({
|
|
ipcMain: {
|
|
handle: vi.fn(
|
|
(
|
|
channel: string,
|
|
handler: (event: { returnValue?: unknown }, ...args: unknown[]) => unknown
|
|
) => {
|
|
handlers.set(channel, handler)
|
|
}
|
|
),
|
|
on: vi.fn(
|
|
(
|
|
channel: string,
|
|
handler: (event: { returnValue?: unknown }, ...args: unknown[]) => unknown
|
|
) => {
|
|
handlers.set(channel, handler)
|
|
}
|
|
)
|
|
}
|
|
}))
|
|
|
|
import { registerSessionHandlers } from './session'
|
|
|
|
describe('registerSessionHandlers', () => {
|
|
it('drops renderer writes to a fenced host source partition and keeps every other one', async () => {
|
|
const store = {
|
|
getSshTarget: vi.fn((id: string) =>
|
|
id === 'fenced' ? { orcadFence: { environmentId: 'env-1' } } : {}
|
|
),
|
|
setWorkspaceSession: vi.fn(),
|
|
patchWorkspaceSession: vi.fn(),
|
|
flushPendingOrThrowAsync: vi.fn(() => Promise.resolve())
|
|
}
|
|
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the handlers under test touch only the store methods stubbed above and never the runtime.
|
|
registerSessionHandlers(store as never, {} as never)
|
|
|
|
for (const hostId of ['ssh:fenced', 'ssh:open', undefined]) {
|
|
await handlers.get('session:set')?.({}, {}, hostId)
|
|
await handlers.get('session:patch')?.({}, {}, hostId)
|
|
}
|
|
expect(store.setWorkspaceSession.mock.calls.map(([, hostId]) => hostId)).toEqual([
|
|
'ssh:open',
|
|
undefined
|
|
])
|
|
expect(store.patchWorkspaceSession.mock.calls.map(([, hostId]) => hostId)).toEqual([
|
|
'ssh:open',
|
|
undefined
|
|
])
|
|
})
|
|
})
|