mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 02:17:31 +00:00
test: remove 145 low-value tests and nine suites (#37982)
* test: remove 145 low-value test declarations * test: clean up remaining type-only relay imports --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -66,45 +66,6 @@ describe('spawnDetachedWithoutInheritance', () => {
|
||||
spawnProcess.mockReset()
|
||||
})
|
||||
|
||||
it('uses a detached, ignoring libuv spawn off Windows', () => {
|
||||
onPlatform('linux')
|
||||
const spawner = vi.fn<IsolatedSpawner>()
|
||||
setIsolatedSpawner(spawner)
|
||||
spawnProcess.mockReturnValue({ pid: 1 })
|
||||
|
||||
spawnDetachedWithoutInheritance({ program: '/bin/true', args: ['x'], cwd: '/' })
|
||||
|
||||
expect(spawner).not.toHaveBeenCalled()
|
||||
expect(spawnProcess).toHaveBeenCalledWith({
|
||||
program: '/bin/true',
|
||||
args: ['x'],
|
||||
cwd: '/',
|
||||
detached: true,
|
||||
stdio: 'ignore'
|
||||
})
|
||||
})
|
||||
|
||||
it('falls back to libuv on Windows when no spawner is installed', () => {
|
||||
onPlatform('win32')
|
||||
spawnProcess.mockReturnValue({ pid: 1 })
|
||||
|
||||
spawnDetachedWithoutInheritance({ program: 'C:\\Windows\\System32\\wsl.exe' })
|
||||
|
||||
expect(spawnProcess).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it.each(['C:\\tools\\run.cmd', 'wsl.exe'])('falls back to libuv for %s', (program) => {
|
||||
onPlatform('win32')
|
||||
const spawner = vi.fn<IsolatedSpawner>()
|
||||
setIsolatedSpawner(spawner)
|
||||
spawnProcess.mockReturnValue({ pid: 1 })
|
||||
|
||||
spawnDetachedWithoutInheritance({ program, env: { ComSpec: 'cmd.exe' } })
|
||||
|
||||
expect(spawner).not.toHaveBeenCalled()
|
||||
expect(spawnProcess).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('hands the native spawner a libuv-shaped command line and environment block', async () => {
|
||||
onPlatform('win32')
|
||||
let exit: (code: number) => void = () => {}
|
||||
@@ -161,24 +122,6 @@ describe('spawnDetachedWithoutInheritance', () => {
|
||||
expect(killed.kill()).toBe(false)
|
||||
})
|
||||
|
||||
it('logs a child whose breakaway from our job was denied, and still starts it', async () => {
|
||||
onPlatform('win32')
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
||||
setIsolatedSpawner(() => ({ pid: 7, exitWatchError: null, breakawayDenied: true }))
|
||||
|
||||
const child = spawnDetachedWithoutInheritance({ program: 'C:\\wsl.exe' })
|
||||
await once(child, 'spawn')
|
||||
|
||||
expect(child.pid).toBe(7)
|
||||
expect(warn).toHaveBeenCalledWith(
|
||||
"[process-host] pid 7 could not break away from this process's job"
|
||||
)
|
||||
warn.mockClear()
|
||||
setIsolatedSpawner(() => ({ pid: 8, exitWatchError: null, breakawayDenied: false }))
|
||||
spawnDetachedWithoutInheritance({ program: 'C:\\wsl.exe' })
|
||||
expect(warn).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('refuses to kill a child whose exit it cannot watch, since its pid may be reused', async () => {
|
||||
onPlatform('win32')
|
||||
setIsolatedSpawner(() => ({ pid: 77, exitWatchError: 5, breakawayDenied: false }))
|
||||
|
||||
@@ -46,19 +46,6 @@ describe('runProcess termination failure', () => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('reports ordinary child close exactly once', async () => {
|
||||
const child = mockChild()
|
||||
const onChildTerminated = vi.fn()
|
||||
spawnMock.mockReturnValue(child)
|
||||
const pending = runProcess({ program: 'git', timeoutMs: null, onChildTerminated })
|
||||
|
||||
child.emit('close', 0, null)
|
||||
child.emit('close', 0, null)
|
||||
|
||||
await expect(pending).resolves.toMatchObject({ code: 0 })
|
||||
expect(onChildTerminated).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('does not report a live-child error before its eventual close', async () => {
|
||||
const child = mockChild()
|
||||
const onChildTerminated = vi.fn()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs'
|
||||
import { existsSync, mkdtempSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import path from 'node:path'
|
||||
import {
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
notifySpawnObserver,
|
||||
setSpawnObserver
|
||||
} from './spawn-observer'
|
||||
import { runProcess, runProcessSync, spawnProcess } from './run-process'
|
||||
|
||||
afterEach(() => {
|
||||
setSpawnObserver(null)
|
||||
@@ -19,87 +18,6 @@ afterEach(() => {
|
||||
})
|
||||
|
||||
describe('spawn observer', () => {
|
||||
it('reports the resolved program for a spawnProcess child', async () => {
|
||||
const seen: { command: string; args: readonly string[]; blockMs: number }[] = []
|
||||
setSpawnObserver((command, args, blockMs) => seen.push({ command, args, blockMs }))
|
||||
const child = spawnProcess({ program: process.execPath, args: ['-e', 'process.exit(0)'] })
|
||||
await new Promise((resolve) => child.on('exit', resolve))
|
||||
expect(seen).toHaveLength(1)
|
||||
expect(seen[0].command).toBe(process.execPath)
|
||||
expect(seen[0].args).toEqual(['-e', 'process.exit(0)'])
|
||||
expect(seen[0].blockMs).toBeGreaterThanOrEqual(0)
|
||||
})
|
||||
|
||||
it('reports exactly once for runProcess, which spawns through spawnProcess', async () => {
|
||||
let calls = 0
|
||||
setSpawnObserver(() => {
|
||||
calls += 1
|
||||
})
|
||||
await runProcess({ program: process.execPath, args: ['-e', 'process.exit(0)'] })
|
||||
expect(calls).toBe(1)
|
||||
})
|
||||
|
||||
it('reports the whole blocking run of runProcessSync', () => {
|
||||
const seen: { command: string; blockMs: number }[] = []
|
||||
setSpawnObserver((command, _args, blockMs) => seen.push({ command, blockMs }))
|
||||
const result = runProcessSync({
|
||||
program: process.execPath,
|
||||
args: ['-e', 'setTimeout(() => process.exit(3), 50)']
|
||||
})
|
||||
expect(result.code).toBe(3)
|
||||
expect(seen).toHaveLength(1)
|
||||
expect(seen[0].command).toBe(process.execPath)
|
||||
expect(seen[0].blockMs).toBeGreaterThanOrEqual(40)
|
||||
})
|
||||
|
||||
it('reports a runProcessSync launch that throws or times out', () => {
|
||||
const seen: string[] = []
|
||||
setSpawnObserver((command) => seen.push(command))
|
||||
const missing = path.join(tmpdir(), 'orca-spawn-observer-missing-program')
|
||||
expect(() => runProcessSync({ program: missing, args: [] })).toThrow()
|
||||
const timedOut = runProcessSync({
|
||||
program: process.execPath,
|
||||
args: ['-e', 'setTimeout(() => {}, 10_000)'],
|
||||
timeoutMs: 50
|
||||
})
|
||||
expect(timedOut.timedOut).toBe(true)
|
||||
expect(seen).toEqual([missing, process.execPath])
|
||||
})
|
||||
|
||||
it('stops reporting after the observer is cleared', async () => {
|
||||
let calls = 0
|
||||
setSpawnObserver(() => {
|
||||
calls += 1
|
||||
})
|
||||
setSpawnObserver(null)
|
||||
await runProcess({ program: process.execPath, args: ['-e', 'process.exit(0)'] })
|
||||
expect(calls).toBe(0)
|
||||
})
|
||||
|
||||
it('logs every spawn, sync or async, to the e2e spawn log when one is named', async () => {
|
||||
const dir = mkdtempSync(path.join(tmpdir(), 'orca-spawn-log-'))
|
||||
const log = path.join(dir, 'spawns.jsonl')
|
||||
process.env[E2E_SPAWN_LOG_ENV] = log
|
||||
process.env[E2E_USER_DATA_DIR_ENV] = dir
|
||||
try {
|
||||
await runProcess({ program: process.execPath, args: ['-e', 'process.exit(0)'] })
|
||||
runProcessSync({ program: process.execPath, args: ['-e', 'process.exit(0)'] })
|
||||
const lines = readFileSync(log, 'utf8')
|
||||
.trim()
|
||||
.split('\n')
|
||||
.map((line) => JSON.parse(line))
|
||||
const spawned = {
|
||||
file: process.execPath,
|
||||
args: ['-e', 'process.exit(0)'],
|
||||
at: expect.any(Number),
|
||||
stack: expect.arrayContaining([expect.stringContaining('spawn-observer.test')])
|
||||
}
|
||||
expect(lines).toEqual([spawned, spawned])
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
|
||||
it('outside e2e mode writes nothing and captures no stack, even with the log variable set', () => {
|
||||
const dir = mkdtempSync(path.join(tmpdir(), 'orca-spawn-log-'))
|
||||
const log = path.join(dir, 'spawns.jsonl')
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('electron', () => ({ ipcRenderer: { invoke: vi.fn(), on: vi.fn() } }))
|
||||
|
||||
import { getWslHostsApi } from './wsl-hosts-api'
|
||||
|
||||
describe('WSL hosts preload API', () => {
|
||||
beforeEach(() => {
|
||||
vi.stubEnv('MODE', 'e2e')
|
||||
})
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs()
|
||||
})
|
||||
|
||||
it('ignores the e2e fake outside an e2e build', () => {
|
||||
vi.stubEnv('MODE', 'production')
|
||||
const env = { ORCA_INTERNAL_WSL_HOSTS: '1', ORCA_E2E_FAKE_WSL_HOSTS: '{}' }
|
||||
expect(getWslHostsApi(env, 'linux')).toBeUndefined()
|
||||
expect(getWslHostsApi(env, 'win32')).toBeDefined()
|
||||
})
|
||||
|
||||
it('is absent on Windows and under the e2e fake while the internal gate is closed', () => {
|
||||
expect(getWslHostsApi({}, 'win32', [])).toBeUndefined()
|
||||
expect(getWslHostsApi({ ORCA_INTERNAL_WSL_HOSTS: 'true' }, 'win32', [])).toBeUndefined()
|
||||
expect(getWslHostsApi({ ORCA_E2E_FAKE_WSL_HOSTS: '{}' }, 'darwin', [])).toBeUndefined()
|
||||
})
|
||||
|
||||
it('is present behind the open gate only where WSL hosts can run', () => {
|
||||
expect(getWslHostsApi({ ORCA_INTERNAL_WSL_HOSTS: '1' }, 'win32')).toBeDefined()
|
||||
expect(
|
||||
getWslHostsApi({ ORCA_INTERNAL_WSL_HOSTS: '1', ORCA_E2E_FAKE_WSL_HOSTS: '{}' }, 'linux')
|
||||
).toBeDefined()
|
||||
expect(getWslHostsApi({ ORCA_INTERNAL_WSL_HOSTS: '1' }, 'darwin')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('is present behind a closed gate when main stamped serve-only, still only where hosts run', () => {
|
||||
const argv = ['--orca-wsl-hosts-serve-only']
|
||||
expect(getWslHostsApi({}, 'win32', argv)).toBeDefined()
|
||||
expect(getWslHostsApi({ ORCA_E2E_FAKE_WSL_HOSTS: '{}' }, 'linux', argv)).toBeDefined()
|
||||
expect(getWslHostsApi({}, 'darwin', argv)).toBeUndefined()
|
||||
expect(getWslHostsApi({}, 'win32', [])).toBeUndefined()
|
||||
})
|
||||
|
||||
it('is absent behind an open gate a remote policy blocked, unless main stamped serve-only', () => {
|
||||
const env = { ORCA_INTERNAL_WSL_HOSTS: '1' }
|
||||
const blocked = '--orca-wsl-hosts-policy-blocked'
|
||||
expect(getWslHostsApi(env, 'win32', [blocked])).toBeUndefined()
|
||||
expect(getWslHostsApi(env, 'win32', [blocked, '--orca-wsl-hosts-serve-only'])).toBeDefined()
|
||||
})
|
||||
})
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
} from './browser-extension-document-targets'
|
||||
|
||||
const DISCARDED_TAB = PRELOAD_FIRST_DISCARDED_TAB_ID + 3
|
||||
const REPLACED_TAB = PRELOAD_FIRST_DISCARDED_TAB_ID + 4
|
||||
|
||||
const ORCA_TOP = 'A'.repeat(32)
|
||||
const ORCA_AD = 'B'.repeat(32)
|
||||
@@ -354,24 +353,6 @@ describe('Orca documentIds in native scripting targets', () => {
|
||||
expect(chrome.runtime.lastError).toBeUndefined()
|
||||
expect(nativeListeners.size).toBe(0)
|
||||
})
|
||||
|
||||
it('keeps native result identities for untargeted executions', async () => {
|
||||
const { chrome, calls } = install(['webNavigation', 'scripting'])
|
||||
|
||||
await expect(chrome.scripting.executeScript({ target: { tabId: 3 } })).resolves.toEqual([
|
||||
{ frameId: 0, documentId: CHROMIUM_TOP, result: 0 }
|
||||
])
|
||||
|
||||
expect(calls).toEqual([])
|
||||
})
|
||||
|
||||
it('calls the native functions directly when there is nothing to map', () => {
|
||||
const { chrome, executeScript, sendMessage } = install(['scripting'])
|
||||
void chrome.scripting.executeScript({ target: { tabId: 3 } })
|
||||
void chrome.tabs.sendMessage(3, 'ping')
|
||||
expect(executeScript).toHaveBeenCalledTimes(1)
|
||||
expect(sendMessage).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('calls to a discarded tab', () => {
|
||||
@@ -393,10 +374,4 @@ describe('calls to a discarded tab', () => {
|
||||
expect(executeScript).not.toHaveBeenCalled()
|
||||
expect(sendMessage).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('leave a retired synthetic id to Electron, which reports no such tab', async () => {
|
||||
const { chrome, executeScript } = install(['scripting', 'webNavigation'])
|
||||
await chrome.scripting.executeScript({ target: { tabId: REPLACED_TAB } })
|
||||
expect(executeScript).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
DOC_PREVIEW_LINK_CLICK_CHANNEL,
|
||||
type DocPreviewLinkModifiers
|
||||
} from '../shared/doc-preview-scheme'
|
||||
import type { DocPreviewLinkModifiers } from '../shared/doc-preview-scheme'
|
||||
import {
|
||||
handleDocPreviewLinkAuxClick,
|
||||
handleDocPreviewLinkClick,
|
||||
installDocPreviewLinkInterception,
|
||||
PRELOAD_DOC_PREVIEW_LINK_CLICK_CHANNEL
|
||||
installDocPreviewLinkInterception
|
||||
} from './doc-preview-link-interception'
|
||||
|
||||
const NO_MODIFIERS = { metaKey: false, ctrlKey: false, shiftKey: false }
|
||||
@@ -70,10 +66,6 @@ beforeEach(() => {
|
||||
})
|
||||
|
||||
describe('doc preview link interception', () => {
|
||||
it('sends on exactly the channel main listens on', () => {
|
||||
expect(PRELOAD_DOC_PREVIEW_LINK_CLICK_CHANNEL).toBe(DOC_PREVIEW_LINK_CLICK_CHANNEL)
|
||||
})
|
||||
|
||||
it('listens for both press kinds in the capture phase, so the document cannot consume them first', () => {
|
||||
loadPreviewDocument('<a id="external" href="https://example.com/docs">go</a>')
|
||||
const addEventListener = vi.spyOn(document, 'addEventListener')
|
||||
@@ -127,15 +119,6 @@ describe('doc preview link interception', () => {
|
||||
expect(event.defaultPrevented).toBe(false)
|
||||
})
|
||||
|
||||
it('reports a trusted press on an external anchor exactly once and stops the navigation', () => {
|
||||
loadPreviewDocument('<a id="external" href="https://example.com/docs">go</a>')
|
||||
|
||||
const event = pressTrusted('#external')
|
||||
|
||||
expect(report).toHaveBeenCalledExactlyOnceWith('https://example.com/docs', NO_MODIFIERS)
|
||||
expect(event.defaultPrevented).toBe(true)
|
||||
})
|
||||
|
||||
it('reports the anchor even when the press landed on what it wraps', () => {
|
||||
loadPreviewDocument('<a href="https://example.com/docs"><span id="inner">go</span></a>')
|
||||
|
||||
@@ -175,16 +158,6 @@ describe('doc preview link interception', () => {
|
||||
expect(event.defaultPrevented).toBe(true)
|
||||
})
|
||||
|
||||
it('scrolls to the top for a bare # on an SVG anchor', () => {
|
||||
loadSvgAnchorDocument('#')
|
||||
const scrollTo = vi.spyOn(window, 'scrollTo').mockImplementation(() => {})
|
||||
|
||||
pressTrusted('#svg-hit')
|
||||
|
||||
expect(scrollTo).toHaveBeenCalledOnce()
|
||||
expect(report).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('keeps a rooted SVG link inside the preview rather than reading it as a filesystem path', () => {
|
||||
loadSvgAnchorDocument('/assets/a.html')
|
||||
|
||||
@@ -249,17 +222,6 @@ describe('doc preview link interception', () => {
|
||||
expect(report).toHaveBeenCalledExactlyOnceWith('https://example.com/page#section', NO_MODIFIERS)
|
||||
})
|
||||
|
||||
it('opens nothing for a middle click on a link', () => {
|
||||
loadPreviewDocument('<a id="external" href="https://example.com/docs">go</a>')
|
||||
const event = new MouseEvent('auxclick', { bubbles: true, button: 1, cancelable: true })
|
||||
Object.defineProperty(event, 'isTrusted', { configurable: true, value: true })
|
||||
|
||||
dispatch('#external', event)
|
||||
|
||||
expect(report).not.toHaveBeenCalled()
|
||||
expect(event.defaultPrevented).toBe(true)
|
||||
})
|
||||
|
||||
it('leaves a middle click the document dispatched itself alone', () => {
|
||||
loadPreviewDocument('<a id="external" href="https://example.com/docs">go</a>')
|
||||
const event = new MouseEvent('auxclick', { bubbles: true, button: 1, cancelable: true })
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { PLUGIN_DECLARATIVE_MESSAGES } from '../shared/plugins/declarative/plugin-declarative-message-names'
|
||||
import { PLUGIN_DECLARATIVE_RENDER_LANE } from '../shared/plugins/declarative/plugin-declarative-limits'
|
||||
import {
|
||||
createPluginFrameSendBudget,
|
||||
PRELOAD_PLUGIN_FRAME_LANES
|
||||
} from './plugin-frame-guest-send-budget'
|
||||
import { createPluginFrameSendBudget } from './plugin-frame-guest-send-budget'
|
||||
|
||||
function chain(depth: number): unknown {
|
||||
let tree: unknown = { type: 'Text', key: '#0', props: {}, children: ['leaf'] }
|
||||
@@ -15,18 +10,6 @@ function chain(depth: number): unknown {
|
||||
}
|
||||
|
||||
describe('guest preload render lane', () => {
|
||||
it("pins its written-out caps to the host's render lane", () => {
|
||||
const { render } = PRELOAD_PLUGIN_FRAME_LANES
|
||||
expect(render.events).toEqual([
|
||||
PLUGIN_DECLARATIVE_MESSAGES.render,
|
||||
PLUGIN_DECLARATIVE_MESSAGES.persist,
|
||||
PLUGIN_DECLARATIVE_MESSAGES.retain
|
||||
])
|
||||
expect(render.maxBytes).toBe(PLUGIN_DECLARATIVE_RENDER_LANE.maxBytes)
|
||||
expect(render.maxNodes).toBe(PLUGIN_DECLARATIVE_RENDER_LANE.maxObjects)
|
||||
expect(render.maxDepth).toBe(PLUGIN_DECLARATIVE_RENDER_LANE.maxDepth)
|
||||
})
|
||||
|
||||
it('sends trees the host accepts, past the shared 64 KiB and depth-100 caps', () => {
|
||||
const send = createPluginFrameSendBudget()
|
||||
const render = (tree: unknown) => ({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Isolated-world budget for what a guest may send to the host. Why written out: the sandboxed
|
||||
* preload can't import shared chunks; plugin-frame-guest.test.ts pins these numbers to the host's
|
||||
* lanes. Sizes are measured like the host measures them (UTF-8 strings, buffer bytes), so a
|
||||
* preload can't import shared chunks. Sizes are measured like the host measures them
|
||||
* (UTF-8 strings, buffer bytes), so a
|
||||
* message this admits is one the host can admit too.
|
||||
*/
|
||||
export const PRELOAD_PLUGIN_FRAME_LANES = {
|
||||
|
||||
@@ -7,19 +7,10 @@ import {
|
||||
PLUGIN_FRAME_KEY_CHANNEL,
|
||||
PLUGIN_FRAME_TRANSPORT_GLOBAL
|
||||
} from '../shared/plugins/frames/plugin-frame-guest'
|
||||
import { PLUGIN_SAVE_AS_MAX_BYTES } from '../shared/plugins/workers/plugin-host-api'
|
||||
import { PANEL_MESSAGE_MAX_BYTES } from '../shared/plugins/frames/plugin-frame-bridge'
|
||||
import { CUSTOM_EDITOR_DOCUMENT_MAX_BYTES } from '../shared/plugins/frames/plugin-custom-editor-bridge'
|
||||
import {
|
||||
PRELOAD_PLUGIN_FRAME_IPC_CHANNEL,
|
||||
PRELOAD_PLUGIN_FRAME_KEY_CHANNEL,
|
||||
PRELOAD_PLUGIN_FRAME_TRANSPORT_GLOBAL
|
||||
} from './plugin-frame-guest-transport'
|
||||
import {
|
||||
createPluginFrameGestureTracker,
|
||||
createPluginFrameSendBudget,
|
||||
measurePluginFrameMessageBytes,
|
||||
PRELOAD_PLUGIN_FRAME_LANES
|
||||
measurePluginFrameMessageBytes
|
||||
} from './plugin-frame-guest-send-budget'
|
||||
|
||||
type Transport = { send: (message: unknown) => void; subscribe: (fn: (m: unknown) => void) => void }
|
||||
@@ -82,17 +73,6 @@ function runPreload(isMainFrame: boolean, contentType = 'text/html') {
|
||||
}
|
||||
|
||||
describe('plugin frame guest preload', () => {
|
||||
it('pins its written-out constants to the shared ones', () => {
|
||||
expect(PRELOAD_PLUGIN_FRAME_IPC_CHANNEL).toBe(PLUGIN_FRAME_IPC_CHANNEL)
|
||||
expect(PRELOAD_PLUGIN_FRAME_KEY_CHANNEL).toBe(PLUGIN_FRAME_KEY_CHANNEL)
|
||||
expect(PRELOAD_PLUGIN_FRAME_TRANSPORT_GLOBAL).toBe(PLUGIN_FRAME_TRANSPORT_GLOBAL)
|
||||
const { shared, saveAs, edit } = PRELOAD_PLUGIN_FRAME_LANES
|
||||
expect(shared.maxBytes).toBeGreaterThanOrEqual(PANEL_MESSAGE_MAX_BYTES)
|
||||
expect(shared.maxBytes).toBeLessThan(PANEL_MESSAGE_MAX_BYTES * 2)
|
||||
expect(saveAs.maxBytes).toBe(PLUGIN_SAVE_AS_MAX_BYTES + 4096)
|
||||
expect(edit.maxBytes).toBe(CUSTOM_EDITOR_DOCUMENT_MAX_BYTES + 4096)
|
||||
})
|
||||
|
||||
it('hands the shell a deletable transport and stamps each send with a gesture serial', () => {
|
||||
const { sendToHost, ipcListeners, pageWindow, input, transport } = runPreload(true)
|
||||
expect(
|
||||
|
||||
@@ -44,7 +44,6 @@ vi.mock('../main/pty/shell-startup/git-bash', () => ({
|
||||
vi.mock('@orca/process-host', () => ({ runProcess: runProcessMock }))
|
||||
|
||||
import {
|
||||
buildCommandLookupSpecs,
|
||||
hasAbsoluteCommandPath,
|
||||
isCommandOnPathForRelay,
|
||||
PreflightHandler
|
||||
@@ -75,29 +74,6 @@ beforeEach(() => {
|
||||
isGitBashAvailableMock.mockReset()
|
||||
})
|
||||
|
||||
describe('buildCommandLookupSpecs', () => {
|
||||
it('allows a custom shell path only when the account login shell matches', () => {
|
||||
expect(
|
||||
buildCommandLookupSpecs(
|
||||
'codex',
|
||||
'darwin',
|
||||
{ SHELL: '/opt/homebrew/bin/zsh' },
|
||||
'/opt/homebrew/bin/zsh'
|
||||
)
|
||||
).toEqual([
|
||||
{ file: '/opt/homebrew/bin/zsh', args: lookupArgs('codex', '-ilc') },
|
||||
{ file: '/bin/sh', args: lookupArgs('codex') }
|
||||
])
|
||||
})
|
||||
|
||||
it('allows conservative system shell paths when account lookup is unavailable', () => {
|
||||
expect(buildCommandLookupSpecs('codex', 'linux', { SHELL: '/usr/bin/bash' }, null)[0]).toEqual({
|
||||
file: '/usr/bin/bash',
|
||||
args: lookupArgs('codex', '-ilc')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('isCommandOnPathForRelay', () => {
|
||||
it('falls back to inherited PATH when shell startup returns no absolute command path', async () => {
|
||||
execFileAsyncMock
|
||||
@@ -280,44 +256,4 @@ describe('PreflightHandler', () => {
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
it('reports remote Windows shell capabilities through the SSH preflight path', async () => {
|
||||
const originalPlatform = process.platform
|
||||
Object.defineProperty(process, 'platform', {
|
||||
configurable: true,
|
||||
value: 'win32'
|
||||
})
|
||||
isWslAvailableAsyncMock.mockResolvedValue(true)
|
||||
listWslDistrosAsyncMock.mockResolvedValue(['Ubuntu'])
|
||||
isPwshAvailableAsyncMock.mockResolvedValue(true)
|
||||
isGitBashAvailableMock.mockReturnValue(true)
|
||||
|
||||
const requestHandlers = new Map<string, (params: Record<string, unknown>) => Promise<unknown>>()
|
||||
const dispatcher = {
|
||||
onRequest: vi.fn(
|
||||
(method: string, handler: (params: Record<string, unknown>) => Promise<unknown>) => {
|
||||
requestHandlers.set(method, handler)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
new PreflightHandler(dispatcher as never)
|
||||
|
||||
try {
|
||||
const handler = requestHandlers.get('preflight.detectWindowsTerminalCapabilities')
|
||||
expect(handler).toBeDefined()
|
||||
await expect(handler!({})).resolves.toEqual({
|
||||
wslAvailable: true,
|
||||
wslDistros: ['Ubuntu'],
|
||||
pwshAvailable: true,
|
||||
gitBashAvailable: true,
|
||||
hostPlatform: 'win32'
|
||||
})
|
||||
} finally {
|
||||
Object.defineProperty(process, 'platform', {
|
||||
configurable: true,
|
||||
value: originalPlatform
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user