test(relay): treat minted PTY ids as opaque

This commit is contained in:
Brennan Benson
2026-08-27 16:56:12 -07:00
parent 8ee33c660f
commit 557d0b5969
2 changed files with 8 additions and 4 deletions
@@ -159,16 +159,20 @@ describe('relay PTY output drain — differential vs the pre-optimization snapsh
async function spawnPtys(count: number): Promise<string[]> {
const ids: string[] = []
for (let i = 0; i < count; i++) {
let dataCallback!: (data: string) => void
let exitCallback!: (event: { exitCode: number }) => void
mockPtySpawn.mockReturnValueOnce({
...mockPtyInstance,
onData: vi.fn((cb: (data: string) => void) => {
dataCallbacks.set(`pty-${i + 1}`, cb)
dataCallback = cb
}),
onExit: vi.fn((cb: (event: { exitCode: number }) => void) => {
exitCallbacks.set(`pty-${i + 1}`, cb)
exitCallback = cb
})
})
const spawned = (await dispatcher.callRequest('pty.spawn', {})) as { id: string }
dataCallbacks.set(spawned.id, dataCallback)
exitCallbacks.set(spawned.id, exitCallback)
ids.push(spawned.id)
}
return ids
+2 -2
View File
@@ -204,7 +204,7 @@ describe('Subprocess: Relay entry point', () => {
const repairedId = relay.send('pty.spawn', { cols: 80, rows: 24 })
const repaired = await relay.waitForResponse(repairedId)
expect(repaired.error).toBeUndefined()
expect(repaired.result).toMatchObject({ id: 'pty-1' })
expect(repaired.result).toMatchObject({ id: expect.any(String) })
}, 10_000)
it('reloads node-pty after a late native binding failure without restarting', async () => {
@@ -228,7 +228,7 @@ describe('Subprocess: Relay entry point', () => {
const repairedId = relay.send('pty.spawn', { cols: 80, rows: 24 })
const repaired = await relay.waitForResponse(repairedId)
expect(repaired.error).toBeUndefined()
expect(repaired.result).toMatchObject({ id: 'pty-2' })
expect(repaired.result).toMatchObject({ id: expect.any(String) })
}, 10_000)
it('responds to fs.stat over stdin/stdout', async () => {