mirror of
https://github.com/stablyai/orca.git
synced 2026-09-29 08:03:20 +00:00
test(rpc): require unconditional terminal afterWrite callbacks
Update exact sendTerminal expectations for the round-2 accepted-write contract. Preserve beforeWrite expectations, absence of reserveWrite, byte payloads and call-count checks; require afterWrite to be a function. Reproduced the requested two-file run: 5 failed, 31 passed. The full RPC suite exposed the same stale shape in ACK budget/overflow, desktop resize (including its later retry), and agent-prompt fallback assertions. Update those too, for 11 assertions across six test files. No production changes. Validation: ORCA_BACKGROUND_LAUNCH=1 full src/main/runtime/rpc suite: 264 files passed; 2292 tests passed, 1 skipped. Changed-code quality and staged oxlint/React Doctor/oxfmt checks passed. Ran lint-staged --no-stash manually to honor checkout safety rather than its default backup hook.
This commit is contained in:
@@ -81,7 +81,7 @@ describe('terminal agent prompt send RPC', () => {
|
||||
expect(sendTerminal).toHaveBeenCalledWith(
|
||||
'terminal-1',
|
||||
{ text: 'echo x', enter: true, interrupt: false },
|
||||
{ beforeWrite: undefined, signal: undefined }
|
||||
{ beforeWrite: undefined, signal: undefined, afterWrite: expect.any(Function) }
|
||||
)
|
||||
expect(sendTerminalAgentPrompt).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
@@ -241,11 +241,15 @@ describe('terminal multiplex RPC', () => {
|
||||
)!
|
||||
)
|
||||
await vi.waitFor(() =>
|
||||
expect(runtime.sendTerminal).toHaveBeenCalledWith('terminal-1', {
|
||||
text: 'still interactive\r',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
})
|
||||
expect(runtime.sendTerminal).toHaveBeenCalledWith(
|
||||
'terminal-1',
|
||||
{
|
||||
text: 'still interactive\r',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
},
|
||||
{ afterWrite: expect.any(Function) }
|
||||
)
|
||||
)
|
||||
|
||||
handlers.get(16)?.(
|
||||
@@ -434,11 +438,15 @@ describe('terminal multiplex RPC', () => {
|
||||
)!
|
||||
)
|
||||
await vi.waitFor(() =>
|
||||
expect(runtime.sendTerminal).toHaveBeenCalledWith('terminal-8', {
|
||||
text: 'remote-still-interactive\r',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
})
|
||||
expect(runtime.sendTerminal).toHaveBeenCalledWith(
|
||||
'terminal-8',
|
||||
{
|
||||
text: 'remote-still-interactive\r',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
},
|
||||
{ afterWrite: expect.any(Function) }
|
||||
)
|
||||
)
|
||||
|
||||
const frameCountBeforeAck = binaryFrames.length
|
||||
|
||||
@@ -413,11 +413,15 @@ describe('terminal multiplex RPC', () => {
|
||||
)!
|
||||
)
|
||||
await vi.waitFor(() =>
|
||||
expect(runtime.sendTerminal).toHaveBeenCalledWith('terminal-1', {
|
||||
text: 'still interactive\r',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
})
|
||||
expect(runtime.sendTerminal).toHaveBeenCalledWith(
|
||||
'terminal-1',
|
||||
{
|
||||
text: 'still interactive\r',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
},
|
||||
{ afterWrite: expect.any(Function) }
|
||||
)
|
||||
)
|
||||
|
||||
binaryFrames.splice(0)
|
||||
|
||||
@@ -206,11 +206,15 @@ describe('terminal multiplex RPC', () => {
|
||||
)
|
||||
)
|
||||
await vi.waitFor(() =>
|
||||
expect(runtime.sendTerminal).toHaveBeenCalledWith('terminal-1', {
|
||||
text: 'ls\r',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
})
|
||||
expect(runtime.sendTerminal).toHaveBeenCalledWith(
|
||||
'terminal-1',
|
||||
{
|
||||
text: 'ls\r',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
},
|
||||
{ afterWrite: expect.any(Function) }
|
||||
)
|
||||
)
|
||||
const sentAfterSuccessfulClaim = vi.mocked(runtime.sendTerminal).mock.calls.length
|
||||
vi.mocked(runtime.updateRemoteDesktopViewer).mockResolvedValueOnce(false)
|
||||
@@ -248,11 +252,15 @@ describe('terminal multiplex RPC', () => {
|
||||
)
|
||||
}
|
||||
await vi.waitFor(() =>
|
||||
expect(runtime.sendTerminal).toHaveBeenLastCalledWith('terminal-1', {
|
||||
text: 'retry',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
})
|
||||
expect(runtime.sendTerminal).toHaveBeenLastCalledWith(
|
||||
'terminal-1',
|
||||
{
|
||||
text: 'retry',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
},
|
||||
{ afterWrite: expect.any(Function) }
|
||||
)
|
||||
)
|
||||
|
||||
dataListenerRef.current?.('a')
|
||||
|
||||
@@ -327,11 +327,15 @@ describe('terminal multiplex RPC', () => {
|
||||
)
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(runtime.sendTerminal).toHaveBeenCalledWith('terminal-1', {
|
||||
text: 'echo one\necho two\r\n',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
})
|
||||
expect(runtime.sendTerminal).toHaveBeenCalledWith(
|
||||
'terminal-1',
|
||||
{
|
||||
text: 'echo one\necho two\r\n',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
},
|
||||
{ afterWrite: expect.any(Function) }
|
||||
)
|
||||
)
|
||||
|
||||
runtime.cleanupSubscription('terminal-multiplex:conn-byte-preserving')
|
||||
@@ -403,11 +407,15 @@ describe('terminal multiplex RPC', () => {
|
||||
)
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(runtime.sendTerminal).toHaveBeenCalledWith('terminal-1', {
|
||||
text: 'printf a\nprintf b\r\n',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
})
|
||||
expect(runtime.sendTerminal).toHaveBeenCalledWith(
|
||||
'terminal-1',
|
||||
{
|
||||
text: 'printf a\nprintf b\r\n',
|
||||
enter: false,
|
||||
interrupt: false
|
||||
},
|
||||
{ afterWrite: expect.any(Function) }
|
||||
)
|
||||
)
|
||||
|
||||
runtime.cleanupSubscription('terminal-1:desktop-1')
|
||||
|
||||
@@ -370,7 +370,7 @@ describe('terminal send RPC', () => {
|
||||
expect(runtime.sendTerminal).toHaveBeenCalledWith(
|
||||
'terminal-1',
|
||||
{ text: '\x1b[3;4R', enter: false, interrupt: false },
|
||||
{ beforeWrite: undefined }
|
||||
{ beforeWrite: undefined, afterWrite: expect.any(Function) }
|
||||
)
|
||||
expect(runtime.mobileTookFloor).not.toHaveBeenCalled()
|
||||
})
|
||||
@@ -570,7 +570,7 @@ describe('terminal send RPC', () => {
|
||||
enter: false,
|
||||
interrupt: false
|
||||
},
|
||||
{ beforeWrite: undefined }
|
||||
{ beforeWrite: undefined, afterWrite: expect.any(Function) }
|
||||
)
|
||||
})
|
||||
|
||||
@@ -653,7 +653,7 @@ describe('terminal send RPC', () => {
|
||||
enter: true,
|
||||
interrupt: false
|
||||
},
|
||||
{ beforeWrite: expect.any(Function) }
|
||||
{ beforeWrite: expect.any(Function), afterWrite: expect.any(Function) }
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user