test STA-5878 ownership and fence refusals

This commit is contained in:
Merge Sim
2026-08-31 12:51:06 -07:00
parent 47d42946d4
commit 9fb61b2e3a
2 changed files with 40 additions and 1 deletions
@@ -60,4 +60,43 @@ describe('TerminalHost pending kill fences', () => {
await host.dispose()
}
})
it('preserves a replacement session when a stale pending kill is fenced out', async () => {
const subprocess: SubprocessHandle = {
pid: 99999,
getForegroundProcess: () => null,
write: vi.fn(),
resize: vi.fn(),
kill: vi.fn(),
forceKill: vi.fn(),
terminateOwnedTree: () => 'unavailable',
signal: vi.fn(),
onData: vi.fn(),
onExit: vi.fn(),
dispose: vi.fn()
}
const host = new TerminalHost({ spawnSubprocess: () => subprocess })
try {
const replacement = await host.createOrAttach({
sessionId: 'replacement-fence',
cols: 80,
rows: 24,
streamClient: { onData: vi.fn(), onExit: vi.fn() }
})
await expect(
host.kill('replacement-fence', {
immediate: true,
incarnationId: 'stale-incarnation'
})
).resolves.toEqual({ fenceUnavailable: true })
expect(host.listSessions()).toEqual([
expect.objectContaining({
id: 'replacement-fence',
incarnationId: replacement.incarnationId
})
])
} finally {
await host.dispose()
}
})
})
+1 -1
View File
@@ -91,7 +91,7 @@ describe('killPtySessions input bounds', () => {
providerForSession: (id) => (id === 'failed' ? failed : healthy) as never,
isOwned: () => ({ owned: false }),
shutdown,
ownershipUnavailable: (provider) => provider === failed
ownershipUnavailable: (provider) => provider === (failed as never)
})
expect(shutdown).toHaveBeenCalledTimes(1)