mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 19:34:29 +00:00
test: remove redundant browser and runtime mock suites (#42292)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -809,7 +809,6 @@
|
||||
"src/main/browser/element-grab/browser-grab-payload.test.ts": 55,
|
||||
"src/main/browser/guest-lifecycle/devtools/browser-guest-devtools-dock.test.ts": 57,
|
||||
"src/main/browser/guest-lifecycle/input/browser-guest-target-url.test.ts": 50,
|
||||
"src/main/browser/guest-lifecycle/input/browser-guest-wheel-zoom-scroll.test.ts": 45,
|
||||
"src/main/browser/client-hosts/leases/browser-host-client-identity.test.ts": 97,
|
||||
"src/main/browser/guest-lifecycle/prompts/browser-http-auth-prompt.test.ts": 74,
|
||||
"src/main/browser/identity/mode/browser-identity-mode-store.test.ts": 95,
|
||||
@@ -1406,7 +1405,6 @@
|
||||
"src/main/daemon/providers/lifecycle/testing/daemon-init-endpoint-adoption.test.ts": 1942,
|
||||
"src/main/daemon/providers/lifecycle/testing/daemon-init-live-session-preservation.test.ts": 1145,
|
||||
"src/main/daemon/providers/lifecycle/testing/daemon-init-macos-stable-launch-fallback.test.ts": 676,
|
||||
"src/main/daemon/providers/lifecycle/testing/daemon-init-packaged-bundle-staleness.test.ts": 551,
|
||||
"src/main/daemon/providers/lifecycle/testing/daemon-init-provider-installation.test.ts": 1395,
|
||||
"src/main/daemon/providers/lifecycle/testing/daemon-init-restart-sequence.test.ts": 2118,
|
||||
"src/main/daemon/providers/lifecycle/testing/daemon-init-severed-host-image.test.ts": 808,
|
||||
@@ -2950,7 +2948,6 @@
|
||||
"src/main/runtime/terminal/layout/mobile-subscribe-idle-pane-hydrate.test.ts": 4782,
|
||||
"src/main/runtime/client/navigation/multi-client-navigation-isolation.integration.test.ts": 5640,
|
||||
"src/main/runtime/terminal/wait/omp-readiness-transcripts.test.ts": 7901,
|
||||
"src/main/runtime/terminal/launch/omp-user-bubble-launch-authority.test.ts": 4274,
|
||||
"src/main/runtime/terminal/wait/opencode-agent-row-structure-transcript.test.ts": 277,
|
||||
"src/main/runtime/orchestration/terminal-authority/opencode-finished-session-authority.test.ts": 4172,
|
||||
"src/main/runtime/session-construction/agent-session/orca-runtime-agent-session-operation.test.ts": 4039,
|
||||
@@ -4203,7 +4200,6 @@
|
||||
"src/renderer/src/components/browser-pane/assemble-chrome/browser-workspace-pane.adoption-chrome.test.tsx": 25933,
|
||||
"src/renderer/src/components/browser-pane/assemble-chrome/browser-workspace-pane.retention-props.test.tsx": 3808,
|
||||
"src/renderer/src/components/browser-pane/assemble-chrome/use-browser-chrome-tool-fold.test.tsx": 307,
|
||||
"src/renderer/src/components/browser-pane/assemble-chrome/use-browser-page-find-shortcuts.test.tsx": 1874,
|
||||
"src/renderer/src/components/browser-pane/browser-client-page-attachment-scan-budget.test.ts": 464,
|
||||
"src/renderer/src/components/browser-pane/browser-client-page-metadata-publisher.test.ts": 315,
|
||||
"src/renderer/src/components/browser-pane/browser-client-page-profile-staging.test.ts": 434,
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const agentInjection = vi.hoisted(() => ({ active: false }))
|
||||
vi.mock('../../cdp/input/agent-input-injection', () => ({
|
||||
isAgentInjectingInput: () => agentInjection.active
|
||||
}))
|
||||
|
||||
import { setupGuestMouseWheelZoomForwarding } from './browser-guest-wheel-zoom'
|
||||
|
||||
describe('guest before-mouse-event forwarding', () => {
|
||||
const rendererSend = vi.fn()
|
||||
const guestOn = vi.fn()
|
||||
|
||||
beforeEach(() => {
|
||||
rendererSend.mockReset()
|
||||
guestOn.mockReset()
|
||||
})
|
||||
|
||||
function trigger(
|
||||
active: boolean,
|
||||
mouse: Partial<Electron.MouseWheelInputEvent>
|
||||
): ReturnType<typeof vi.fn> {
|
||||
setupGuestMouseWheelZoomForwarding({
|
||||
browserTabId: 'tab-1',
|
||||
guest: { on: guestOn } as unknown as Electron.WebContents,
|
||||
resolveRenderer: () => ({ send: rendererSend }) as unknown as Electron.WebContents,
|
||||
isViewportPresetActive: () => active,
|
||||
canViewportScroll: () => active
|
||||
})
|
||||
const handler = guestOn.mock.calls.at(-1)![1] as (
|
||||
event: Electron.Event,
|
||||
input: Electron.MouseInputEvent
|
||||
) => void
|
||||
const preventDefault = vi.fn()
|
||||
handler({ preventDefault } as unknown as Electron.Event, {
|
||||
type: 'mouseWheel',
|
||||
x: 0,
|
||||
y: 0,
|
||||
modifiers: [],
|
||||
deltaX: 0,
|
||||
deltaY: 0,
|
||||
...mouse
|
||||
})
|
||||
return preventDefault
|
||||
}
|
||||
|
||||
function sideButton(
|
||||
type: 'mouseDown' | 'mouseUp',
|
||||
button: string
|
||||
): Partial<Electron.MouseWheelInputEvent> {
|
||||
const mouse: Partial<Electron.MouseWheelInputEvent> = {}
|
||||
// Why: overrides trigger's wheel defaults; Electron reports side buttons as 'back'/'forward'
|
||||
// at runtime, which its typing omits.
|
||||
Reflect.set(mouse, 'type', type)
|
||||
Reflect.set(mouse, 'button', button)
|
||||
return mouse
|
||||
}
|
||||
|
||||
it('leaves presses an agent makes in the page to the page alone', () => {
|
||||
agentInjection.active = true
|
||||
try {
|
||||
trigger(false, sideButton('mouseDown', 'left'))
|
||||
trigger(false, sideButton('mouseUp', 'back'))
|
||||
} finally {
|
||||
agentInjection.active = false
|
||||
}
|
||||
expect(rendererSend).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('leaves fitting presets and host-edge wheels to the guest page', () => {
|
||||
setupGuestMouseWheelZoomForwarding({
|
||||
browserTabId: 'tab-1',
|
||||
guest: { on: guestOn } as unknown as Electron.WebContents,
|
||||
resolveRenderer: () => ({ send: rendererSend }) as unknown as Electron.WebContents,
|
||||
isViewportPresetActive: () => true,
|
||||
canViewportScroll: () => false
|
||||
})
|
||||
const handler = guestOn.mock.calls.at(-1)![1] as (
|
||||
event: Electron.Event,
|
||||
input: Electron.MouseWheelInputEvent
|
||||
) => void
|
||||
const preventDefault = vi.fn()
|
||||
handler(
|
||||
{ preventDefault } as unknown as Electron.Event,
|
||||
{
|
||||
type: 'mouseWheel',
|
||||
x: 0,
|
||||
y: 0,
|
||||
modifiers: [],
|
||||
deltaX: 0,
|
||||
deltaY: 120
|
||||
} as Electron.MouseWheelInputEvent
|
||||
)
|
||||
|
||||
expect(preventDefault).not.toHaveBeenCalled()
|
||||
expect(rendererSend).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { FAKE_RUNTIME_DIR } from './daemon-init-test-harness'
|
||||
|
||||
const {
|
||||
isPackagedMock,
|
||||
forkMock,
|
||||
isDaemonStaleForCurrentBundleMock,
|
||||
killStaleDaemonMock,
|
||||
daemonClientMock,
|
||||
spawnerInstances,
|
||||
importFresh,
|
||||
mockConnectedAdoptionClientOnce,
|
||||
installDefaultNetConnectStub,
|
||||
moduleFactories
|
||||
} = await vi.hoisted(async () =>
|
||||
(await import('./daemon-init-test-harness')).createDaemonInitMocks()
|
||||
)
|
||||
|
||||
vi.mock('fs', () => moduleFactories.fs())
|
||||
vi.mock('child_process', async (importOriginal) =>
|
||||
moduleFactories.childProcess(await importOriginal<Record<string, unknown>>())
|
||||
)
|
||||
vi.mock('net', () => moduleFactories.net())
|
||||
vi.mock('../../../health/daemon-health', () => moduleFactories.daemonHealth())
|
||||
vi.mock('../../../endpoint/identity/daemon-pid-identity', () => moduleFactories.daemonPidIdentity())
|
||||
vi.mock('../../../permissions/daemon-tcc-attribution', () => moduleFactories.daemonTccAttribution())
|
||||
vi.mock('../../../launch/daemon-bundle-staleness', () => moduleFactories.daemonBundleStaleness())
|
||||
vi.mock('../../../launch/daemon-stale-kill', () => moduleFactories.daemonStaleKill())
|
||||
vi.mock('../../../endpoint/identity/daemon-process-start-time', () =>
|
||||
moduleFactories.daemonProcessStartTime()
|
||||
)
|
||||
vi.mock('../../../endpoint/identity/daemon-pid-file-parse', () =>
|
||||
moduleFactories.daemonPidFileParse()
|
||||
)
|
||||
vi.mock('../../../transport/client/daemon-client', () => moduleFactories.client())
|
||||
vi.mock('../../../observability/daemon-lifecycle-event', () =>
|
||||
moduleFactories.daemonLifecycleEvent()
|
||||
)
|
||||
vi.mock('../../../launch/daemon-spawner', () => moduleFactories.daemonSpawner())
|
||||
vi.mock('../../adapter/daemon-pty-adapter', () => moduleFactories.daemonPtyAdapter())
|
||||
vi.mock('../../../../ipc/pty/provider/registry', () => moduleFactories.ptyProviderRegistry())
|
||||
vi.mock('../../../../ipc/pty/provider/listener-lifecycle', () =>
|
||||
moduleFactories.ptyListenerLifecycle()
|
||||
)
|
||||
|
||||
describe('daemon-init: runRestartDaemon (7-step sequence)', () => {
|
||||
beforeEach(() => {
|
||||
installDefaultNetConnectStub()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('preserves a packaged daemon that predates the current app bundle when it owns live sessions', async () => {
|
||||
const mod = await importFresh()
|
||||
await mod.initDaemonPtyProvider()
|
||||
|
||||
const requestMock = vi.fn(async (method: string) => {
|
||||
if (method === 'listSessions') {
|
||||
return {
|
||||
sessions: [{ sessionId: 'wt-1@@live', isAlive: true }]
|
||||
}
|
||||
}
|
||||
return {}
|
||||
})
|
||||
const disconnectMock = vi.fn()
|
||||
mockConnectedAdoptionClientOnce()
|
||||
daemonClientMock.mockImplementationOnce(function MockDaemonClient() {
|
||||
return {
|
||||
ensureConnected: vi.fn(async () => {}),
|
||||
ensureConnectedWithin: vi.fn(async () => {}),
|
||||
request: requestMock,
|
||||
disconnect: disconnectMock
|
||||
}
|
||||
})
|
||||
|
||||
const launcher = spawnerInstances[0].launcher as (
|
||||
socketPath: string,
|
||||
tokenPath: string
|
||||
) => Promise<{ shutdown(): Promise<void> }>
|
||||
isPackagedMock.mockReturnValue(true)
|
||||
isDaemonStaleForCurrentBundleMock.mockReturnValueOnce(true)
|
||||
|
||||
await launcher('/fake/socket', '/fake/token')
|
||||
|
||||
expect(isDaemonStaleForCurrentBundleMock).toHaveBeenCalledWith(
|
||||
FAKE_RUNTIME_DIR,
|
||||
'/fake/socket',
|
||||
'/fake/token',
|
||||
'1.2.3'
|
||||
)
|
||||
expect(requestMock).toHaveBeenCalledWith('listSessions', undefined, expect.any(Number))
|
||||
expect(disconnectMock).toHaveBeenCalledOnce()
|
||||
expect(killStaleDaemonMock).not.toHaveBeenCalled()
|
||||
expect(forkMock).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -1,101 +0,0 @@
|
||||
import type * as WorktreeScanCacheModule from '../../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import type * as WorktreeListingModule from '../../../git/worktrees/catalog/worktree-listing'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { makeStore } from '../../rpc/server/runtime-rpc-worktree-store-fixtures'
|
||||
import { spawnedPtyEnv } from './spawned-pty-env-fixtures'
|
||||
import { committingSpawn } from '../../orca-runtime-tests/bind-first-pane.test-fixture'
|
||||
import { partialRuntimeStore } from '../../orca-runtime-tests/runtime-store-partial-fixture'
|
||||
|
||||
// #10923: OMP user bubbles emit OSC 133 B C D;0; treating it as shell completion retires live hook/session authority.
|
||||
const OMP_TRANSCRIPT = readFileSync(
|
||||
join(__dirname, '..', '..', '__fixtures__/omp-user-bubble-osc133-zone.txt'),
|
||||
'utf8'
|
||||
)
|
||||
|
||||
vi.mock('../../../git/worktrees/catalog/worktree-scan-cache', async (importOriginal) => {
|
||||
const listings = getWorktreeListingMocks()
|
||||
return {
|
||||
...(await importOriginal<typeof WorktreeScanCacheModule>()),
|
||||
listWorktrees: listings.listWorktrees
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('../../../git/worktrees/catalog/worktree-listing', async (importOriginal) => {
|
||||
const listings = getWorktreeListingMocks()
|
||||
return {
|
||||
...(await importOriginal<typeof WorktreeListingModule>()),
|
||||
listWorktreesStrict: listings.listWorktreesStrict
|
||||
}
|
||||
})
|
||||
|
||||
const { getWorktreeListingMocks } = vi.hoisted(() => {
|
||||
function createWorktreeListingMocks() {
|
||||
const worktrees = [
|
||||
{
|
||||
path: '/tmp/worktree-omp',
|
||||
head: 'abc',
|
||||
branch: 'omp',
|
||||
isBare: false,
|
||||
isMainWorktree: false
|
||||
}
|
||||
]
|
||||
return {
|
||||
listWorktrees: vi.fn().mockResolvedValue(worktrees),
|
||||
listWorktreesStrict: vi.fn().mockResolvedValue(worktrees)
|
||||
}
|
||||
}
|
||||
let listings: ReturnType<typeof createWorktreeListingMocks> | undefined
|
||||
return { getWorktreeListingMocks: () => (listings ??= createWorktreeListingMocks()) }
|
||||
})
|
||||
|
||||
async function launchOmpPane(): Promise<{
|
||||
runtime: OrcaRuntimeService
|
||||
retire: ReturnType<typeof vi.fn>
|
||||
paneKey: string
|
||||
}> {
|
||||
const retire = vi.fn()
|
||||
const spawn = vi.fn(async (_args: { worktreeId?: string; tabId?: string; leafId?: string }) => ({
|
||||
id: 'pty-omp',
|
||||
incarnationId: 'incarnation-1'
|
||||
}))
|
||||
const runtime = new OrcaRuntimeService(partialRuntimeStore(makeStore()), undefined, {
|
||||
attestAgentHookCompatibilityAuthority: (candidate) => ({
|
||||
paneKey: candidate.paneKey,
|
||||
source: 'current_hook' as const
|
||||
}),
|
||||
retireAgentHookCompatibilityAuthority: retire
|
||||
})
|
||||
runtime.setPtyController({
|
||||
spawn: committingSpawn(runtime, spawn),
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => 'omp'
|
||||
})
|
||||
await runtime.createTerminal('path:/tmp/worktree-omp', {
|
||||
command: 'omp',
|
||||
launchConfig: { agentCommand: 'omp', agentArgs: '', agentEnv: {} },
|
||||
launchAgent: 'omp'
|
||||
})
|
||||
return { runtime, retire, paneKey: spawnedPtyEnv(spawn.mock.calls[0]?.[0]).ORCA_PANE_KEY }
|
||||
}
|
||||
|
||||
describe('OMP user bubbles and launch authority (#10923)', () => {
|
||||
it('keeps the pane authority through a real OMP turn', async () => {
|
||||
const { runtime, retire } = await launchOmpPane()
|
||||
let at = 100
|
||||
for (let index = 0; index < OMP_TRANSCRIPT.length; index += 512) {
|
||||
runtime.onPtyData('pty-omp', OMP_TRANSCRIPT.slice(index, index + 512), at++)
|
||||
}
|
||||
expect(retire).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('still retires it when the shell reports OMP exited', async () => {
|
||||
const { runtime, retire, paneKey } = await launchOmpPane()
|
||||
runtime.onPtyData('pty-omp', OMP_TRANSCRIPT, 100)
|
||||
runtime.onPtyData('pty-omp', '\x1b]133;D;0\x07\x1b]133;A\x07$ ', 101)
|
||||
expect(retire).toHaveBeenCalledWith(paneKey)
|
||||
})
|
||||
})
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { act, cleanup, render } from '@testing-library/react'
|
||||
import type { Dispatch, SetStateAction } from 'react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { BrowserChromeShortcutScope } from '../describe-page/browser-page-types'
|
||||
import { useBrowserPageFindShortcuts } from './use-browser-page-find-shortcuts'
|
||||
|
||||
// Why: Find is Cmd+F on macOS and Ctrl+F elsewhere, so the platform cannot be left to the runner.
|
||||
const MAC_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)'
|
||||
|
||||
function FindHarness({
|
||||
id,
|
||||
scope,
|
||||
setFindOpen
|
||||
}: {
|
||||
id: string
|
||||
scope: BrowserChromeShortcutScope
|
||||
setFindOpen: Dispatch<SetStateAction<boolean>>
|
||||
}): React.JSX.Element {
|
||||
useBrowserPageFindShortcuts({
|
||||
browserTabId: `page-${id}`,
|
||||
workspaceId: `workspace-${id}`,
|
||||
isActive: true,
|
||||
chromeShortcutScope: scope,
|
||||
setFindOpen
|
||||
})
|
||||
return (
|
||||
<div data-browser-overlay-tab-id={`workspace-${id}`}>
|
||||
<button type="button" data-testid={`toolbar-${id}`}>
|
||||
toolbar
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function renderFloatingOverSplit() {
|
||||
const split = vi.fn()
|
||||
const floating = vi.fn()
|
||||
render(
|
||||
<>
|
||||
<FindHarness id="a" scope="focused" setFindOpen={split} />
|
||||
<div data-floating-terminal-panel>
|
||||
<FindHarness id="floating" scope="owned-target-focused" setFindOpen={floating} />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
return { split, floating }
|
||||
}
|
||||
|
||||
function pressFind(testId: string): void {
|
||||
const target = document.querySelector(`[data-testid="${testId}"]`)
|
||||
act(() => {
|
||||
target?.dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'f', metaKey: true, bubbles: true, cancelable: true })
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
Object.defineProperty(navigator, 'userAgent', { configurable: true, value: MAC_USER_AGENT })
|
||||
Object.defineProperty(window, 'api', {
|
||||
configurable: true,
|
||||
value: { ui: { onFindInBrowserPage: () => () => {} } }
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
})
|
||||
|
||||
describe('useBrowserPageFindShortcuts with a floating browser over a focused split', () => {
|
||||
it('opens find only in the floating browser for a chord from its chrome', () => {
|
||||
const { split, floating } = renderFloatingOverSplit()
|
||||
|
||||
pressFind('toolbar-floating')
|
||||
|
||||
expect(floating).toHaveBeenCalledWith(true)
|
||||
expect(split).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('opens find only in the focused split for a chord from its chrome', () => {
|
||||
const { split, floating } = renderFloatingOverSplit()
|
||||
|
||||
pressFind('toolbar-a')
|
||||
|
||||
expect(split).toHaveBeenCalledWith(true)
|
||||
expect(floating).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user