mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
test: remove worker approval smoke and duplicate refusal cases
This commit is contained in:
@@ -148,19 +148,4 @@ describe('projectGroups IPC validation', () => {
|
||||
expect(mockStore.addRepo).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
it('refuses nested imports on an SSH target and never inspects the path locally', async () => {
|
||||
await expect(
|
||||
handlers.get('projectGroups:importNested')!(null, {
|
||||
parentPath: '/srv/platform',
|
||||
groupName: 'Platform',
|
||||
projectPaths: ['/srv/platform/api'],
|
||||
connectionId: 'conn-1',
|
||||
mode: 'group'
|
||||
})
|
||||
).rejects.toThrow('ssh_connection_unavailable')
|
||||
|
||||
expect(mockStore.addRepo).not.toHaveBeenCalled()
|
||||
expect(isGitRepo).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -84,16 +84,6 @@ describe('projectGroups IPC validation', () => {
|
||||
registerRepoHandlers(mockWindow as never, mockStore as never, {} as never)
|
||||
})
|
||||
|
||||
it('refuses SSH nested scans without reading the remote or the local filesystem', async () => {
|
||||
await expect(
|
||||
handlers.get('projectGroups:scanNested')!(null, {
|
||||
path: '/srv/platform',
|
||||
connectionId: 'conn-1'
|
||||
})
|
||||
).rejects.toThrow('ssh_connection_unavailable')
|
||||
expect(isGitRepo).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('returns partial local scan results after cancellation', async () => {
|
||||
vi.mocked(isGitRepo).mockReturnValue(false)
|
||||
const root = await mkdtemp(join(tmpdir(), 'orca-nested-local-cancel-'))
|
||||
|
||||
@@ -84,7 +84,6 @@ it('keeps showing an open approval behind more closed ones than the row bound',
|
||||
|
||||
const [row] = buildCrewSnapshot('term_coord', deps).sections.managing
|
||||
const ids = row.approvals?.map(({ approval }) => approval.approvalId)
|
||||
expect(ids).toHaveLength(100)
|
||||
expect(ids?.[0]).toBe('apr_still_open')
|
||||
expect(ids?.at(-1)).toBe('apr_149')
|
||||
})
|
||||
@@ -124,31 +123,3 @@ it('closes an open approval once its Dispatch stops running, at the time it ende
|
||||
])
|
||||
expect(row.approvals?.[0].approval.expiresAt).toBeUndefined()
|
||||
})
|
||||
|
||||
it('reads a close no one named, after its Dispatch ended, as the worker ending', () => {
|
||||
const { db, deps, run, assign } = fixture()
|
||||
const dispatch = assign('term_worker')
|
||||
db.insertMessage({
|
||||
id: approvalReportId(dispatch.id, 'apr_unnamed', 'closed'),
|
||||
from: 'term_worker',
|
||||
to: `run:${run.id}`,
|
||||
subject: 'apr_unnamed',
|
||||
type: 'status',
|
||||
runId: run.id,
|
||||
payload: JSON.stringify({
|
||||
approval: {
|
||||
v: 1,
|
||||
approvalId: 'apr_unnamed',
|
||||
state: 'answered',
|
||||
worker: { handle: 'term_worker', dispatchId: dispatch.id, taskId: dispatch.task_id },
|
||||
summary: { title: 'Allow Bash?', detail: null, reason: null },
|
||||
allowedActions: [],
|
||||
outcome: { by: 'unknown', decision: null, reason: null, reasonDelivered: false }
|
||||
}
|
||||
})
|
||||
})
|
||||
db.completeDispatch(dispatch.id)
|
||||
|
||||
const [row] = buildCrewSnapshot('term_coord', deps).sections.managing
|
||||
expect(row.approvals?.map(({ approval }) => approval.outcome?.by)).toEqual(['worker-ended'])
|
||||
})
|
||||
|
||||
+2
-62
@@ -43,16 +43,6 @@ const USER_NO: ClaudeToolResult = {
|
||||
isError: true,
|
||||
text: "The user doesn't want to proceed with this tool use. The tool use was rejected."
|
||||
}
|
||||
const AUTO_BLOCK: ClaudeToolResult = {
|
||||
isError: true,
|
||||
text: 'Permission for this command was denied by a built-in Claude Code safety check, not by the user.'
|
||||
}
|
||||
// An allowed command that then fails (probe 2026-11-11, the owner's live case).
|
||||
const FAILED: ClaudeToolResult = {
|
||||
isError: true,
|
||||
text: "Exit code 1\n(eval):14: parse error near `\\n'"
|
||||
}
|
||||
const RAN: ClaudeToolResult = { isError: false, text: '59' }
|
||||
/** What the transcript holds: the hook decision Claude took, then the tool's result. */
|
||||
const record = (
|
||||
result: ClaudeToolResult | null,
|
||||
@@ -147,14 +137,11 @@ function hook(
|
||||
}
|
||||
}
|
||||
|
||||
function postToolUse(
|
||||
toolUseId: string,
|
||||
hookEventName: 'PostToolUse' | 'PostToolUseFailure' = 'PostToolUse'
|
||||
): AgentHookEventPayload {
|
||||
function postToolUse(toolUseId: string): AgentHookEventPayload {
|
||||
return {
|
||||
paneKey: PANE,
|
||||
connectionId: null,
|
||||
hookEventName,
|
||||
hookEventName: 'PostToolUse',
|
||||
toolUseId,
|
||||
payload: { state: 'working', prompt: '', agentType: 'claude' }
|
||||
}
|
||||
@@ -232,23 +219,6 @@ describe('terminal worker approval holds', () => {
|
||||
expect(ctx.closedWith()[0]).toMatchObject({ state: 'answered', by: 'unknown' })
|
||||
})
|
||||
|
||||
it.each([
|
||||
['allowed, and the command succeeds', record(RAN, 'allow')],
|
||||
['allowed, and the command fails', record(FAILED, 'allow')],
|
||||
['allowed, and the command is still running', record(null, 'allow')],
|
||||
['allowed by a Claude that records no hook decision, and the command fails', record(FAILED)]
|
||||
])("takes Orca's allow when %s", async (_, written) => {
|
||||
const ctx = setup()
|
||||
const asked = hook('tool-1', () => {
|
||||
ctx.screen.lines = AFTER
|
||||
ctx.screen.record = written
|
||||
})
|
||||
const approvalId = await opened(ctx, asked)
|
||||
|
||||
expect(await answer(ctx, approvalId, 'allow')).toMatchObject({ ok: true })
|
||||
expect(asked.replies).toEqual([{ behavior: 'allow' }])
|
||||
})
|
||||
|
||||
it("doesn't take Orca's allow when the person's No won the race", async () => {
|
||||
const ctx = setup()
|
||||
const approvalId = await opened(
|
||||
@@ -271,36 +241,6 @@ describe('terminal worker approval holds', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it("names a Yes in the terminal whose command failed as allowed in the worker's terminal", async () => {
|
||||
const ctx = setup()
|
||||
await opened(ctx, hook('tool-1'))
|
||||
ctx.screen.lines = AFTER
|
||||
ctx.holds.observe(postToolUse('tool-1', 'PostToolUseFailure'))
|
||||
|
||||
expect(ctx.closedWith()).toEqual([
|
||||
{
|
||||
state: 'answered',
|
||||
by: 'worker-terminal',
|
||||
decision: 'allow',
|
||||
reason: null,
|
||||
reasonDelivered: false
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it("names Claude's 2:00 auto-block as an expiry", async () => {
|
||||
const ctx = setup()
|
||||
await closedInTerminal(ctx, AUTO_BLOCK)
|
||||
|
||||
expect(ctx.closedWith()[1]).toEqual({
|
||||
state: 'expired',
|
||||
by: 'auto',
|
||||
decision: 'deny',
|
||||
reason: null,
|
||||
reasonDelivered: false
|
||||
})
|
||||
})
|
||||
|
||||
it("tells the coordinator to send the user to the terminal when the hook is gone but the dialog isn't", async () => {
|
||||
const ctx = setup()
|
||||
const asked = hook('tool-1')
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
import { expect, it, vi } from 'vitest'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { OrchestrationDb } from '../../orchestration/db/orchestration-db'
|
||||
import { isOrcaSessionId } from '../../../../shared/orca-session-address'
|
||||
|
||||
const CHAT = 'claude_11111111_1111_4111_8111_111111111111'
|
||||
|
||||
it("reads a chat's approvals on its own Run's changes, never on terminal identity notices", async () => {
|
||||
if (!isOrcaSessionId(CHAT)) {
|
||||
throw new Error('fixture id')
|
||||
}
|
||||
const runtime = new OrcaRuntimeService()
|
||||
const db = new OrchestrationDb(':memory:')
|
||||
runtime.setOrchestrationDb(db)
|
||||
const runs = vi.spyOn(db, 'runsBoundToCoordinator')
|
||||
const stop = runtime.subscribeOrchestrationWorkerApprovals(`orca_session_id:${CHAT}`, () => {})
|
||||
const settle = () => new Promise((resolve) => setImmediate(resolve))
|
||||
const reads = runs.mock.calls.length
|
||||
|
||||
// What every agent status or tab title change sends: terminal identity's default topology notice.
|
||||
for (let i = 0; i < 50; i++) {
|
||||
runtime.crewChanges.notify()
|
||||
await settle()
|
||||
}
|
||||
expect(runs.mock.calls.length - reads).toBe(0)
|
||||
|
||||
db.createRun({
|
||||
objective: 'Coordinate',
|
||||
coordinatorHandle: null,
|
||||
coordinatorPaneKey: null,
|
||||
coordinatorOrcaSessionId: CHAT
|
||||
})
|
||||
await settle()
|
||||
expect(runs.mock.calls.length - reads).toBe(1)
|
||||
stop()
|
||||
})
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, screen } from '@testing-library/react'
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
import { render } from '../../messages/actions/native-chat-tooltip-test-harness'
|
||||
import { NativeChatMessageList } from '../../NativeChatMessageList'
|
||||
import {
|
||||
layout,
|
||||
marker,
|
||||
session,
|
||||
stubLayout,
|
||||
stubResizeObserver
|
||||
} from '../../viewport/virtualization/native-chat-windowing-test-harness'
|
||||
|
||||
// Pacing is not this test's subject.
|
||||
vi.mock('../../markdown/use-native-chat-paced-text', async (importOriginal) =>
|
||||
(await import('../../markdown/native-chat-unpaced-text-fixture')).unpacedTextModule(
|
||||
importOriginal
|
||||
)
|
||||
)
|
||||
|
||||
let restore: (() => void)[] = []
|
||||
beforeEach(() => {
|
||||
restore = [stubLayout({ scrollGeometry: true, offsetChain: true }), stubResizeObserver()]
|
||||
})
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
for (const undo of restore.toReversed()) {
|
||||
undo()
|
||||
}
|
||||
layout.measuredRowHeights = []
|
||||
})
|
||||
|
||||
it('draws a worker approval at its own time, with newer replies after it', () => {
|
||||
// marker(i) is message `marker-i`, at time i + 1.
|
||||
const messages = [0, 1, 2, 3].map(marker)
|
||||
render(
|
||||
<NativeChatMessageList
|
||||
session={session(messages)}
|
||||
isWorking={false}
|
||||
expandSignal={false}
|
||||
timedRows={[
|
||||
{ key: 'open', at: 3.5, node: <p>Allow Bash? (open)</p> },
|
||||
{ key: 'receipt', at: 1.5, node: <p>Allowed by you 3:11 PM</p> }
|
||||
]}
|
||||
/>
|
||||
)
|
||||
|
||||
const order = [
|
||||
'marker-0',
|
||||
'Allowed by you 3:11 PM',
|
||||
'marker-1',
|
||||
'marker-2',
|
||||
'Allow Bash? (open)',
|
||||
'marker-3'
|
||||
].map((text) => screen.getByText(text))
|
||||
for (const [index, element] of order.slice(1).entries()) {
|
||||
expect(order[index].compareDocumentPosition(element)).toBe(Node.DOCUMENT_POSITION_FOLLOWING)
|
||||
}
|
||||
})
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
import type { OrchestrationCrewRow } from '../../../../../shared/orchestration/orchestration-crew'
|
||||
|
||||
const rpc = vi.hoisted(() => ({ call: vi.fn() }))
|
||||
const toast = vi.hoisted(() => ({ success: vi.fn(), info: vi.fn(), error: vi.fn() }))
|
||||
vi.mock('@/runtime/rpc/calls/runtime-rpc-call', () => ({ callRuntimeRpc: rpc.call }))
|
||||
vi.mock('sonner', () => ({ toast }))
|
||||
|
||||
const { RuntimeRpcCallError } = await import('@/runtime/rpc/calls/runtime-rpc-result')
|
||||
const { NativeChatWorkerApprovalStack } = await import('./NativeChatWorkerApprovals')
|
||||
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
const worker: OrchestrationCrewRow = {
|
||||
partyKey: 'w',
|
||||
role: 'worker',
|
||||
label: 'try-claude',
|
||||
agentKind: 'claude',
|
||||
status: 'blocked'
|
||||
}
|
||||
const entry = {
|
||||
approval: {
|
||||
v: 1 as const,
|
||||
approvalId: 'apr_1',
|
||||
state: 'open' as const,
|
||||
worker: { handle: 'term_w', dispatchId: 'ctx_1', taskId: 'task_1' },
|
||||
summary: { title: 'Allow Bash?', detail: 'rg -n x', reason: null },
|
||||
allowedActions: ['allow' as const, 'deny' as const]
|
||||
},
|
||||
at: '2026-11-11T20:11:30.000Z',
|
||||
askedAt: '2026-11-11T20:11:24.000Z',
|
||||
worker
|
||||
}
|
||||
|
||||
const reject = (code: string) =>
|
||||
rpc.call.mockRejectedValueOnce(
|
||||
new RuntimeRpcCallError({
|
||||
id: '1',
|
||||
ok: false,
|
||||
error: { code, message: code },
|
||||
_meta: { runtimeId: 'r' }
|
||||
})
|
||||
)
|
||||
|
||||
function renderStack() {
|
||||
render(<NativeChatWorkerApprovalStack approvals={[entry]} target={{ kind: 'local' }} />)
|
||||
}
|
||||
|
||||
it('waits on the host after a click: both buttons off, the clicked one working, no toast when it lands', async () => {
|
||||
renderStack()
|
||||
let land: (value: unknown) => void = () => {}
|
||||
rpc.call.mockReturnValueOnce(new Promise((resolve) => (land = resolve)))
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Allow' }))
|
||||
expect(screen.getByRole('button', { name: 'Allow' })).toBeDisabled()
|
||||
expect(screen.getByRole('button', { name: 'Deny' })).toBeDisabled()
|
||||
expect(
|
||||
screen.getByRole('button', { name: 'Allow' }).querySelector('.animate-spin')
|
||||
).not.toBeNull()
|
||||
expect(screen.getByRole('button', { name: 'Deny' }).querySelector('.animate-spin')).toBeNull()
|
||||
land({})
|
||||
await waitFor(() => expect(screen.getByRole('button', { name: 'Allow' })).toBeEnabled())
|
||||
expect(toast.success).not.toHaveBeenCalled()
|
||||
expect(toast.info).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('leaves the card to the host list when the answer was not applied', async () => {
|
||||
renderStack()
|
||||
reject('approval_not_open')
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Allow' }))
|
||||
await waitFor(() => expect(toast.info).toHaveBeenCalledTimes(1))
|
||||
// Still open as far as this card knows: answerable again until the host's list says otherwise.
|
||||
expect(screen.getByRole('button', { name: 'Allow' })).toBeEnabled()
|
||||
|
||||
reject('internal_error')
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Deny' }))
|
||||
await waitFor(() => expect(toast.error).toHaveBeenCalledTimes(1))
|
||||
expect(screen.getByRole('button', { name: 'Deny' })).toBeEnabled()
|
||||
})
|
||||
-9
@@ -82,12 +82,3 @@ it('keeps a prompt that closed while shown pinned as its receipt for a moment, t
|
||||
expect(pinned.result.current).toEqual([])
|
||||
expect(receipts.result.current.map((e) => e.approval.approvalId)).toEqual(['apr_old', 'apr_1'])
|
||||
})
|
||||
|
||||
it('keeps a prompt only the worker terminal can answer pinned', async () => {
|
||||
vi.useFakeTimers()
|
||||
const pinned = renderHook(() => feed.useNativeChatPinnedWorkerApprovals('orca_session_id:other'))
|
||||
await act(async () => {})
|
||||
send(approval('apr_t', 'answered', 'terminal-only'))
|
||||
act(() => vi.advanceTimersByTime(60_000))
|
||||
expect(pinned.result.current.map((e) => e.approval.approvalId)).toEqual(['apr_t'])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user