test: remove low-value startup and IPC test suites (#43419)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-11-16 20:26:11 -08:00
committed by GitHub
co-authored by OrcaWin
parent bfe15312a2
commit 2f17e24a18
11 changed files with 0 additions and 500 deletions
@@ -45,7 +45,6 @@ jobs:
run: >-
pnpm exec vitest run --config config/vitest.config.ts --maxWorkers=2
src/main/ipc/preflight/preflight-runnable-local-cli.test.ts
src/main/ipc/preflight/preflight-wsl-agent-detection.test.ts
src/packages/process-host/src/process-tree-termination.test.ts
src/packages/process-host/src/run-process.test.ts
src/packages/process-host/src/run-process-termination-failure.test.ts
@@ -1408,7 +1408,6 @@
"src/main/ipc/browser/browser-client-page-metadata-ipc.test.ts": 143,
"src/main/ipc/browser/browser-session-profile-ipc.test.ts": 699,
"src/main/ipc/browser/browser.test.ts": 1209,
"src/main/ipc/accounts/codex-config-sync.test.ts": 101,
"src/main/ipc/command-path/command-path-directory-worker.test.ts": 640,
"src/main/ipc/command-path/command-path-resolver.test.ts": 130,
"src/main/ipc/crash-reporting/crash-reporting-replay-guard-wedge-burst.test.ts": 82,
@@ -1417,7 +1416,6 @@
"src/main/ipc/ephemeral-vm/ephemeral-vm.test.ts": 2043,
"src/main/ipc/feedback/feedback-image-attachments.test.ts": 86,
"src/main/ipc/feedback/feedback-request-ownership.test.ts": 87,
"src/main/ipc/feedback/feedback.test.ts": 150,
"src/main/ipc/filesystem/access/filesystem-allowed-roots.test.ts": 551,
"src/main/ipc/filesystem/access/filesystem-auth-unc-drive-missing-path.test.ts": 182,
"src/main/ipc/filesystem/access/filesystem-auth.test.ts": 749,
@@ -1460,8 +1458,6 @@
"src/main/ipc/plugins/plugins-panel-document-lifetime.test.ts": 875,
"src/main/ipc/preflight/preflight-provider-command-selection.test.ts": 458,
"src/main/ipc/preflight/preflight-runnable-local-cli.test.ts": 9893,
"src/main/ipc/preflight/preflight-wsl-agent-detection.test.ts": 94,
"src/main/ipc/preflight/preflight-wsl-command.test.ts": 57,
"src/main/ipc/pty/host-env/claude-agent-view.test.ts": 49,
"src/main/ipc/pty/host-env/opencode-hook-installation.test.ts": 668,
"src/main/ipc/pty/ipc/spawn-commit-run-facts.test.ts": 1661,
@@ -1,92 +0,0 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { mkdtempSync, rmSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { AgentHookServer, _internals } from '../../agent-hook-server'
import { buildBody, PANE } from '../server.test-fixtures'
import { mainAgentDoneAt } from '../../../../../shared/agent-status/lifecycle/main-agent-status'
import type { AutomationRun } from '../../../../../shared/automations/history/automation-run'
import { createRuntimeAutomationRunTerminalObserver } from '../../../../automations/observation/runtime-terminal-run-observer'
vi.mock('../../../../telemetry/client', () => ({ track: vi.fn() }))
vi.mock('../../../../telemetry/cohort-classifier', () => ({
getCohortAtEmit: () => ({ nth_repo_added: 2 })
}))
// Markers past the 8,000-char status preview prove the whole reply survived.
const REPLY = `START ${'a'.repeat(12_000)} MIDDLE-MARKER ${'b'.repeat(12_000)} END-MARKER`
let userDataPath: string
let server: AgentHookServer
beforeEach(async () => {
_internals.resetCachesForTests()
userDataPath = mkdtempSync(join(tmpdir(), 'orca-accepted-reply-'))
server = new AgentHookServer()
await server.start({ env: 'production', userDataPath })
})
afterEach(() => {
server.stop()
rmSync(userDataPath, { recursive: true, force: true })
})
async function post(payload: Record<string, unknown>): Promise<void> {
const env = server.buildPtyEnv()
await fetch(`http://127.0.0.1:${env.ORCA_AGENT_HOOK_PORT}/hook/claude`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Orca-Agent-Hook-Token': env.ORCA_AGENT_HOOK_TOKEN
},
body: JSON.stringify(buildBody(payload))
})
}
/** What a run watcher reads: the reply for the lead turn its selected row reports finished. */
function replyForCurrentRow(): string | undefined {
const row = server.getStatusSnapshotForPane(PANE)[0]
const leadTurnKey = row ? mainAgentDoneAt(row) : undefined
return leadTurnKey === undefined ? undefined : server.getAcceptedReply(PANE, leadTurnKey)
}
describe('accepted lead reply', () => {
it("saves the reply of an agent that exits right after it, though exit cleanup clears the pane's status", async () => {
await post({ hook_event_name: 'UserPromptSubmit', prompt: 'write the report' })
const paneKey: string = PANE
const observer = createRuntimeAutomationRunTerminalObserver(
{
getTerminalHandleForPaneKey: () => 'terminal-1',
readTerminal: async () => ({ tail: [] }),
canOpenRunTerminals: () => true,
waitForTerminal: async () => {
await post({ hook_event_name: 'Stop', last_assistant_message: REPLY })
server.reconcileEndedProcessForPaneKeys([PANE])
throw Object.assign(new Error('terminal_exited'), {
terminalExitCause: { kind: 'exited', exitCode: 0 }
})
}
},
{
getAgentStatusRowsForPane: (paneKey) => server.getStatusSnapshotForPane(paneKey),
getAcceptedReply: (paneKey, leadTurnKey) => server.getAcceptedReply(paneKey, leadTurnKey),
subscribeStatusChanges: (listener) =>
server.subscribeStatusRowMutations(({ after }) => after && listener(after.paneKey)),
agentCommandsForRun: () => ['claude']
}
)
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the observer reads only these run fields.
const run = { terminalPaneKey: paneKey, startedAt: 0, dispatchedAt: 0 } as AutomationRun
const observation = await observer.observeCompletion('terminal-1', {
signal: new AbortController().signal,
run
})
expect(replyForCurrentRow()).toBeUndefined()
expect(observation).toMatchObject({
status: 'completed',
outputSnapshot: { content: REPLY, truncated: false }
})
})
})
@@ -1,81 +0,0 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import type * as NodeOs from 'node:os'
const { handleMock, removeHandlerMock, homedirMock } = vi.hoisted(() => ({
handleMock: vi.fn(),
removeHandlerMock: vi.fn(),
homedirMock: vi.fn<() => string>()
}))
vi.mock('electron', () => ({
ipcMain: { handle: handleMock, removeHandler: removeHandlerMock }
}))
vi.mock('node:os', async (importOriginal) => {
const actual = await importOriginal<typeof NodeOs>()
return { ...actual, homedir: homedirMock }
})
import { registerCodexConfigSyncHandlers } from './codex-config-sync'
import type { CodexConfigSyncStatus } from '../../../shared/agent-accounts/codex/codex-config-sync-types'
let root: string
function invokeHandler(mirroredHome: string | null): CodexConfigSyncStatus {
return invokeHandlerWithStatus({ kind: 'ready', homePath: mirroredHome })
}
function invokeHandlerWithStatus(
mirrored: { kind: 'ready'; homePath: string | null } | { kind: 'unavailable' }
): CodexConfigSyncStatus {
handleMock.mockClear()
registerCodexConfigSyncHandlers({
getMirroredHostHomePathForStatus: () => mirrored
})
const handler = handleMock.mock.calls.at(-1)?.[1] as () => CodexConfigSyncStatus
return handler()
}
beforeEach(() => {
root = mkdtempSync(join(tmpdir(), 'orca-config-sync-ipc-'))
homedirMock.mockReturnValue(root)
mkdirSync(join(root, '.codex'), { recursive: true })
})
afterEach(() => {
rmSync(root, { recursive: true, force: true })
vi.clearAllMocks()
})
describe('codexConfigSync:status handler', () => {
it('reports the stall for the home the current selection actually mirrors into', () => {
// Managed accounts mirror per-account homes, not the shared runtime home.
const perAccountHome = join(root, 'codex-accounts', 'acct-1', 'home')
mkdirSync(perAccountHome, { recursive: true })
writeFileSync(join(perAccountHome, 'config.toml'), 'model = "runtime-model"\n', 'utf-8')
expect(invokeHandler(perAccountHome)).toEqual({
state: 'stalled',
reason: 'missing-source',
systemConfigPath: join(root, '.codex', 'config.toml')
})
})
})
// Unreadable managed homes must not collapse into the healthy no-mirror state (STA-4422).
it('reports a managed-home-unavailable stall instead of synced when the home is unreadable', () => {
expect(invokeHandlerWithStatus({ kind: 'ready', homePath: null })).toEqual({
state: 'synced',
reason: null,
systemConfigPath: join(root, '.codex', 'config.toml')
})
expect(invokeHandlerWithStatus({ kind: 'unavailable' })).toEqual({
state: 'stalled',
reason: 'managed-home-unavailable',
systemConfigPath: join(root, '.codex', 'config.toml')
})
})
-70
View File
@@ -1,70 +0,0 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
const { fetchMock, handlers } = vi.hoisted(() => ({
fetchMock: vi.fn(),
handlers: new Map<string, (_event: unknown, args?: unknown) => unknown>()
}))
vi.mock('electron', () => ({
app: { getVersion: () => '1.2.3-test' },
ipcMain: {
handle: vi.fn((channel: string, handler: (_event: unknown, args?: unknown) => unknown) => {
handlers.set(channel, handler)
}),
removeHandler: vi.fn((channel: string) => handlers.delete(channel))
},
net: { fetch: (...args: unknown[]) => fetchMock(...args) }
}))
import { submitFeedback } from './feedback'
function okResponse(): Response {
return { ok: true, status: 200 } as unknown as Response
}
describe('submitFeedback', () => {
beforeEach(() => {
vi.useRealTimers()
handlers.clear()
fetchMock.mockReset()
fetchMock.mockResolvedValue(okResponse())
})
afterEach(() => {
vi.useRealTimers()
})
describe('image attachments', () => {
function pngImage(bytes = 8): { contentType: string; data: Uint8Array } {
return { contentType: 'image/png', data: new Uint8Array(bytes).fill(1) }
}
function imageSubmitArgs(
images: { contentType: string; data: Uint8Array }[]
): Parameters<typeof submitFeedback>[0] {
return {
feedback: 'images attached',
submissionType: 'feedback',
githubLogin: 'someone',
githubEmail: null,
images
}
}
it('reports unconfirmed delivery for a settled non-JSON 2xx', async () => {
fetchMock.mockResolvedValue({
ok: true,
status: 202,
json: async () => {
throw new SyntaxError('Unexpected token')
}
} as unknown as Response)
await expect(submitFeedback(imageSubmitArgs([pngImage()]))).resolves.toEqual({
ok: true,
imagesDelivered: false
})
})
// Enforce MIME ownership at IPC even if a renderer bypasses its own checks.
})
})
@@ -1,76 +0,0 @@
import { execFileSync, type ExecFileSyncOptions } from 'node:child_process'
import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
const runWslProcessMock = vi.hoisted(() => vi.fn())
vi.mock('../../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock }))
import { detectWslCommandsOnPath } from './preflight-wsl-agent-detection'
import '../../../shared/shell/command-resolution/posix-command-path-lookup'
describe('the detection script itself, run by a real POSIX shell', () => {
// Execute real shell globbing and executable checks; Windows has no /bin/sh.
const itPosix = process.platform === 'win32' ? it.skip : it
let home: string
beforeEach(() => {
home = mkdtempSync(join(tmpdir(), 'orca-wsl-detect-'))
})
afterEach(() => {
rmSync(home, { recursive: true, force: true })
})
const plant = (dir: string, name: string): void => {
mkdirSync(join(home, dir), { recursive: true })
const file = join(home, dir, name)
writeFileSync(file, '#!/bin/sh\necho hi\n')
chmodSync(file, 0o755)
}
const runScript = async (): Promise<string> => {
runWslProcessMock.mockResolvedValue({
environmentResolved: false,
code: 0,
stdout: '',
stderr: '',
timedOut: false
})
await detectWslCommandsOnPath({ distro: 'Ubuntu' }, ['orca-fake-cli', 'nosuchtool'])
const script = String(runWslProcessMock.mock.calls.at(-1)?.[0].script)
const options: ExecFileSyncOptions = {
encoding: 'utf8',
env: { HOME: home, PATH: '/usr/bin:/bin' }
}
return String(execFileSync('/bin/sh', ['-c', script], options))
}
itPosix('finds an nvm-installed binary the login PATH would have shown', async () => {
// Version-manager fallback must recover a CLI absent from login PATH (#9725).
plant('.nvm/versions/node/v20.1.0/bin', 'orca-fake-cli')
const out = await runScript()
expect(out).toContain('__ORCA_AGENT_PATH__orca-fake-cli')
expect(out).toContain('.nvm/versions/node/v20.1.0/bin/orca-fake-cli')
})
itPosix('finds a CLI when $HOME contains a space', async () => {
// HOME with spaces must remain one path throughout fallback glob expansion.
const spaced = mkdtempSync(join(tmpdir(), 'orca has space-'))
const previous = home
home = spaced
try {
plant('.nvm/versions/node/v20.1.0/bin', 'orca-fake-cli')
expect(await runScript()).toContain(`${spaced}/.nvm/versions/node/v20.1.0/bin/orca-fake-cli`)
} finally {
home = previous
rmSync(spaced, { recursive: true, force: true })
}
})
itPosix('does not report a directory as an installed CLI', async () => {
// Directories pass -x but would fail to launch with EISDIR.
mkdirSync(join(home, '.local/bin/orca-fake-cli'), { recursive: true })
expect(await runScript()).not.toContain('__ORCA_AGENT_PATH__orca-fake-cli')
})
})
@@ -1,87 +0,0 @@
import { execFileSync, type ExecFileSyncOptions } from 'node:child_process'
import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { beforeEach, describe, expect, it, vi } from 'vitest'
const runWslProcessMock = vi.hoisted(() => vi.fn())
vi.mock('../../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock }))
import { runPreflightCommandInWsl } from './preflight-wsl-command'
beforeEach(() => {
runWslProcessMock.mockReset()
runWslProcessMock.mockResolvedValue({
environmentResolved: false,
code: 0,
stdout: 'gh version 2.0.0',
stderr: '',
timedOut: false
})
})
describe('the PATH fallback, run by a real POSIX shell', () => {
const itPosix = process.platform === 'win32' ? it.skip : it
itPosix('finds an nvm-installed CLI a degraded probe would have missed', async () => {
// Use a fabricated CLI: appended fallback PATH must not lose to a real host gh binary (#9725).
const home = mkdtempSync(join(tmpdir(), 'orca-wsl-cmd-'))
try {
const bin = join(home, '.nvm/versions/node/v20.1.0/bin')
mkdirSync(bin, { recursive: true })
writeFileSync(join(bin, 'orca-fake-cli'), '#!/bin/sh\necho cli-ok\n')
chmodSync(join(bin, 'orca-fake-cli'), 0o755)
runWslProcessMock.mockResolvedValue({
environmentResolved: false,
code: 0,
stdout: '',
stderr: '',
timedOut: false
})
await runPreflightCommandInWsl({ distro: 'Ubuntu' }, 'command -v orca-fake-cli', 5000)
const script = String(runWslProcessMock.mock.calls.at(-1)?.[0].script)
const options: ExecFileSyncOptions = {
encoding: 'utf8',
env: { HOME: home, PATH: '/usr/bin:/bin' }
}
expect(String(execFileSync('/bin/sh', ['-c', script], options))).toContain(
'.nvm/versions/node/v20.1.0/bin/orca-fake-cli'
)
} finally {
rmSync(home, { recursive: true, force: true })
}
})
itPosix('appends rather than prepends, so a resolved PATH still wins', async () => {
const home = mkdtempSync(join(tmpdir(), 'orca-wsl-cmd-'))
const real = mkdtempSync(join(tmpdir(), 'orca-wsl-real-'))
try {
for (const [dir, body] of [
[join(home, '.local/bin'), 'stale'],
[real, 'current']
] as const) {
mkdirSync(dir, { recursive: true })
writeFileSync(join(dir, 'orca-fake-cli'), `#!/bin/sh\necho ${body}\n`)
chmodSync(join(dir, 'orca-fake-cli'), 0o755)
}
runWslProcessMock.mockResolvedValue({
environmentResolved: true,
code: 0,
stdout: '',
stderr: '',
timedOut: false
})
await runPreflightCommandInWsl({ distro: 'Ubuntu' }, 'orca-fake-cli', 5000)
const script = String(runWslProcessMock.mock.calls.at(-1)?.[0].script)
const options: ExecFileSyncOptions = {
encoding: 'utf8',
env: { HOME: home, PATH: `${real}:/usr/bin:/bin` }
}
expect(String(execFileSync('/bin/sh', ['-c', script], options)).trim()).toBe('current')
} finally {
rmSync(home, { recursive: true, force: true })
rmSync(real, { recursive: true, force: true })
}
})
})
@@ -8,10 +8,6 @@ describe('tuiAgentArgsBypassPermissions', () => {
// Legacy Yolo intent lives in Arguments, not separate storage; recognize its token sequence anywhere before --.
it.each([
['claude', '--dangerously-skip-permissions', true],
['claude', '--dangerously-skip-permissions --model Opus', true],
['claude', '--model Opus --dangerously-skip-permissions', true],
['claude', '', false],
['claude', '--model Opus', false],
// A token boundary, so a longer flag that merely starts the same way is not a bypass.
['claude', '--dangerously-skip-permissions-not-really', false],
[
@@ -20,13 +16,8 @@ describe('tuiAgentArgsBypassPermissions', () => {
false
],
['claude', '-- --dangerously-skip-permissions', false],
['codex', '--dangerously-bypass-approvals-and-sandbox --model gpt-5.6-sol', true],
['codex', '--model gpt-5.6-sol', false],
['codex', '--config "note=--dangerously-bypass-approvals-and-sandbox only as text"', false],
['codex', '-- --dangerously-bypass-approvals-and-sandbox', false],
// Two-token bypass flags match as a token sequence, not one token.
['grok', '--permission-mode bypassPermissions', true],
['grok', '--model grok-4.7 --permission-mode bypassPermissions', true],
['grok', '--permission-mode default', false],
['grok', '--permission-mode', false],
['grok', '--permission-mode "bypassPermissions now"', false],
@@ -1,32 +0,0 @@
import { describe, expect, it } from 'vitest'
import { resolveAgentStartupPlanInputs } from './agent-startup-plan-inputs'
import './automation-extra-agent-args'
import { buildAgentStartupPlan } from './tui-agent-startup'
import '../choices/tui-agent-launch-defaults'
const SETTINGS = {
agentDefaultArgs: { claude: '--dangerously-skip-permissions --model sonnet' },
terminalWindowsShell: 'powershell.exe'
}
describe('resolveAgentStartupPlanInputs with extra agent args', () => {
it.each([
['linux', false],
['win32', false],
['win32', true]
] as const)('merges over the host defaults on %s (remote %s)', (platform, isRemote) => {
const inputs = resolveAgentStartupPlanInputs({
agent: 'claude',
settings: SETTINGS,
platform,
isRemote,
shell: undefined,
extraAgentArgs: '--model opus --add-dir "my docs"'
})
const plan = buildAgentStartupPlan({ ...inputs, prompt: 'go' })
expect(plan?.launchCommand).toContain("'--add-dir' 'my docs'")
expect(plan?.launchCommand).toContain('opus')
expect(plan?.launchCommand).not.toContain('sonnet')
expect(plan?.launchCommand).toContain('--dangerously-skip-permissions')
})
})
@@ -1,46 +0,0 @@
import { describe, expect, it } from 'vitest'
import { buildAiVaultResumeCommand } from '../../ai-vault/resume/ai-vault-resume-command'
import { buildAgentResumeStartupPlan } from './tui-agent-resume-startup'
describe('OpenCode 2 restored terminal launch mode', () => {
it('retains an explicitly configured standalone command and quoted Unix session id', () => {
const plan = buildAgentResumeStartupPlan({
agent: 'opencode2',
providerSession: { key: 'session_id', id: 'session with spaces & $HOME' },
cmdOverrides: { opencode2: 'mise exec -- team-opencode --standalone --port 4321' },
platform: 'linux'
})
expect(plan?.launchCommand).toBe(
"mise exec -- team-opencode --standalone --port 4321 '--session' 'session with spaces & $HOME'"
)
})
it('does not resume unsupported provider identities', () => {
expect(
buildAgentResumeStartupPlan({
agent: 'opencode2',
providerSession: { key: 'conversation_id', id: 'conversation' },
cmdOverrides: {},
platform: 'linux'
})
).toBeNull()
})
})
describe('OpenCode 2 session-history launch mode', () => {
it('preserves a standalone override and Windows command quoting in a folder workspace', () => {
expect(
buildAiVaultResumeCommand({
agent: 'opencode2',
sessionId: 'session & one',
cwd: 'C:\\Ada Lovelace\\folder',
commandOverride: '"C:\\Agent Tools\\opencode2.cmd" --standalone',
platform: 'win32',
shell: 'cmd'
})
).toBe(
'cd /d "C:\\Ada Lovelace\\folder" && "C:\\Agent Tools\\opencode2.cmd" --standalone --session "session & one"'
)
})
})
@@ -1,9 +1,7 @@
import './agent-resume-argv-drop.spec'
import './agent-resume-launch-command.spec'
import './agent-startup-plan-inputs.spec'
import './agent-startup-plan-inputs-extra-agent-args.spec'
import './opencode-startup-prompt.spec'
import './opencode2-resume-launch-mode.spec'
import './tui-agent-fork-startup.spec'
import '../choices/tui-agent-launch-defaults.spec'
import './tui-agent-startup-hermes.spec'