mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
test: remove low-value CLI, browser and E2E checks
This commit is contained in:
@@ -345,7 +345,6 @@
|
||||
"src/cli/handlers/orchestration-lifecycle-json-rejection.test.ts": 555,
|
||||
"src/cli/handlers/orchestration-lifecycle-rejection.test.ts": 781,
|
||||
"src/cli/handlers/orchestration-task-list-brief.test.ts": 494,
|
||||
"src/cli/handlers/orchestration-windows-ask-cli.test.ts": 801,
|
||||
"src/cli/handlers/orchestration-worker-cli.test.ts": 706,
|
||||
"src/cli/handlers/orchestration.test.ts": 543,
|
||||
"src/cli/handlers/orchestration/agent-view.test.ts": 511,
|
||||
@@ -380,7 +379,6 @@
|
||||
"src/cli/index-omitted-host-scope-selectors.test.ts": 6719,
|
||||
"src/cli/index-orchestration.test.ts": 659,
|
||||
"src/cli/index-terminal-commands.test.ts": 466,
|
||||
"src/cli/index-vm-recipe-doctor.test.ts": 459,
|
||||
"src/cli/index-workspace-owner-choice-scaling.test.ts": 10154,
|
||||
"src/cli/index-workspace-owner-choice.test.ts": 1072,
|
||||
"src/cli/index-worktree-create-agent.test.ts": 582,
|
||||
@@ -441,7 +439,6 @@
|
||||
"src/cli/runtime/serve-update-supervisor-gate.test.ts": 73,
|
||||
"src/cli/runtime/status-caller.test.ts": 488,
|
||||
"src/cli/runtime/status.test.ts": 1406,
|
||||
"src/cli/runtime/terminal-prompt-mutation-recovery-plugin-denied.test.ts": 125,
|
||||
"src/cli/runtime/transport-framing.test.ts": 194,
|
||||
"src/cli/runtime/transport.test.ts": 462,
|
||||
"src/cli/runtime/types.test.ts": 62,
|
||||
@@ -4766,7 +4763,6 @@
|
||||
"src/renderer/src/components/browser-pane/host-guest/agent-input-focus-guard.test.ts": 228,
|
||||
"src/renderer/src/components/browser-pane/host-guest/browser-automation-visibility.test.ts": 45,
|
||||
"src/renderer/src/components/browser-pane/host-guest/browser-guest-eviction-veto.test.ts": 1724,
|
||||
"src/renderer/src/components/browser-pane/host-guest/browser-guest-paint-policy.test.ts": 2035,
|
||||
"src/renderer/src/components/browser-pane/host-guest/browser-page-evicted-guest-recovery.test.ts": 1839,
|
||||
"src/renderer/src/components/browser-pane/host-guest/browser-page-guest-recovery.test.ts": 515,
|
||||
"src/renderer/src/components/browser-pane/host-guest/browser-page-registration-ownership.test.ts": 2197,
|
||||
@@ -7102,7 +7098,6 @@
|
||||
"src/shared/agent-cli-install-dir-fallback.test.ts": 130,
|
||||
"src/shared/agent-launch/startup/agent-command-line-intent.test.ts": 95,
|
||||
"src/shared/agent-status/title/agent-detection.test.ts": 188,
|
||||
"src/shared/agent-hook-listener/transport/agent-hook-endpoint-file.test.ts": 58,
|
||||
"src/shared/agent-hook-listener/transport/agent-hook-endpoint-temp-cleanup.test.ts": 55,
|
||||
"src/shared/agent-hook-listener/normalization/agent-hook-listener-claude-elicitation.test.ts": 229,
|
||||
"src/shared/agent-hook-listener/normalization/agent-hook-listener-codex-approval-ownership.test.ts": 258,
|
||||
@@ -8262,7 +8257,6 @@
|
||||
"tests/e2e/git-history-tooltip-wrap.spec.ts": 22900,
|
||||
"tests/e2e/git-no-upstream-polling-churn.spec.ts": 22600,
|
||||
"tests/e2e/github-cli-stall-repro.spec.ts": 18200,
|
||||
"tests/e2e/github-created-issue-start-prefill.spec.ts": 43100,
|
||||
"tests/e2e/github-url-smart-input-transition.spec.ts": 58200,
|
||||
"tests/e2e/golden-agent-tui-launch.spec.ts": 27300,
|
||||
"tests/e2e/golden-core-flows.spec.ts": 91100,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { existsSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { parseArgs, REPEATED_FLAG_SEPARATOR, specPaths } from '../args'
|
||||
import { parseArgs, specPaths } from '../args'
|
||||
import { ACCOUNT_COMMAND_SPECS } from '../specs/account'
|
||||
import { RuntimeClient } from '../runtime-client'
|
||||
import { DATA_ACCOUNT_RUNTIME_CAPABILITY } from '../../shared/account-runtime-capabilities'
|
||||
@@ -61,40 +61,6 @@ describe('managed data account enrollment', () => {
|
||||
expect(existsSync(directory)).toBe(false)
|
||||
})
|
||||
|
||||
it('passes OpenCode login method and answers before the standalone flag', async () => {
|
||||
vi.spyOn(client, 'call')
|
||||
.mockResolvedValueOnce({
|
||||
id: 'test',
|
||||
ok: true,
|
||||
result: { capabilities: [DATA_ACCOUNT_RUNTIME_CAPABILITY] },
|
||||
_meta: { runtimeId: 'test' }
|
||||
})
|
||||
.mockRejectedValueOnce(new Error('capture failed'))
|
||||
const login = vi.fn(async (_command: string, args: string[]) => {
|
||||
expect(args).toEqual([
|
||||
'auth',
|
||||
'login',
|
||||
'github-copilot',
|
||||
'--method',
|
||||
' device ',
|
||||
'--answer',
|
||||
'deploymentType=github.com',
|
||||
'--answer',
|
||||
'note name=a=b',
|
||||
'--standalone'
|
||||
])
|
||||
})
|
||||
const flags = new Map<string, string | boolean>([
|
||||
['integration', 'github-copilot'],
|
||||
['method', ' device '],
|
||||
['answer', ['deploymentType=github.com', 'note name=a=b'].join(REPEATED_FLAG_SEPARATOR)]
|
||||
])
|
||||
await expect(addDataAccount({ ...context, flags }, 'opencode', login)).rejects.toThrow(
|
||||
'capture failed'
|
||||
)
|
||||
expect(login).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it.each([
|
||||
['devin', new Map([['method', 'device']]), 'only supported with --agent opencode'],
|
||||
['opencode', new Map([['method', ' ']]), '--method requires'],
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const callMock = vi.fn()
|
||||
const originalCliCommand = process.env.ORCA_CLI_COMMAND
|
||||
const originalPackagedLauncher = process.env.ORCA_WINDOWS_PACKAGED_CLI_LAUNCHER
|
||||
const originalTerminalHandle = process.env.ORCA_TERMINAL_HANDLE
|
||||
const originalExitCode = process.exitCode
|
||||
|
||||
vi.mock('../format', () => ({ printResult: vi.fn() }))
|
||||
vi.mock('../selectors', () => ({ getTerminalHandle: vi.fn() }))
|
||||
|
||||
import { ORCHESTRATION_HANDLERS } from './orchestration'
|
||||
|
||||
describe('packaged Windows legacy ask protocol', () => {
|
||||
beforeEach(() => {
|
||||
callMock.mockReset()
|
||||
process.env.ORCA_WINDOWS_PACKAGED_CLI_LAUNCHER = '1'
|
||||
process.env.ORCA_TERMINAL_HANDLE = 'term_worker'
|
||||
process.exitCode = undefined
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
process.exitCode = originalExitCode
|
||||
restoreEnv('ORCA_CLI_COMMAND', originalCliCommand)
|
||||
restoreEnv('ORCA_WINDOWS_PACKAGED_CLI_LAUNCHER', originalPackagedLauncher)
|
||||
restoreEnv('ORCA_TERMINAL_HANDLE', originalTerminalHandle)
|
||||
})
|
||||
|
||||
it.each(['orca', 'orca-ide'] as const)(
|
||||
'commits with the %s launcher and exits 75 before resume',
|
||||
async (command) => {
|
||||
process.env.ORCA_CLI_COMMAND = command
|
||||
callMock.mockResolvedValue({
|
||||
result: {
|
||||
answer: null,
|
||||
messageId: 'msg_question',
|
||||
threadId: 'msg_question',
|
||||
timedOut: false,
|
||||
legacyCompatibility: {
|
||||
resumeRequired: true,
|
||||
resumeCommand: `${command} orchestration ask --resume msg_question`
|
||||
}
|
||||
}
|
||||
})
|
||||
const log = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await invokeAsk(new Map([['question', 'Proceed?']]))
|
||||
|
||||
expect(callMock).toHaveBeenCalledWith(
|
||||
'orchestration.ask',
|
||||
expect.objectContaining({
|
||||
question: 'Proceed?',
|
||||
resume: undefined,
|
||||
compatibilityWindowsCommand: command
|
||||
}),
|
||||
expect.any(Object)
|
||||
)
|
||||
expect(log.mock.calls.map(([line]) => line)).toEqual([
|
||||
`Question msg_question committed.\nNext: Resume with: ${command} orchestration ask --resume msg_question`
|
||||
])
|
||||
expect(process.exitCode).toBe(75)
|
||||
}
|
||||
)
|
||||
|
||||
it('resumes the committed question without another exit-75 handoff', async () => {
|
||||
process.env.ORCA_CLI_COMMAND = 'orca'
|
||||
callMock.mockResolvedValue({
|
||||
result: {
|
||||
answer: 'yes',
|
||||
messageId: 'msg_question',
|
||||
threadId: 'msg_question',
|
||||
timedOut: false
|
||||
}
|
||||
})
|
||||
const log = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await invokeAsk(new Map([['resume', 'msg_question']]))
|
||||
|
||||
expect(callMock).toHaveBeenCalledWith(
|
||||
'orchestration.ask',
|
||||
expect.objectContaining({
|
||||
question: undefined,
|
||||
resume: 'msg_question',
|
||||
compatibilityWindowsCommand: 'orca'
|
||||
}),
|
||||
expect.any(Object)
|
||||
)
|
||||
expect(log).toHaveBeenCalledWith('yes')
|
||||
expect(process.exitCode).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
function invokeAsk(flags: Map<string, string | boolean>): Promise<void> {
|
||||
return ORCHESTRATION_HANDLERS['orchestration ask']({
|
||||
flags,
|
||||
client: { call: callMock },
|
||||
cwd: '/tmp/repo',
|
||||
json: false
|
||||
} as never)
|
||||
}
|
||||
|
||||
function restoreEnv(name: string, value: string | undefined): void {
|
||||
if (value === undefined) {
|
||||
delete process.env[name]
|
||||
} else {
|
||||
process.env[name] = value
|
||||
}
|
||||
}
|
||||
@@ -38,36 +38,6 @@ describe('file commands on a server with no app window', () => {
|
||||
vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
})
|
||||
|
||||
it('explains the refusal instead of printing the raw token', async () => {
|
||||
mocks.callMock.mockRejectedValueOnce(headlessRefusal())
|
||||
|
||||
await main(['file', 'open', 'src/App.tsx', '--worktree', 'id:wt-1'], '/tmp/repo')
|
||||
|
||||
const printed = String(vi.mocked(console.error).mock.calls[0]?.[0])
|
||||
expect(printed).toContain('This Orca server has no app window')
|
||||
expect(printed).toContain('Next step: Open the file from the file explorer')
|
||||
expect(printed.split('\n')[0]).not.toBe('renderer_unavailable')
|
||||
expect(process.exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('keeps a stable code and recovery in --json output', async () => {
|
||||
mocks.callMock.mockRejectedValueOnce(headlessRefusal())
|
||||
|
||||
await main(
|
||||
['file', 'diff', 'src/App.tsx', '--worktree', 'id:wt-1', '--focus', '--json'],
|
||||
'/tmp/repo'
|
||||
)
|
||||
|
||||
const output = JSON.parse(String(vi.mocked(console.log).mock.calls[0]?.[0]))
|
||||
expect(output.ok).toBe(false)
|
||||
expect(output.error.code).toBe('renderer_unavailable')
|
||||
expect(output.error.message).toContain('no app window')
|
||||
expect(output.error.data.nextSteps).toEqual([
|
||||
expect.stringContaining('file explorer'),
|
||||
expect.stringContaining('path in your reply')
|
||||
])
|
||||
})
|
||||
|
||||
it('stops open-changed at the first refusal with the same explanation', async () => {
|
||||
mocks.callMock
|
||||
.mockResolvedValueOnce(
|
||||
@@ -94,19 +64,4 @@ describe('file commands on a server with no app window', () => {
|
||||
'This Orca server has no app window'
|
||||
)
|
||||
})
|
||||
|
||||
it('leaves other runtime errors untouched', async () => {
|
||||
mocks.callMock.mockRejectedValueOnce(
|
||||
new RuntimeRpcFailureError({
|
||||
id: 'req_open',
|
||||
ok: false,
|
||||
error: { code: 'runtime_error', message: 'chat_scratch_not_openable' },
|
||||
_meta: { runtimeId: 'runtime-1' }
|
||||
})
|
||||
)
|
||||
|
||||
await main(['file', 'open', 'src/App.tsx', '--worktree', 'id:wt-1'], '/tmp/repo')
|
||||
|
||||
expect(String(vi.mocked(console.error).mock.calls[0]?.[0])).toBe('chat_scratch_not_openable')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
import path from 'node:path'
|
||||
import { chmodSync, mkdtempSync, rmSync, writeFileSync, mkdirSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const {
|
||||
callMock,
|
||||
runtimeClientConstructorMock,
|
||||
serveOrcaAppMock,
|
||||
getDefaultUserDataPathMock,
|
||||
addEnvironmentFromPairingCodeMock,
|
||||
listEnvironmentsMock,
|
||||
spawnMock
|
||||
} = vi.hoisted(() => ({
|
||||
callMock: vi.fn(),
|
||||
runtimeClientConstructorMock: vi.fn(),
|
||||
serveOrcaAppMock: vi.fn(),
|
||||
getDefaultUserDataPathMock: vi.fn(() => '/tmp/orca-user-data'),
|
||||
addEnvironmentFromPairingCodeMock: vi.fn(),
|
||||
listEnvironmentsMock: vi.fn(),
|
||||
spawnMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('./runtime-client', async () => {
|
||||
const { createRuntimeClientModuleMock } = await import('./index-test-harness.js')
|
||||
return createRuntimeClientModuleMock({
|
||||
callMock,
|
||||
runtimeClientConstructorMock,
|
||||
serveOrcaAppMock,
|
||||
getDefaultUserDataPathMock
|
||||
})
|
||||
})
|
||||
|
||||
vi.mock('./runtime/environments', () => ({
|
||||
addEnvironmentFromPairingCode: addEnvironmentFromPairingCodeMock,
|
||||
removeEnvironment: vi.fn(),
|
||||
resolveEnvironment: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../shared/remote-runtime/host-store/runtime-environment-store', () => ({
|
||||
listEnvironments: listEnvironmentsMock
|
||||
}))
|
||||
|
||||
vi.mock('child_process', async () => {
|
||||
const { createChildProcessModuleMock } = await import('./index-test-harness.js')
|
||||
return createChildProcessModuleMock(spawnMock)
|
||||
})
|
||||
|
||||
import { main } from './index'
|
||||
import { useWorktreeAwarenessEnvironment } from './index-test-harness'
|
||||
|
||||
describe('orca cli worktree awareness', () => {
|
||||
useWorktreeAwarenessEnvironment({
|
||||
callMock,
|
||||
serveOrcaAppMock,
|
||||
getDefaultUserDataPathMock,
|
||||
addEnvironmentFromPairingCodeMock,
|
||||
listEnvironmentsMock,
|
||||
spawnMock
|
||||
})
|
||||
|
||||
it('runs vm recipe doctor locally without contacting the app runtime', async () => {
|
||||
const repoPath = mkdtempSync(path.join(tmpdir(), 'orca-vm-doctor-'))
|
||||
try {
|
||||
mkdirSync(path.join(repoPath, 'scripts', 'orca-vm'), { recursive: true })
|
||||
const startScript = path.join(repoPath, 'scripts', 'orca-vm', 'start.sh')
|
||||
const cleanupScript = path.join(repoPath, 'scripts', 'orca-vm', 'cleanup.sh')
|
||||
writeFileSync(startScript, '#!/bin/sh\n')
|
||||
writeFileSync(cleanupScript, '#!/bin/sh\n')
|
||||
chmodSync(startScript, 0o755)
|
||||
chmodSync(cleanupScript, 0o755)
|
||||
writeFileSync(
|
||||
path.join(repoPath, 'orca.yaml'),
|
||||
[
|
||||
'environmentRecipes:',
|
||||
' - id: cloud-sandbox',
|
||||
' name: Cloud Sandbox',
|
||||
' create: ./scripts/orca-vm/start.sh',
|
||||
' destroy: ./scripts/orca-vm/cleanup.sh'
|
||||
].join('\n')
|
||||
)
|
||||
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await main(['vm', 'recipe', 'doctor', 'cloud-sandbox', '--repo-path', repoPath, '--json'])
|
||||
|
||||
const output = JSON.parse(String(logSpy.mock.calls[0][0])) as {
|
||||
ok: boolean
|
||||
checks: { id: string; status: string }[]
|
||||
}
|
||||
if (!output.ok) {
|
||||
throw new Error(JSON.stringify(output))
|
||||
}
|
||||
expect(output.ok).toBe(true)
|
||||
expect(output.checks).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ id: 'orca_yaml.parse', status: 'pass' }),
|
||||
expect.objectContaining({ id: 'recipe.exists', status: 'pass' }),
|
||||
expect.objectContaining({ id: 'recipe.create', status: 'pass' }),
|
||||
expect.objectContaining({ id: 'recipe.destroy', status: 'pass' })
|
||||
])
|
||||
)
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
rmSync(repoPath, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -75,15 +75,4 @@ describe('a structured chat session with no orchestration identity', () => {
|
||||
expect.objectContaining({ terminal: 'structworker_self' })
|
||||
)
|
||||
})
|
||||
|
||||
it('leaves an ordinary shell alone, which has no marker and may still guess', async () => {
|
||||
delete process.env[ORCA_STRUCTURED_SESSION_ENV]
|
||||
callMock.mockResolvedValue({ result: { messages: [], count: 0 } })
|
||||
await invoke('orchestration check')
|
||||
expect(getTerminalHandleMock).toHaveBeenCalled()
|
||||
expect(callMock).toHaveBeenCalledWith(
|
||||
'orchestration.check',
|
||||
expect.objectContaining({ terminal: 'term_sibling' })
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -109,12 +109,4 @@ describe('orca plugin check: editors load as the frame protocol serves them', ()
|
||||
expect(result.issues).toEqual([])
|
||||
expect(result.files).toContain('editor/my script.js')
|
||||
})
|
||||
|
||||
it('lets a dependency reach the 16 MiB the protocol serves, past the 10 MiB entry cap', async () => {
|
||||
const root = await editorWith({
|
||||
'editor/index.html': page('<script type="module" src="./vendor.mjs"></script>'),
|
||||
'editor/vendor.mjs': `export const x = 1\n//${'x'.repeat(11 * 1024 * 1024)}\n`
|
||||
})
|
||||
expect((await check(root)).issues).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@ import { appendFile, mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/pro
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { checkPluginEditors, formatPluginEditorCheck } from './plugin-editor-check'
|
||||
import { checkPluginEditors } from './plugin-editor-check'
|
||||
import { createPluginFromTemplate } from './plugin-create'
|
||||
import { validatePluginTarget } from './plugin-folder-validation'
|
||||
import { checkPluginDevFolder } from '../plugin-dev-watch/plugin-dev-watch-check'
|
||||
@@ -37,14 +37,6 @@ async function editorPlugin(): Promise<string> {
|
||||
}
|
||||
|
||||
describe('orca plugin check: custom editors', () => {
|
||||
it('passes the editor template and follows its script and imports', async () => {
|
||||
const dir = await editorPlugin()
|
||||
const [check] = await checkPluginEditors(dir)
|
||||
expect(check.issues).toEqual([])
|
||||
expect(check.files).toEqual(['editor/index.html', 'editor/main.ts', 'editor/sync.ts'])
|
||||
expect(formatPluginEditorCheck(check)[0]).toMatch(/: ok, 3 file\(s\) load$/)
|
||||
})
|
||||
|
||||
it('fails on a syntax error that validate lets through', async () => {
|
||||
const dir = await editorPlugin()
|
||||
await appendFile(join(dir, 'editor', 'main.ts'), 'this is not valid ts(\n')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
|
||||
import { mkdtemp, rm, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { runProcess } from '@orca/process-host'
|
||||
@@ -90,18 +90,4 @@ describe('orca plugin release-entry', () => {
|
||||
expect(result.entry).toBeUndefined()
|
||||
expect(result.note).toContain('themes/dark.json')
|
||||
})
|
||||
|
||||
it('explains why there is no entry outside Git or before the first commit', async () => {
|
||||
const outside = join(await tempRoot(), 'loose')
|
||||
await createPluginFromTemplate({ dir: outside, template: 'theme', publisher: 'acme' })
|
||||
expect((await releaseFor(outside)).note).toContain('not in a Git repository')
|
||||
|
||||
const repo = await tempRoot()
|
||||
await git(repo, ['init', '--quiet'])
|
||||
await mkdir(join(repo, 'p'))
|
||||
await createPluginFromTemplate({ dir: join(repo, 'p'), template: 'theme', publisher: 'acme' })
|
||||
const uncommitted = await releaseFor(join(repo, 'p'))
|
||||
expect(uncommitted.entry).toBeUndefined()
|
||||
expect(uncommitted.note).toContain('commit the plugin first')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -11,13 +11,6 @@ const pairingCode = encodePairingOffer({
|
||||
})
|
||||
|
||||
describe('exchangeCliPairingCode', () => {
|
||||
it('saves the code unchanged when the host is unreachable or the code is invalid', async () => {
|
||||
const send = vi.fn().mockRejectedValue(new Error('ECONNREFUSED'))
|
||||
await expect(exchangeCliPairingCode(pairingCode, send)).resolves.toBe(pairingCode)
|
||||
await expect(exchangeCliPairingCode('not a code', send)).resolves.toBe('not a code')
|
||||
expect(send).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('refuses to save a code the host rejects, such as one another device already used', async () => {
|
||||
for (const send of [
|
||||
vi
|
||||
|
||||
@@ -3,11 +3,7 @@ import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { encodePairingOffer } from '../../shared/remote-runtime/pairing/pairing'
|
||||
import {
|
||||
addEnvironmentFromPairingCode,
|
||||
removeEnvironment,
|
||||
resolveEnvironmentPairingOffer
|
||||
} from './environments'
|
||||
import { addEnvironmentFromPairingCode, resolveEnvironmentPairingOffer } from './environments'
|
||||
import { getEnvironmentStorePath } from '../../shared/remote-runtime/host-store/runtime-environment-store-records'
|
||||
import { listEnvironments } from '../../shared/remote-runtime/host-store/runtime-environment-store'
|
||||
|
||||
@@ -37,29 +33,6 @@ function pairingCode(endpoint = 'ws://127.0.0.1:6768', keyFill = 1): string {
|
||||
describe('CLI runtime environments', () => {
|
||||
const posixModeIt = process.platform === 'win32' ? it.skip : it
|
||||
|
||||
it('saves, resolves, and removes a paired environment', () => {
|
||||
const userDataPath = temporaryProfile()
|
||||
const saved = addEnvironmentFromPairingCode(userDataPath, {
|
||||
name: 'workstation',
|
||||
pairingCode: pairingCode(),
|
||||
now: 100
|
||||
})
|
||||
|
||||
expect(listEnvironments(userDataPath)).toHaveLength(1)
|
||||
expect(resolveEnvironmentPairingOffer(userDataPath, 'workstation')).toMatchObject({
|
||||
endpoint: 'ws://127.0.0.1:6768',
|
||||
deviceToken: 'device-token'
|
||||
})
|
||||
expect(resolveEnvironmentPairingOffer(userDataPath, saved.id)).toMatchObject({
|
||||
endpoint: 'ws://127.0.0.1:6768'
|
||||
})
|
||||
expect(statSync(getEnvironmentStorePath(userDataPath)).isFile()).toBe(true)
|
||||
|
||||
const removed = removeEnvironment(userDataPath, 'workstation')
|
||||
expect(removed.id).toBe(saved.id)
|
||||
expect(listEnvironments(userDataPath)).toEqual([])
|
||||
})
|
||||
|
||||
posixModeIt('stores paired environments with owner-only POSIX permissions', () => {
|
||||
const userDataPath = temporaryProfile()
|
||||
|
||||
|
||||
@@ -1,77 +1,7 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
buildOrchestrationRecoveryCommand,
|
||||
resolveOrchestrationCliExecutable
|
||||
} from './orchestration-recovery-command'
|
||||
import { buildOrchestrationRecoveryCommand } from './orchestration-recovery-command'
|
||||
|
||||
describe('orchestration recovery command identity', () => {
|
||||
it.each([
|
||||
['configured dev', { ORCA_CLI_COMMAND: 'orca-dev' }, 'darwin', 'orca-dev'],
|
||||
['configured WSL', { ORCA_CLI_COMMAND: 'orca-ide' }, 'linux', 'orca-ide'],
|
||||
['dev checkout', { ORCA_DEV_REPO_ROOT: '/repo' }, 'darwin', 'orca-dev'],
|
||||
['packaged Linux', {}, 'linux', 'orca-ide'],
|
||||
['local macOS', {}, 'darwin', 'orca'],
|
||||
['local Windows', {}, 'win32', 'orca']
|
||||
] as const)('resolves the %s CLI identity', (_name, env, platform, expected) => {
|
||||
expect(resolveOrchestrationCliExecutable(env, platform)).toBe(expected)
|
||||
})
|
||||
|
||||
it('reconstructs the keyed worker-start command from its RPC params', () => {
|
||||
expect(
|
||||
buildOrchestrationRecoveryCommand(
|
||||
'orchestration.workerStart',
|
||||
{
|
||||
task: 'task_1',
|
||||
on: 'windows',
|
||||
worktree: 'new-top-level',
|
||||
timeoutMs: 90_000,
|
||||
devMode: false
|
||||
},
|
||||
'orca'
|
||||
)
|
||||
).toEqual([
|
||||
'orca',
|
||||
'orchestration',
|
||||
'worker-start',
|
||||
'--task',
|
||||
'task_1',
|
||||
'--on',
|
||||
'windows',
|
||||
'--worktree',
|
||||
'new-top-level',
|
||||
'--timeout-ms',
|
||||
'90000'
|
||||
])
|
||||
})
|
||||
|
||||
it('preserves the selected executable and raw command arguments', () => {
|
||||
expect(
|
||||
buildOrchestrationRecoveryCommand(
|
||||
'orchestration.workerStart',
|
||||
{ task: 'task_1' },
|
||||
'orca-dev',
|
||||
[
|
||||
'orchestration',
|
||||
'worker-start',
|
||||
'--task',
|
||||
'task_1',
|
||||
'--comment',
|
||||
'literal $(do-not-run) "quoted"',
|
||||
'--json'
|
||||
]
|
||||
)
|
||||
).toEqual([
|
||||
'orca-dev',
|
||||
'orchestration',
|
||||
'worker-start',
|
||||
'--task',
|
||||
'task_1',
|
||||
'--comment',
|
||||
'literal $(do-not-run) "quoted"',
|
||||
'--json'
|
||||
])
|
||||
})
|
||||
|
||||
it.each([
|
||||
['split', ['orchestration', 'send', '--pairing-code', 'secret', '--subject', 'status']],
|
||||
['equals', ['orchestration', 'send', '--pairing-code=secret', '--subject', 'status']],
|
||||
@@ -89,28 +19,6 @@ describe('orchestration recovery command identity', () => {
|
||||
).toBeUndefined()
|
||||
})
|
||||
|
||||
it('supports the explicit executable-first form', () => {
|
||||
expect(
|
||||
buildOrchestrationRecoveryCommand('orca-ide', 'orchestration.workerStop', {
|
||||
dispatch: 'dispatch_1'
|
||||
})
|
||||
).toEqual(['orca-ide', 'orchestration', 'worker-stop', '--dispatch', 'dispatch_1'])
|
||||
})
|
||||
|
||||
it('reconstructs worker-keep-open when raw argv is unavailable', () => {
|
||||
expect(
|
||||
buildOrchestrationRecoveryCommand('orchestration.workerRetain', {
|
||||
dispatch: 'dispatch_1'
|
||||
})
|
||||
).toEqual([
|
||||
resolveOrchestrationCliExecutable(),
|
||||
'orchestration',
|
||||
'worker-keep-open',
|
||||
'--dispatch',
|
||||
'dispatch_1'
|
||||
])
|
||||
})
|
||||
|
||||
it('does not fabricate identity for unsupported mutations or malformed params', () => {
|
||||
expect(buildOrchestrationRecoveryCommand('orchestration.send', {})).toBeUndefined()
|
||||
expect(buildOrchestrationRecoveryCommand('orchestration.workerStart', null)).toBeUndefined()
|
||||
|
||||
@@ -3,7 +3,6 @@ import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { readServeInstallEvidence } from './serve-install-hold'
|
||||
import { isShipItRunningForBundle } from '../../shared/shipit-process-listing'
|
||||
|
||||
describe('readServeInstallEvidence', () => {
|
||||
let root: string
|
||||
@@ -60,11 +59,4 @@ describe('readServeInstallEvidence', () => {
|
||||
})
|
||||
).resolves.toEqual({ kind: 'clear' })
|
||||
})
|
||||
|
||||
it('matches only the ShipIt binary path', () => {
|
||||
expect(isShipItRunningForBundle(` ${shipIt('/A.app')}`, '/A.app')).toBe(true)
|
||||
expect(
|
||||
isShipItRunningForBundle('/A.app/Contents/Frameworks/Squirrel.framework/Squirrel', '/A.app')
|
||||
).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -5,8 +5,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
createPairingRedactor,
|
||||
PAIRING_HIDDEN_LINE,
|
||||
redactingSpawn,
|
||||
shouldRedactSupervisedStdout
|
||||
redactingSpawn
|
||||
} from './serve-pairing-redaction'
|
||||
|
||||
const READY = [
|
||||
@@ -49,12 +48,6 @@ describe('supervised pairing redaction', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('redacts only supervised output that is not a terminal', () => {
|
||||
expect(shouldRedactSupervisedStdout(true, false)).toBe(true)
|
||||
expect(shouldRedactSupervisedStdout(true, true)).toBe(false)
|
||||
expect(shouldRedactSupervisedStdout(false, false)).toBe(false)
|
||||
})
|
||||
|
||||
it('pipes only stdout through the redactor and keeps the ipc slot', async () => {
|
||||
const stdout = new PassThrough()
|
||||
const child = new ChildProcess()
|
||||
|
||||
@@ -21,23 +21,6 @@ function exit(overrides: Partial<ServeChildExit> = {}): ServeChildExit {
|
||||
}
|
||||
|
||||
describe('decideAfterServeChildExit', () => {
|
||||
it('passes a normal exit code through, and explains an unforwarded signal', () => {
|
||||
const base = { expectedHandoff: null, handoff: null, hasHandoffPath: true }
|
||||
expect(decideAfterServeChildExit({ ...base, exit: exit({ code: 3 }) })).toEqual({
|
||||
kind: 'exit',
|
||||
code: 3
|
||||
})
|
||||
expect(
|
||||
decideAfterServeChildExit({
|
||||
...base,
|
||||
exit: exit({ code: null, signal: 'SIGTERM', signalWasForwarded: true })
|
||||
})
|
||||
).toEqual({ kind: 'exit', code: 0 })
|
||||
expect(
|
||||
decideAfterServeChildExit({ ...base, exit: exit({ code: null, signal: 'SIGABRT' }) })
|
||||
).toEqual({ kind: 'signal-exit', signal: 'SIGABRT' })
|
||||
})
|
||||
|
||||
it('waits for the new bundle only when this very child requested the install', () => {
|
||||
expect(
|
||||
decideAfterServeChildExit({
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { attachDurableMutationRecovery } from './terminal-prompt-mutation-recovery'
|
||||
import { RuntimeClientError } from './types'
|
||||
|
||||
describe('a plugin hook denial in the CLI', () => {
|
||||
it('gets no retry advice in the CLI', () => {
|
||||
const denied = new RuntimeClientError(
|
||||
'denied_by_plugin',
|
||||
'terminal.send denied by plugin a.b: x'
|
||||
)
|
||||
expect(
|
||||
attachDurableMutationRecovery(denied, 'req-1', ['terminal', 'send'], 'terminal.send')
|
||||
).toBe(denied)
|
||||
const other = attachDurableMutationRecovery(
|
||||
new RuntimeClientError('runtime_error', 'boom'),
|
||||
'req-1',
|
||||
['terminal', 'send'],
|
||||
'terminal.send'
|
||||
)
|
||||
expect(String(other)).toMatch(/--retry-request req-1/)
|
||||
})
|
||||
})
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { browserPageNeedsPaintRetention } from './browser-guest-paint-retention'
|
||||
import { hydrateBrowserDrivers } from '../../../lib/pane-manager/browser-mobile-driver-state'
|
||||
import { hydrateBrowserRemoteViewerPages } from '../../../lib/pane-manager/browser-remote-viewer-state'
|
||||
import {
|
||||
acquireBrowserAutomationVisibility,
|
||||
releaseBrowserAutomationVisibility
|
||||
} from './browser-automation-visibility'
|
||||
|
||||
// The imperative twin, for retention decisions taken outside a render (the eviction budget).
|
||||
describe('browserPageNeedsPaintRetention', () => {
|
||||
afterEach(() => {
|
||||
hydrateBrowserDrivers([])
|
||||
hydrateBrowserRemoteViewerPages([])
|
||||
})
|
||||
|
||||
it('answers for each term on its own', () => {
|
||||
expect(browserPageNeedsPaintRetention('page-a')).toBe(false)
|
||||
|
||||
hydrateBrowserRemoteViewerPages(['page-a'])
|
||||
expect(browserPageNeedsPaintRetention('page-a')).toBe(true)
|
||||
hydrateBrowserRemoteViewerPages([])
|
||||
|
||||
hydrateBrowserDrivers([
|
||||
{ browserPageId: 'page-a', driver: { kind: 'mobile', clientId: 'phone-1' } }
|
||||
])
|
||||
expect(browserPageNeedsPaintRetention('page-a')).toBe(true)
|
||||
hydrateBrowserDrivers([])
|
||||
|
||||
const token = acquireBrowserAutomationVisibility('page-a')
|
||||
expect(browserPageNeedsPaintRetention('page-a')).toBe(true)
|
||||
releaseBrowserAutomationVisibility(token)
|
||||
expect(browserPageNeedsPaintRetention('page-a')).toBe(false)
|
||||
})
|
||||
|
||||
it('stays scoped to the page asked about', () => {
|
||||
hydrateBrowserRemoteViewerPages(['page-a'])
|
||||
expect(browserPageNeedsPaintRetention('page-b')).toBe(false)
|
||||
})
|
||||
})
|
||||
-67
@@ -62,36 +62,6 @@ afterEach(() => {
|
||||
})
|
||||
|
||||
describe('browser page guest recovery', () => {
|
||||
it('reloads a lost renderer in place and cancels the failure surface after recovery', () => {
|
||||
vi.useFakeTimers()
|
||||
const state = createRecovery()
|
||||
|
||||
state.recovery.recoverRenderer()
|
||||
|
||||
expect(state.reload).toHaveBeenCalledOnce()
|
||||
expect(state.pending()).toBe(true)
|
||||
|
||||
state.recovery.finish()
|
||||
vi.advanceTimersByTime(BROWSER_GUEST_RECOVERY_TIMEOUT_MS)
|
||||
|
||||
expect(state.pending()).toBe(false)
|
||||
expect(state.onRecoveryFailed).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('recreates a guest when in-place reload is unavailable', async () => {
|
||||
const state = createRecovery({
|
||||
reload: () => {
|
||||
throw new Error('guest destroyed')
|
||||
}
|
||||
})
|
||||
|
||||
state.recovery.recoverRenderer()
|
||||
await vi.waitFor(() => expect(state.onReplacementReady).toHaveBeenCalledOnce())
|
||||
|
||||
expect(state.replaceGuest).toHaveBeenCalledOnce()
|
||||
expect(state.pending()).toBe(true)
|
||||
})
|
||||
|
||||
it('surfaces guest replacement rejection without marking it ready', async () => {
|
||||
const replacementError = new Error('replacement failed')
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
||||
@@ -139,32 +109,6 @@ describe('browser page guest recovery', () => {
|
||||
expect(state.onReplacementReady).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('recreates an active guest missing from the authoritative registry after resume', async () => {
|
||||
const state = createRecovery({ registered: false })
|
||||
|
||||
state.recovery.validateAfterResume()
|
||||
await vi.waitFor(() => expect(state.onReplacementReady).toHaveBeenCalledOnce())
|
||||
|
||||
expect(state.validateRegistration).toHaveBeenCalledOnce()
|
||||
expect(state.replaceGuest).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('waits for an attaching guest instead of replacing it as missing', async () => {
|
||||
vi.useFakeTimers()
|
||||
const state = createRecovery()
|
||||
state.validateRegistration.mockResolvedValueOnce(null).mockResolvedValueOnce(true)
|
||||
|
||||
state.recovery.validateAfterResume()
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
|
||||
expect(state.replaceGuest).not.toHaveBeenCalled()
|
||||
await vi.advanceTimersByTimeAsync(BROWSER_GUEST_VALIDATION_RETRY_DELAY_MS)
|
||||
|
||||
expect(state.validateRegistration).toHaveBeenCalledTimes(2)
|
||||
expect(state.onRecoverySucceeded).toHaveBeenCalledOnce()
|
||||
expect(state.replaceGuest).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('surfaces an attaching guest that never becomes identifiable', async () => {
|
||||
vi.useFakeTimers()
|
||||
const state = createRecovery()
|
||||
@@ -251,17 +195,6 @@ describe('browser page guest recovery', () => {
|
||||
expect(state.onRecoveryFailed).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('surfaces an explicit recovery failure instead of leaving a permanent blank page', () => {
|
||||
vi.useFakeTimers()
|
||||
const state = createRecovery()
|
||||
|
||||
state.recovery.recoverRenderer()
|
||||
vi.advanceTimersByTime(BROWSER_GUEST_RECOVERY_TIMEOUT_MS)
|
||||
|
||||
expect(state.pending()).toBe(false)
|
||||
expect(state.onRecoveryFailed).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('keeps the original recovery deadline across repeated renderer loss events', () => {
|
||||
vi.useFakeTimers()
|
||||
const state = createRecovery()
|
||||
|
||||
@@ -190,34 +190,6 @@ describeOnWindows('resolveWindowsCmdShim', () => {
|
||||
expect(resolveWindowsCmdShim(shim, env)?.prefixArgs).toEqual([join(dir, 'ci2.js')])
|
||||
})
|
||||
|
||||
it('walks PATH once per shim directory, not once per spawn', () => {
|
||||
// Adding an earlier interpreter after first resolution proves cached PATH walks stay cached; without the cache this returns early.
|
||||
const early = mkdtempSync(join(tmpdir(), 'orca-shim-path-early-'))
|
||||
const late = mkdtempSync(join(tmpdir(), 'orca-shim-path-late-'))
|
||||
const shimDir = mkdtempSync(join(tmpdir(), 'orca-shim-path-'))
|
||||
try {
|
||||
writeFileSync(join(late, 'node.exe'), '')
|
||||
writeFileSync(join(shimDir, 'cli.js'), '')
|
||||
const shim = join(shimDir, 'walk.cmd')
|
||||
writeFileSync(shim, npmProgNodeShim('cli.js'))
|
||||
const pathEnv = { ...env, Path: undefined, PATH: `${early};${late}` }
|
||||
|
||||
expect(resolveWindowsCmdShim(shim, pathEnv)?.program).toBe(join(late, 'node.exe'))
|
||||
|
||||
writeFileSync(join(early, 'node.exe'), '')
|
||||
expect(resolveWindowsCmdShim(shim, pathEnv)?.program).toBe(join(late, 'node.exe'))
|
||||
|
||||
// A PATH edit must miss: caching the walk must not outlive its input.
|
||||
expect(resolveWindowsCmdShim(shim, { ...pathEnv, PATH: `${early};${late};` })?.program).toBe(
|
||||
join(early, 'node.exe')
|
||||
)
|
||||
} finally {
|
||||
removeTreeSync(early)
|
||||
removeTreeSync(late)
|
||||
removeTreeSync(shimDir)
|
||||
}
|
||||
})
|
||||
|
||||
it('gives up when cmd would resolve `node` to a non-.exe PATHEXT spelling', () => {
|
||||
// cmd stops at the first PATHEXT match, including .COM before .EXE; skipping it would launch the wrong binary.
|
||||
const first = mkdtempSync(join(tmpdir(), 'orca-shim-ext-first-'))
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { getEventListeners } from 'node:events'
|
||||
import { expect, it, vi } from 'vitest'
|
||||
import { expect, it } from 'vitest'
|
||||
import { waitForPromiseWithSignal } from './abort-signal-reason'
|
||||
import { sharedPromiseSettlementWaiters } from './promise-settlement-waiters'
|
||||
|
||||
it('observes work that rejects after its caller has already canceled', async () => {
|
||||
const controller = new AbortController()
|
||||
@@ -15,29 +13,6 @@ it('observes work that rejects after its caller has already canceled', async ()
|
||||
await new Promise<void>((resolve) => setImmediate(resolve))
|
||||
})
|
||||
|
||||
it('detaches cancelled callers from shared stalled work while another caller waits', async () => {
|
||||
let finish = (_value: number): void => {}
|
||||
const work = new Promise<number>((resolve) => {
|
||||
finish = resolve
|
||||
})
|
||||
const observed = vi.spyOn(work, 'then')
|
||||
const anchorController = new AbortController()
|
||||
const anchor = waitForPromiseWithSignal(work, anchorController.signal)
|
||||
for (let index = 0; index < 100; index += 1) {
|
||||
const controller = new AbortController()
|
||||
const cancelled = waitForPromiseWithSignal(work, controller.signal)
|
||||
controller.abort(new Error('cancelled'))
|
||||
await expect(cancelled).rejects.toThrow('cancelled')
|
||||
expect(getEventListeners(controller.signal, 'abort')).toHaveLength(0)
|
||||
}
|
||||
expect(observed).toHaveBeenCalledOnce()
|
||||
expect(sharedPromiseSettlementWaiters(work).waiterCount).toBe(1)
|
||||
finish(42)
|
||||
await expect(anchor).resolves.toBe(42)
|
||||
expect(sharedPromiseSettlementWaiters(work).waiterCount).toBe(0)
|
||||
expect(getEventListeners(anchorController.signal, 'abort')).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('allows synchronous cancellation before a cached settlement is delivered', async () => {
|
||||
const work = Promise.resolve(42)
|
||||
await expect(waitForPromiseWithSignal(work, new AbortController().signal)).resolves.toBe(42)
|
||||
|
||||
@@ -99,28 +99,6 @@ describe('agent CLI install-dir fallback', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// Match packaged PATH seeding and guest prelude order so all resolvers select the same binary.
|
||||
it('ranks system install dirs in the same order as the PATH seed', () => {
|
||||
const home = '/home/tester'
|
||||
const dirs = [
|
||||
'/usr/local/bin',
|
||||
'/snap/bin',
|
||||
'/home/linuxbrew/.linuxbrew/bin',
|
||||
'/nix/var/nix/profiles/default/bin',
|
||||
join(home, '.nix-profile', 'bin'),
|
||||
join(home, '.opencode', 'bin'),
|
||||
join(home, '.vite-plus', 'bin'),
|
||||
join(home, '.grok', 'bin')
|
||||
]
|
||||
stage(...dirs.map((dir) => join(dir, 'opencode')))
|
||||
for (const expected of dirs) {
|
||||
expect(resolveAll(['opencode'], { platform: 'linux', homePath: home })).toEqual({
|
||||
opencode: join(expected, 'opencode')
|
||||
})
|
||||
fsFixture.executables.delete(join(expected, 'opencode'))
|
||||
}
|
||||
})
|
||||
|
||||
// Both resolver entrypoints must prefer version-manager binaries over same-named system installs.
|
||||
describe.each([
|
||||
{ platform: 'darwin' as const, home: '/Users/tester', systemDir: '/opt/homebrew/bin' },
|
||||
|
||||
@@ -42,21 +42,6 @@ describe('scanFileRegionsBackward', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('stops at the first defined result without reading the rest of the file', () => {
|
||||
const file = writeFixture(`${Array.from({ length: 200 }, (_, i) => `line-${i}`).join('\n')}\n`)
|
||||
let regions = 0
|
||||
const found = scanFileRegionsBackward(
|
||||
file,
|
||||
{ chunkBytes: 32, maxScanBytes: 1024 * 1024 },
|
||||
() => {
|
||||
regions += 1
|
||||
return 'first'
|
||||
}
|
||||
)
|
||||
expect(found).toBe('first')
|
||||
expect(regions).toBe(1)
|
||||
})
|
||||
|
||||
it('reports the byte offset each region starts at', () => {
|
||||
const file = writeFixture('😀alpha\nbravo\ncharlie\n')
|
||||
const offsets: { text: string; regionPosition: number }[] = []
|
||||
|
||||
@@ -61,36 +61,7 @@ it('reads the same bounded first-record prefix with N and 10N later records and
|
||||
}
|
||||
})
|
||||
|
||||
function expectedLines(text: string): string[] {
|
||||
return text
|
||||
.split('\n')
|
||||
.toReversed()
|
||||
.map((line) => line.trim())
|
||||
.filter((line) => line.length > 0)
|
||||
}
|
||||
|
||||
describe('backward transcript line extraction', () => {
|
||||
it('preserves line order and early return across generated delimiters', () => {
|
||||
let seed = 29
|
||||
const fragments = ['a', '\n', '\r\n', ' ', '\t', '😀', '\u2028', '\0']
|
||||
for (let sample = 0; sample < 1000; sample++) {
|
||||
let text = ''
|
||||
for (let i = 0; i < sample % 100; i++) {
|
||||
seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0
|
||||
text += fragments[seed % fragments.length]
|
||||
}
|
||||
const lines = expectedLines(text)
|
||||
const stop = sample % (lines.length + 1)
|
||||
const seen: string[] = []
|
||||
const result = findLastExtractedTranscriptLineText(text, (line) => {
|
||||
seen.push(line)
|
||||
return seen.length === stop + 1 ? line : undefined
|
||||
})
|
||||
expect(seen).toEqual(lines.slice(0, stop + 1))
|
||||
expect(result).toBe(lines[stop])
|
||||
}
|
||||
})
|
||||
|
||||
it('returns the newest assistant message behind a long tool line', () => {
|
||||
const message = JSON.stringify({ role: 'assistant', content: 'latest 😀' })
|
||||
const tool = JSON.stringify({ role: 'tool', content: 'x'.repeat(256 * 1024) })
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import { mkdtempSync, readFileSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { parseAgentHookEndpointFile } from './agent-hook-endpoint-file'
|
||||
import { getEndpointFileName, writeEndpointFile } from './endpoint-publication'
|
||||
const ENDPOINT = { port: '12345', token: 'token-123', env: 'production', version: '1' }
|
||||
|
||||
describe('agent hook endpoint files', () => {
|
||||
it('parses the endpoint bytes published by the platform writer', () => {
|
||||
const directory = mkdtempSync(join(tmpdir(), 'orca-hook-endpoint-parser-'))
|
||||
try {
|
||||
const path = join(directory, getEndpointFileName())
|
||||
expect(
|
||||
writeEndpointFile(directory, path, {
|
||||
port: 12345,
|
||||
token: 'token-123',
|
||||
env: 'production',
|
||||
version: '1'
|
||||
})
|
||||
).toBe(true)
|
||||
expect(parseAgentHookEndpointFile(readFileSync(path, 'utf8'))).toEqual(ENDPOINT)
|
||||
} finally {
|
||||
rmSync(directory, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,206 +0,0 @@
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { chmodSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import { test as base, expect } from './helpers/orca-app'
|
||||
import { waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
import { getTerminalContent } from './helpers/terminal'
|
||||
|
||||
const ISSUE_NUMBER = 6613
|
||||
const ISSUE_TITLE = 'Start a newly created issue without losing its context'
|
||||
const ISSUE_URL = `https://github.com/acme/repo/issues/${ISSUE_NUMBER}`
|
||||
const fakeCliDir = mkdtempSync(path.join(os.tmpdir(), 'orca-e2e-created-issue-prefill-'))
|
||||
|
||||
const fakeGhSource = `
|
||||
const args = process.argv.slice(2)
|
||||
const joined = args.join(' ')
|
||||
const issue = {
|
||||
number: ${ISSUE_NUMBER},
|
||||
title: ${JSON.stringify(ISSUE_TITLE)},
|
||||
state: 'open',
|
||||
html_url: ${JSON.stringify(ISSUE_URL)},
|
||||
labels: [],
|
||||
assignees: [],
|
||||
user: { login: 'e2e' },
|
||||
updated_at: '2026-07-22T12:00:00.000Z'
|
||||
}
|
||||
|
||||
if (args[0] === 'auth' && args[1] === 'status') {
|
||||
console.error('github.com\\n ✓ Logged in to github.com account e2e (GITHUB_TOKEN)')
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'api' && args[1] === 'user') {
|
||||
console.log(JSON.stringify({ login: 'e2e' }))
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'api' && args.includes('rate_limit')) {
|
||||
console.log(JSON.stringify({ resources: { core: { limit: 5000, remaining: 5000, reset: 0 }, graphql: { limit: 5000, remaining: 5000, reset: 0 }, search: { limit: 30, remaining: 30, reset: 0 } } }))
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'api' && args.includes('-X') && args.includes('POST') && joined.includes('repos/acme/repo/issues')) {
|
||||
console.log(JSON.stringify(issue))
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'api' && joined.includes('/labels')) {
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'api' && joined.includes('/assignees')) {
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'api' && joined.includes('repos/acme/repo/issues/${ISSUE_NUMBER}')) {
|
||||
console.log(JSON.stringify(issue))
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'api' && joined.includes('search/issues')) {
|
||||
console.log(JSON.stringify({ total_count: 0, incomplete_results: false, items: [] }))
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'issue' && args[1] === 'list') {
|
||||
console.log('[]')
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'pr' && args[1] === 'list') {
|
||||
console.log('[]')
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'api' && args[1] === 'graphql') {
|
||||
console.log(JSON.stringify({ data: { search: { issueCount: 0, pageInfo: { hasNextPage: false, endCursor: null }, nodes: [] } } }))
|
||||
process.exit(0)
|
||||
}
|
||||
console.error('fake gh: unhandled ' + joined)
|
||||
process.exit(1)
|
||||
`
|
||||
|
||||
const fakeClaudeSource = `
|
||||
const args = process.argv.slice(2)
|
||||
process.stdout.write('E2E_CLAUDE_ARGV ' + JSON.stringify(args) + '\\n')
|
||||
setInterval(() => {}, 60_000)
|
||||
`
|
||||
|
||||
function installFakeCli(name: 'gh' | 'claude', source: string): void {
|
||||
if (process.platform === 'win32') {
|
||||
writeFileSync(path.join(fakeCliDir, `fake-${name}.js`), source)
|
||||
writeFileSync(
|
||||
path.join(fakeCliDir, `${name}.cmd`),
|
||||
`@echo off\r\nnode "%~dp0\\fake-${name}.js" %*\r\n`
|
||||
)
|
||||
return
|
||||
}
|
||||
const executable = path.join(fakeCliDir, name)
|
||||
writeFileSync(executable, `#!/usr/bin/env node\n${source}`)
|
||||
chmodSync(executable, 0o755)
|
||||
}
|
||||
|
||||
installFakeCli('gh', fakeGhSource)
|
||||
installFakeCli('claude', fakeClaudeSource)
|
||||
|
||||
const test = base.extend({
|
||||
launchEnv: {
|
||||
PATH: `${fakeCliDir}${path.delimiter}${process.env.PATH ?? ''}`
|
||||
}
|
||||
})
|
||||
|
||||
test.afterAll(() => {
|
||||
rmSync(fakeCliDir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
function configureGitHubRemote(repoPath: string): void {
|
||||
try {
|
||||
execFileSync('git', ['remote', 'remove', 'origin'], { cwd: repoPath, stdio: 'ignore' })
|
||||
} catch {
|
||||
// The disposable E2E repo does not have an origin on its first run.
|
||||
}
|
||||
execFileSync('git', ['remote', 'add', 'origin', 'https://github.com/acme/repo.git'], {
|
||||
cwd: repoPath,
|
||||
stdio: 'pipe'
|
||||
})
|
||||
}
|
||||
|
||||
// Add origin before repos.add caches no-remote for five minutes, which would disable GitHub issue creation.
|
||||
test.beforeAll(({ testRepoPath }) => {
|
||||
configureGitHubRemote(testRepoPath)
|
||||
})
|
||||
|
||||
test('starting a just-created GitHub issue launches Claude with its URL prefilled', async ({
|
||||
orcaPage,
|
||||
electronApp
|
||||
}) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await waitForActiveWorktree(orcaPage)
|
||||
// Why: the gh preflight merges the login-shell PATH ahead of launchEnv, so the fake gh can lose to a real one.
|
||||
await electronApp.evaluate(
|
||||
({ ipcMain }, created) => {
|
||||
ipcMain.removeHandler('gh:createIssue')
|
||||
ipcMain.handle('gh:createIssue', () => ({ ok: true, ...created }))
|
||||
},
|
||||
{ number: ISSUE_NUMBER, url: ISSUE_URL }
|
||||
)
|
||||
|
||||
await orcaPage.evaluate(async () => {
|
||||
const store = window.__store
|
||||
if (!store) {
|
||||
throw new Error('window.__store is not available')
|
||||
}
|
||||
const state = store.getState()
|
||||
const preparedWorkspace = state
|
||||
.allWorktrees()
|
||||
.find((worktree) => worktree.branch?.endsWith('e2e-secondary'))
|
||||
if (!preparedWorkspace) {
|
||||
throw new Error('Seeded secondary E2E worktree is not available')
|
||||
}
|
||||
// Why: this regression owns renderer-to-PTY command propagation, while the shared fixture already covers Git worktree creation.
|
||||
store.setState({
|
||||
createWorktree: async () => ({ worktree: preparedWorkspace })
|
||||
})
|
||||
await state.updateSettings({
|
||||
defaultTuiAgent: 'claude',
|
||||
disabledTuiAgents: [],
|
||||
...(navigator.userAgent.includes('Windows') ? { terminalWindowsShell: 'git-bash' } : {})
|
||||
})
|
||||
store.getState().openTaskPage({ taskSource: 'github' })
|
||||
})
|
||||
|
||||
const newIssueButton = orcaPage.getByRole('button', { name: 'New GitHub issue' })
|
||||
await expect(newIssueButton).toBeEnabled({ timeout: 15_000 })
|
||||
await newIssueButton.click()
|
||||
|
||||
const createDialog = orcaPage.getByRole('dialog', { name: 'New GitHub issue' })
|
||||
await expect(createDialog).toBeVisible()
|
||||
await createDialog.getByPlaceholder('Short summary').fill(ISSUE_TITLE)
|
||||
await createDialog.getByRole('button', { name: 'Create issue' }).click()
|
||||
|
||||
await expect(createDialog).toBeHidden({ timeout: 10_000 })
|
||||
await expect(orcaPage.getByRole('heading', { name: ISSUE_TITLE })).toBeVisible({
|
||||
timeout: 10_000
|
||||
})
|
||||
|
||||
await orcaPage.getByRole('button', { name: 'Start workspace from issue' }).click()
|
||||
|
||||
// Issue start opens the quick-create composer, which must carry its URL into the submitted agent command.
|
||||
const composer = orcaPage.getByRole('dialog', { name: /Create (workspace|worktree)/i })
|
||||
await expect(composer).toBeVisible({ timeout: 15_000 })
|
||||
const createWorkspaceButton = composer.getByRole('button', {
|
||||
name: /Create (workspace|worktree)/i
|
||||
})
|
||||
await expect(createWorkspaceButton).toBeEnabled({ timeout: 15_000 })
|
||||
await createWorkspaceButton.click()
|
||||
await expect(composer).toBeHidden({ timeout: 20_000 })
|
||||
|
||||
let terminalText = ''
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
terminalText = await getTerminalContent(orcaPage, 12_000)
|
||||
return terminalText
|
||||
},
|
||||
{
|
||||
timeout: 30_000,
|
||||
message: 'Claude prefill command did not reach the active terminal buffer'
|
||||
}
|
||||
)
|
||||
.toContain('--prefill')
|
||||
expect(terminalText).toContain('--dangerously-skip-permissions')
|
||||
expect(terminalText).toContain('--prefill')
|
||||
expect(terminalText).toContain(ISSUE_URL)
|
||||
expect(terminalText).not.toMatch(/(?:^|\n)claude '--dangerously-skip-permissions'(?:\r?\n|$)/)
|
||||
})
|
||||
Reference in New Issue
Block a user