mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 18:37:24 +00:00
test: remove low-value smoke and fixture assertions
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -224,7 +224,6 @@
|
||||
"config/scripts/release/versioning/release-rc-history.test.mjs": 230,
|
||||
"config/scripts/release/workflow-contracts/release-windows-signing-gate.test.mjs": 102,
|
||||
"config/scripts/static-analysis/oxlint-contracts/renderer-scrollbar-style-plugin.test.mjs": 234,
|
||||
"config/scripts/static-analysis/renderer-styles/renderer-tailwind-sources.test.mjs": 289,
|
||||
"config/scripts/desktop-distribution/nsis/replace-cached-nsis-elevate.test.mjs": 1258,
|
||||
"config/scripts/ci/workflow-contracts/required-pr-check-name.test.mjs": 1266,
|
||||
"config/scripts/archives/seven-zip/resolve-7za-path.test.mjs": 1391,
|
||||
@@ -4066,7 +4065,6 @@
|
||||
"src/main/window/renderer-recovery-reload-watchdog.test.ts": 69,
|
||||
"src/main/window/runtime-renderer-notification-sender.test.ts": 54,
|
||||
"src/main/window/runtime-window-lifecycle-terminal-reveal.test.ts": 100,
|
||||
"src/main/window/runtime-window-pane-title-notification.test.ts": 97,
|
||||
"src/main/window/session-tab-close-request-relay.test.ts": 74,
|
||||
"src/main/window/terminal-tab-close-request-relay.test.ts": 64,
|
||||
"src/main/window/updater-package-recovery-ipc.test.ts": 169,
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
import {
|
||||
cpSync,
|
||||
mkdtempSync,
|
||||
mkdirSync,
|
||||
readFileSync,
|
||||
rmSync,
|
||||
symlinkSync,
|
||||
writeFileSync
|
||||
} from 'node:fs'
|
||||
import { createRequire } from 'node:module'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join, resolve } from 'node:path'
|
||||
import { expect, it } from 'vitest'
|
||||
|
||||
const require = createRequire(import.meta.resolve('@tailwindcss/vite'))
|
||||
const { compile } = require('@tailwindcss/node')
|
||||
const { Scanner } = require('@tailwindcss/oxide')
|
||||
|
||||
it('generates renderer CSS from production files while excluding test and spec files', async () => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'orca-tailwind-sources-'))
|
||||
try {
|
||||
const renderer = join(root, 'src', 'renderer', 'src')
|
||||
const assets = join(renderer, 'assets')
|
||||
cpSync(resolve('src/renderer/src/assets'), assets, { recursive: true })
|
||||
cpSync(resolve('src/shared/styles'), join(root, 'src', 'shared', 'styles'), { recursive: true })
|
||||
symlinkSync(resolve('node_modules'), join(root, 'node_modules'), 'junction')
|
||||
const components = join(renderer, 'components')
|
||||
mkdirSync(components)
|
||||
writeFileSync(join(components, 'example.tsx'), 'export const style = "z-[31415]"')
|
||||
writeFileSync(join(components, 'example.test.tsx'), 'export const style = "z-[27182]"')
|
||||
writeFileSync(join(components, 'example.spec.ts'), 'export const style = "z-[16180]"')
|
||||
|
||||
const compiler = await compile(readFileSync(join(assets, 'main.css'), 'utf8'), {
|
||||
base: assets,
|
||||
onDependency() {}
|
||||
})
|
||||
const automaticSources =
|
||||
compiler.root === 'none' ? [] : [compiler.root ?? { base: root, pattern: '**/*' }]
|
||||
const scanner = new Scanner({
|
||||
sources: [
|
||||
...automaticSources.map((source) => ({ ...source, negated: false })),
|
||||
...compiler.sources
|
||||
]
|
||||
})
|
||||
const css = compiler.build(scanner.scan())
|
||||
expect(css).toContain('z-index: 31415')
|
||||
expect(css).not.toContain('z-index: 27182')
|
||||
expect(css).not.toContain('z-index: 16180')
|
||||
|
||||
writeFileSync(join(components, 'added.tsx'), 'export const style = "z-[14142]"')
|
||||
expect(compiler.build(scanner.scan())).toContain('z-index: 14142')
|
||||
} finally {
|
||||
rmSync(root, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
@@ -50,14 +50,6 @@ describe('orca computer action CLI validation', () => {
|
||||
expect(process.exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('does not mask missing app with action target errors', async () => {
|
||||
await main(['computer', 'click'], '/tmp/repo/src')
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect(vi.mocked(console.error).mock.calls[0][0]).toContain('Missing required --app')
|
||||
expect(process.exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('rejects malformed hotkeys before calling the runtime', async () => {
|
||||
await main(
|
||||
['computer', 'hotkey', '--app', 'Finder', '--key', 'Return', '--json'],
|
||||
@@ -166,67 +158,6 @@ describe('orca computer action CLI validation', () => {
|
||||
expect(process.exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('rejects invalid window ids before calling the runtime', async () => {
|
||||
await main(
|
||||
['computer', 'get-app-state', '--app', 'Finder', '--window-id', '1.5', '--json'],
|
||||
'/tmp/repo/src'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
const output = JSON.parse(vi.mocked(console.log).mock.calls[0][0])
|
||||
expect(output.error).toMatchObject({
|
||||
code: 'invalid_argument',
|
||||
message: expect.stringContaining('Invalid non-negative integer for --window-id')
|
||||
})
|
||||
expect(process.exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('rejects conflicting action window target flags before calling the runtime', async () => {
|
||||
await main(
|
||||
[
|
||||
'computer',
|
||||
'click',
|
||||
'--app',
|
||||
'Finder',
|
||||
'--element-index',
|
||||
'1',
|
||||
'--window-id',
|
||||
'42',
|
||||
'--window-index',
|
||||
'0',
|
||||
'--json'
|
||||
],
|
||||
'/tmp/repo/src'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
const output = JSON.parse(vi.mocked(console.log).mock.calls[0][0])
|
||||
expect(output.error).toMatchObject({
|
||||
code: 'invalid_argument',
|
||||
message: expect.stringContaining('either --window-id or --window-index')
|
||||
})
|
||||
expect(process.exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('rejects invalid action flags before resolving the runtime target', async () => {
|
||||
await main(
|
||||
['computer', 'click', '--app', 'Finder', '--element-index', '1', '--click-count', '0'],
|
||||
'/tmp/repo/src'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect(vi.mocked(console.error).mock.calls[0][0]).toContain(
|
||||
'Invalid positive integer for --click-count'
|
||||
)
|
||||
expect(vi.mocked(console.error).mock.calls[0][0]).toContain(
|
||||
'Next step: Fix the command flags or RPC params exactly as described by the error message.'
|
||||
)
|
||||
expect(vi.mocked(console.error).mock.calls[0][0]).toContain(
|
||||
'Next step: Do not retry the same command unchanged.'
|
||||
)
|
||||
expect(process.exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('returns structured recovery data for local computer action flag errors in JSON mode', async () => {
|
||||
await main(
|
||||
[
|
||||
@@ -256,100 +187,6 @@ describe('orca computer action CLI validation', () => {
|
||||
expect(process.exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('rejects incomplete pointer action targets before resolving the runtime target', async () => {
|
||||
await main(['computer', 'click', '--app', 'Finder', '--x', '10'], '/tmp/repo/src')
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect(vi.mocked(console.error).mock.calls[0][0]).toContain(
|
||||
'Click requires --element-index or both --x and --y'
|
||||
)
|
||||
expect(process.exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('rejects unsupported action option values before resolving the runtime target', async () => {
|
||||
await main(
|
||||
['computer', 'click', '--app', 'Finder', '--element-index', '1', '--mouse-button', 'primary'],
|
||||
'/tmp/repo/src'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect(vi.mocked(console.error).mock.calls[0][0]).toContain('Unsupported --mouse-button')
|
||||
expect(process.exitCode).toBe(1)
|
||||
|
||||
vi.mocked(console.error).mockClear()
|
||||
process.exitCode = undefined
|
||||
|
||||
await main(
|
||||
[
|
||||
'computer',
|
||||
'click',
|
||||
'--app',
|
||||
'Finder',
|
||||
'--element-index',
|
||||
'1',
|
||||
'--modifiers',
|
||||
'CmdOrCtrl+A'
|
||||
],
|
||||
'/tmp/repo/src'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect(vi.mocked(console.error).mock.calls[0][0]).toContain(
|
||||
'Click modifiers accept modifier keys only'
|
||||
)
|
||||
expect(process.exitCode).toBe(1)
|
||||
|
||||
vi.mocked(console.error).mockClear()
|
||||
process.exitCode = undefined
|
||||
|
||||
await main(
|
||||
['computer', 'click', '--app', 'Finder', '--element-index', '1', '--modifiers', ''],
|
||||
'/tmp/repo/src'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect(vi.mocked(console.error).mock.calls[0][0]).toContain(
|
||||
'Click modifiers accept modifier keys only'
|
||||
)
|
||||
expect(process.exitCode).toBe(1)
|
||||
|
||||
vi.mocked(console.error).mockClear()
|
||||
process.exitCode = undefined
|
||||
|
||||
await main(
|
||||
['computer', 'scroll', '--app', 'Finder', '--element-index', '1', '--direction', 'diagonal'],
|
||||
'/tmp/repo/src'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect(vi.mocked(console.error).mock.calls[0][0]).toContain('Unsupported --direction')
|
||||
expect(process.exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('rejects incomplete drag targets before resolving the runtime target', async () => {
|
||||
await main(
|
||||
['computer', 'drag', '--app', 'Finder', '--from-element-index', '1'],
|
||||
'/tmp/repo/src'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect(vi.mocked(console.error).mock.calls[0][0]).toContain(
|
||||
'Drag element targeting requires both --from-element-index and --to-element-index'
|
||||
)
|
||||
expect(process.exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('rejects conflicting text payload flags before resolving the runtime target', async () => {
|
||||
await main(
|
||||
['computer', 'type-text', '--app', 'Finder', '--text', 'hello', '--text-stdin'],
|
||||
'/tmp/repo/src'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect(vi.mocked(console.error).mock.calls[0][0]).toContain('Use either --text or --text-stdin')
|
||||
expect(process.exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('rejects empty stdin for text actions before calling the runtime', async () => {
|
||||
const stdin = mockStdin(false, [])
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { RuntimeLinearCommandPorts } from './runtime-linear-command-base'
|
||||
import type { ResolvedWorktree } from '../../workspaces/catalog/runtime-worktree-path-identity'
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
import * as mutations from '../../../linear/issues/linear-issue-mutations'
|
||||
import * as comments from '../../../linear/issues/linear-issue-comments'
|
||||
@@ -333,69 +332,3 @@ it.each(['comment', 'attach', 'create'] as const)(
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
it('publishes successful command writes for each linked row with account identity intact', async () => {
|
||||
vi.mocked(mutations.updateIssueForAgent).mockResolvedValue({
|
||||
...issue,
|
||||
state: { id: 'done', name: 'Done' }
|
||||
})
|
||||
const base: ResolvedWorktree = {
|
||||
id: 'wt-1',
|
||||
repoId: 'repo',
|
||||
path: '/repo/wt-1',
|
||||
head: 'head',
|
||||
branch: 'branch',
|
||||
isBare: false,
|
||||
isMainWorktree: false,
|
||||
displayName: '',
|
||||
comment: '',
|
||||
linkedIssue: null,
|
||||
linkedPR: null,
|
||||
linkedLinearIssue: 'eng-1',
|
||||
linkedLinearIssueWorkspaceId: 'w1',
|
||||
isArchived: false,
|
||||
isUnread: false,
|
||||
isPinned: false,
|
||||
sortOrder: 0,
|
||||
lastActivityAt: 0,
|
||||
parentWorktreeId: null,
|
||||
childWorktreeIds: [],
|
||||
lineage: null,
|
||||
git: {
|
||||
path: '/repo/wt-1',
|
||||
head: 'head',
|
||||
branch: 'branch',
|
||||
isBare: false,
|
||||
isMainWorktree: false
|
||||
}
|
||||
}
|
||||
const emit = vi.fn()
|
||||
const c = commands(
|
||||
async () => [
|
||||
base,
|
||||
{ ...base, id: 'wt-2' },
|
||||
{ ...base, id: 'wrong-account', linkedLinearIssueWorkspaceId: 'w2' }
|
||||
],
|
||||
emit
|
||||
)
|
||||
await c.linearIssueSetState({ input: 'ENG-1', to: 'Done' })
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
expect(emit.mock.calls).toEqual([
|
||||
[
|
||||
{
|
||||
type: 'linearLinkedIssueUpdated',
|
||||
worktreeId: 'wt-1',
|
||||
identifier: 'ENG-1',
|
||||
workspaceId: 'w1'
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
type: 'linearLinkedIssueUpdated',
|
||||
worktreeId: 'wt-2',
|
||||
identifier: 'ENG-1',
|
||||
workspaceId: 'w1'
|
||||
}
|
||||
]
|
||||
])
|
||||
})
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
import { mkdtempSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { expect, it, vi } from 'vitest'
|
||||
import * as durable from '../../filesystem/durable-file-write'
|
||||
import { writeUsageSourceCache } from './usage-source-cache-file'
|
||||
|
||||
it('bounds source-cache write batches as one source grows from N to 10N events', async () => {
|
||||
const directory = mkdtempSync(join(tmpdir(), 'orca-usage-stream-contract-'))
|
||||
const receipts: { bytes: number; maximum: number; chunks: number }[] = []
|
||||
const write = vi
|
||||
.spyOn(durable, 'writeFileDurable')
|
||||
.mockImplementation(async (_tmp, _final, data) => {
|
||||
const receipt = { bytes: 0, maximum: 0, chunks: 0 }
|
||||
const chunks = typeof data === 'string' || data instanceof Uint8Array ? [data] : data
|
||||
for await (const chunk of chunks) {
|
||||
const bytes = typeof chunk === 'string' ? Buffer.byteLength(chunk) : chunk.byteLength
|
||||
receipt.bytes += bytes
|
||||
receipt.maximum = Math.max(receipt.maximum, bytes)
|
||||
receipt.chunks++
|
||||
}
|
||||
receipts.push(receipt)
|
||||
})
|
||||
try {
|
||||
for (const events of [10_000, 100_000]) {
|
||||
await writeUsageSourceCache(
|
||||
{
|
||||
path: join(directory, 'sources.json'),
|
||||
schemaVersion: 7,
|
||||
worktreeFingerprint: null,
|
||||
reuse: true
|
||||
},
|
||||
[
|
||||
{
|
||||
ownedEventKeys: Array.from(
|
||||
{ length: events },
|
||||
(_, index) => `turn-${index}|100000,50000,1000,0,101000|1000,500,10,0,1010`
|
||||
)
|
||||
}
|
||||
]
|
||||
)
|
||||
}
|
||||
for (const receipt of receipts) {
|
||||
// Output-sized work, with bounded batches and no awaited write per event.
|
||||
expect(receipt.maximum).toBeLessThanOrEqual(256 * 1024)
|
||||
expect(receipt.chunks).toBeLessThanOrEqual(Math.ceil(receipt.bytes / (32 * 1024)) + 1)
|
||||
}
|
||||
expect(receipts[1].bytes).toBeGreaterThan(receipts[0].bytes * 9)
|
||||
expect(receipts[1].chunks).toBeLessThanOrEqual(receipts[0].chunks * 11)
|
||||
} finally {
|
||||
write.mockRestore()
|
||||
rmSync(directory, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
@@ -1,141 +0,0 @@
|
||||
import { EventEmitter } from 'node:events'
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
import type { BrowserWindow } from 'electron'
|
||||
import type { OrcaRuntimeService } from '../runtime/orca-runtime'
|
||||
import { RuntimeClientEventBus } from '../runtime/client/events/runtime-client-event-bus'
|
||||
import { OrcaRuntimeWithApplyTrackedPtyTitle } from '../runtime/terminal/output/terminal-title-observation'
|
||||
|
||||
const { ipcMain, flags } = await vi.hoisted(async () => {
|
||||
const { EventEmitter } = await import('node:events')
|
||||
return { ipcMain: new EventEmitter(), flags: { sidebar: false } }
|
||||
})
|
||||
vi.mock('electron', () => ({ ipcMain }))
|
||||
vi.mock('../../shared/sidebar-inputs-switch', () => ({
|
||||
get ORCA_SIDEBAR_INPUTS_IS_MAIN() {
|
||||
return flags.sidebar
|
||||
}
|
||||
}))
|
||||
vi.mock('../ipc/worktrees/listing/worktree-change-invalidators', () => ({
|
||||
runWorktreeChangeInvalidators: vi.fn()
|
||||
}))
|
||||
vi.mock('./renderer-document-navigation', () => ({ registerRendererDocumentNavigation: vi.fn() }))
|
||||
import { registerRuntimeWindowLifecycle } from './runtime-window-lifecycle'
|
||||
afterEach(() => {
|
||||
ipcMain.removeAllListeners()
|
||||
flags.sidebar = false
|
||||
})
|
||||
|
||||
abstract class TerminalScanningProbe extends OrcaRuntimeWithApplyTrackedPtyTitle {
|
||||
public refreshScanningAvailability(): void {
|
||||
super.refreshTerminalSideEffectConsumerAvailability()
|
||||
}
|
||||
public setScanningAvailable(value: boolean): void {
|
||||
super.setTerminalSideEffectConsumerAvailable(value)
|
||||
}
|
||||
}
|
||||
|
||||
it.each([100, 1000])(
|
||||
'forwards only Linear notifications and releases its window at %i producers',
|
||||
(population) => {
|
||||
const trackers = Array.from({ length: population }, () => ({
|
||||
tracker: { setTransientSideEffectScanningEnabled: vi.fn() },
|
||||
commandCodeDetector: null
|
||||
}))
|
||||
const state = {
|
||||
terminalSideEffectLocalConsumerAvailable: false,
|
||||
terminalSideEffectConsumerAvailable: false,
|
||||
onTerminalSideEffects: () => {},
|
||||
ptyTitleTrackersByPtyId: new Map(trackers.map((tracker, i) => [String(i), tracker])),
|
||||
createTerminalSideEffectCommandCodeDetector: vi.fn(() => ({})),
|
||||
countTerminalSideEffectConsumingClientEventListeners: () =>
|
||||
bus.countTerminalSideEffectConsumers(),
|
||||
refreshTerminalSideEffectConsumerAvailability: () =>
|
||||
TerminalScanningProbe.prototype.refreshScanningAvailability.call(probe)
|
||||
}
|
||||
const bus = new RuntimeClientEventBus({
|
||||
makeTitleGateKey: (raw) => raw,
|
||||
onConsumerAvailabilityChanged: () => state.refreshTerminalSideEffectConsumerAvailability()
|
||||
})
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: these public test wrappers run only the production availability methods over their installed tracker/consumer fields.
|
||||
const probe = state as unknown as TerminalScanningProbe
|
||||
const available = (value: boolean) =>
|
||||
TerminalScanningProbe.prototype.setScanningAvailable.call(probe, value)
|
||||
const events = new EventEmitter()
|
||||
const send = vi.fn()
|
||||
const webContents = { on: vi.fn(), isDestroyed: () => false, send }
|
||||
const window = { id: 1, on: events.on.bind(events), isDestroyed: () => false, webContents }
|
||||
const runtime = {
|
||||
attachWindow: vi.fn(),
|
||||
setNotifier: vi.fn(),
|
||||
onClientEvent: bus.on.bind(bus),
|
||||
setAgentListPublication: vi.fn(),
|
||||
markGraphUnavailable: vi.fn()
|
||||
}
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the fixture implements the window registration's lifecycle and notification ports.
|
||||
registerRuntimeWindowLifecycle(
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: registration reads only the installed window lifecycle and notification ports.
|
||||
window as unknown as BrowserWindow,
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: registration exercises only these installed runtime event, graph and notifier ports.
|
||||
runtime as unknown as OrcaRuntimeService
|
||||
)
|
||||
expect(bus.countTerminalSideEffectConsumers()).toBe(0)
|
||||
available(true)
|
||||
available(false)
|
||||
expect(state.terminalSideEffectConsumerAvailable).toBe(false)
|
||||
expect(
|
||||
trackers.every(
|
||||
(entry) => entry.tracker.setTransientSideEffectScanningEnabled.mock.lastCall?.[0] === false
|
||||
)
|
||||
).toBe(true)
|
||||
for (let i = 0; i < population; i += 1) {
|
||||
bus.emit({ type: 'worktreesChanged', repoId: String(i) })
|
||||
}
|
||||
expect(send).toHaveBeenCalledTimes(0)
|
||||
const update = {
|
||||
type: 'linearLinkedIssueUpdated' as const,
|
||||
worktreeId: 'wt',
|
||||
identifier: 'ENG-1',
|
||||
workspaceId: 'w1'
|
||||
}
|
||||
bus.emit(update)
|
||||
expect(send.mock.calls).toEqual([['linear:linkedIssueUpdated', update]])
|
||||
events.emit('closed')
|
||||
bus.emit(update)
|
||||
expect(send).toHaveBeenCalledTimes(1)
|
||||
expect(bus.countTerminalSideEffectConsumers()).toBe(0)
|
||||
}
|
||||
)
|
||||
|
||||
it.each([false, true])('preserves the sidebar switch=%s beside Linear notices', (enabled) => {
|
||||
flags.sidebar = enabled
|
||||
const events = new EventEmitter()
|
||||
const send = vi.fn()
|
||||
const bus = new RuntimeClientEventBus({
|
||||
makeTitleGateKey: (raw) => raw,
|
||||
onConsumerAvailabilityChanged: () => {}
|
||||
})
|
||||
const runtime = {
|
||||
attachWindow: vi.fn(),
|
||||
setNotifier: vi.fn(),
|
||||
onClientEvent: bus.on.bind(bus),
|
||||
setAgentListPublication: vi.fn(),
|
||||
markGraphUnavailable: vi.fn()
|
||||
}
|
||||
const window = {
|
||||
id: 2,
|
||||
on: events.on.bind(events),
|
||||
isDestroyed: () => false,
|
||||
webContents: { on: vi.fn(), isDestroyed: () => false, send }
|
||||
}
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: only the installed lifecycle/notification ports are exercised.
|
||||
registerRuntimeWindowLifecycle(
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: only the installed window lifecycle and webContents ports are read.
|
||||
window as unknown as BrowserWindow,
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: registration exercises only these fixture runtime event and notifier ports.
|
||||
runtime as unknown as OrcaRuntimeService
|
||||
)
|
||||
const event = { type: 'sidebarInputsChanged' as const, generation: 'g', revision: 1 }
|
||||
bus.emit(event)
|
||||
expect(send.mock.calls).toEqual(enabled ? [['runtime:sidebarInputsChanged', event]] : [])
|
||||
events.emit('closed')
|
||||
})
|
||||
@@ -1,69 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import type { BrowserWindow } from 'electron'
|
||||
import type { OrcaRuntimeService } from '../runtime/orca-runtime'
|
||||
import type { RuntimeNotifier } from '../runtime/client/events/runtime-notifier-contract'
|
||||
|
||||
vi.mock('electron', () => ({ ipcMain: { on: vi.fn(), removeListener: vi.fn() } }))
|
||||
vi.mock('../ipc/worktrees/listing/worktree-change-invalidators', () => ({
|
||||
runWorktreeChangeInvalidators: vi.fn()
|
||||
}))
|
||||
vi.mock('./renderer-document-navigation', () => ({ registerRendererDocumentNavigation: vi.fn() }))
|
||||
vi.mock('./session-tab-close-request-relay', () => ({
|
||||
requestSessionTabCloseFromRenderer: vi.fn()
|
||||
}))
|
||||
vi.mock('./terminal-tab-close-request-relay', () => ({
|
||||
requestTerminalTabCloseFromRenderer: vi.fn()
|
||||
}))
|
||||
|
||||
import { registerRuntimeWindowLifecycle } from './runtime-window-lifecycle'
|
||||
|
||||
function attachNotifier() {
|
||||
const send = vi.fn()
|
||||
const markGraphReloadFailed = vi.fn()
|
||||
const attached: { notifier: RuntimeNotifier | null } = { notifier: null }
|
||||
const windowState = { destroyed: false }
|
||||
const mainWindow = {
|
||||
id: 1,
|
||||
isDestroyed: () => windowState.destroyed,
|
||||
on: vi.fn(),
|
||||
webContents: { isDestroyed: () => false, send, on: vi.fn() }
|
||||
}
|
||||
const runtime = {
|
||||
attachWindow: vi.fn(),
|
||||
onClientEvent: vi.fn(() => () => {}),
|
||||
markGraphReloadFailed,
|
||||
setNotifier: (next: RuntimeNotifier | null) => {
|
||||
attached.notifier = next
|
||||
}
|
||||
}
|
||||
registerRuntimeWindowLifecycle(
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: registration reads only the supplied window lifecycle and webContents members.
|
||||
mainWindow as unknown as BrowserWindow,
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: registration calls only the supplied runtime attachment and notification members.
|
||||
runtime as unknown as OrcaRuntimeService
|
||||
)
|
||||
if (!attached.notifier?.setPaneTitle) {
|
||||
throw new Error('pane-title notifier was not attached')
|
||||
}
|
||||
return { setPaneTitle: attached.notifier.setPaneTitle, send, windowState, markGraphReloadFailed }
|
||||
}
|
||||
|
||||
describe('pane title renderer emission receipts', () => {
|
||||
it('returns false without emitting to a destroyed desktop', () => {
|
||||
const { setPaneTitle, send, windowState } = attachNotifier()
|
||||
windowState.destroyed = true
|
||||
expect(setPaneTitle('tab-1', 'leaf-1', null)).toBe(false)
|
||||
expect(send).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('reports a disposed frame once and refuses subsequent emissions', () => {
|
||||
const { setPaneTitle, send, markGraphReloadFailed } = attachNotifier()
|
||||
send.mockImplementation(() => {
|
||||
throw new Error('disposed frame')
|
||||
})
|
||||
expect(setPaneTitle('tab-1', 'leaf-1', 'REVIEWER')).toBe(false)
|
||||
expect(setPaneTitle('tab-1', 'leaf-1', 'OTHER')).toBe(false)
|
||||
expect(send).toHaveBeenCalledTimes(1)
|
||||
expect(markGraphReloadFailed).toHaveBeenCalledExactlyOnceWith(1, 'renderer-frame-unavailable')
|
||||
})
|
||||
})
|
||||
-125
@@ -1,125 +0,0 @@
|
||||
/** @vitest-environment happy-dom */
|
||||
import { act, cleanup, render } from '@testing-library/react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { createTestStore, issue } from '@/store/slices/linear/linear-slice-test-harness'
|
||||
import { clearLinearRequestMaps } from '@/store/slices/linear/linear-slice-request-state'
|
||||
import type { TaskSourceContext } from '../../../../../../shared/work-items/task-source-context'
|
||||
import { useWorktreeCardLifecycleEffects } from './use-worktree-card-lifecycle-effects'
|
||||
|
||||
const requests = vi.hoisted(() => ({ detail: vi.fn() }))
|
||||
vi.mock('@/runtime/linear/runtime-linear-issue-client', async (original) => ({
|
||||
...(await original<Record<string, unknown>>()),
|
||||
linearGetIssue: requests.detail
|
||||
}))
|
||||
vi.mock('@/hooks/useIssueMetadata', () => ({ clearLinearMetadataCache: vi.fn() }))
|
||||
|
||||
type Store = ReturnType<typeof createTestStore>
|
||||
type CardProps = Parameters<typeof useWorktreeCardLifecycleEffects>[0]
|
||||
const source: TaskSourceContext = {
|
||||
kind: 'task-source',
|
||||
provider: 'linear',
|
||||
projectId: 'project',
|
||||
hostId: 'local'
|
||||
}
|
||||
|
||||
function LinkedIssueCard({
|
||||
store,
|
||||
id,
|
||||
sourceContext = source
|
||||
}: {
|
||||
store: Store
|
||||
id: string
|
||||
sourceContext?: TaskSourceContext
|
||||
}) {
|
||||
const props: CardProps = {
|
||||
worktree: {
|
||||
id,
|
||||
repoId: 'repo',
|
||||
path: `/repo/${id}`,
|
||||
displayName: id,
|
||||
comment: '',
|
||||
linkedIssue: null,
|
||||
linkedPR: null,
|
||||
linkedLinearIssue: id,
|
||||
isArchived: false,
|
||||
isUnread: false,
|
||||
isPinned: false,
|
||||
sortOrder: 0,
|
||||
lastActivityAt: 0,
|
||||
head: 'head',
|
||||
branch: 'branch',
|
||||
isBare: false,
|
||||
isMainWorktree: false
|
||||
},
|
||||
repo: undefined,
|
||||
isFolder: false,
|
||||
hostedReviewCacheKey: '',
|
||||
cachedBranchFallbackGitHubPRNumber: null,
|
||||
linkedGitLabMR: null,
|
||||
linkedBitbucketPR: null,
|
||||
linkedAzureDevOpsPR: null,
|
||||
linkedGiteaPR: null,
|
||||
branch: 'branch',
|
||||
fetchHostedReviewForBranch: vi.fn(),
|
||||
shouldRefreshHostedReview: false,
|
||||
newCardStyle: false,
|
||||
hoverDetailsOpen: false,
|
||||
showIssue: false,
|
||||
issueCacheKey: '',
|
||||
fetchIssue: vi.fn(),
|
||||
showLinearIssue: true,
|
||||
linearSourceContext: sourceContext,
|
||||
linearWorkspaceId: 'workspace',
|
||||
fetchLinearIssue: store.getState().fetchLinearIssue
|
||||
}
|
||||
useWorktreeCardLifecycleEffects(props)
|
||||
return null
|
||||
}
|
||||
|
||||
async function settle() {
|
||||
await act(async () => {
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
})
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers()
|
||||
vi.setSystemTime(new Date('2026-01-01T00:00:00Z'))
|
||||
vi.spyOn(document, 'visibilityState', 'get').mockReturnValue('visible')
|
||||
requests.detail.mockImplementation(async (_scope, id: string) => issue(id))
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
clearLinearRequestMaps()
|
||||
vi.restoreAllMocks()
|
||||
vi.clearAllMocks()
|
||||
vi.useRealTimers()
|
||||
})
|
||||
|
||||
describe('linked issue card demand', () => {
|
||||
it('bounds 100 mounted cards across 10 focus cycles over five minutes', async () => {
|
||||
const store = createTestStore()
|
||||
render(
|
||||
<>
|
||||
{Array.from({ length: 100 }, (_, index) => (
|
||||
<LinkedIssueCard key={index} id={`ISSUE-${index}`} store={store} />
|
||||
))}
|
||||
</>
|
||||
)
|
||||
await settle()
|
||||
expect(requests.detail).toHaveBeenCalledTimes(100)
|
||||
|
||||
for (let cycle = 0; cycle < 10; cycle += 1) {
|
||||
await act(async () => {
|
||||
await vi.advanceTimersByTimeAsync(30_000)
|
||||
})
|
||||
act(() => {
|
||||
window.dispatchEvent(new Event('focus'))
|
||||
document.dispatchEvent(new Event('visibilitychange'))
|
||||
})
|
||||
await settle()
|
||||
}
|
||||
expect(requests.detail).toHaveBeenCalledTimes(100)
|
||||
})
|
||||
})
|
||||
@@ -444,62 +444,6 @@ it('resolves direct SSH on the local endpoint without selecting a paired physica
|
||||
h.finishSetup()
|
||||
})
|
||||
|
||||
it('refreshes a linked folder badge on the local endpoint through its stored source', async () => {
|
||||
const h = harness([])
|
||||
const context = source('local', 'folder-project')
|
||||
useAppStore.setState({
|
||||
folderWorkspaces: [
|
||||
{
|
||||
id: 'f',
|
||||
projectGroupId: 'group',
|
||||
name: 'Folder',
|
||||
folderPath: '/folder',
|
||||
executionHostId: 'local',
|
||||
linkedTask: {
|
||||
provider: 'linear',
|
||||
type: 'issue',
|
||||
number: 0,
|
||||
linearIdentifier: 'eng-1',
|
||||
title: 'Issue',
|
||||
url: 'https://linear.app/issue/eng-1'
|
||||
},
|
||||
linkedTaskSourceContext: context,
|
||||
comment: '',
|
||||
isArchived: false,
|
||||
isUnread: false,
|
||||
isPinned: false,
|
||||
sortOrder: 0,
|
||||
lastActivityAt: 0,
|
||||
createdAt: 1,
|
||||
updatedAt: 1
|
||||
}
|
||||
]
|
||||
})
|
||||
const read = readLinearIssueForTest(
|
||||
useAppStore.getState().fetchLinearIssue('eng-1', 'all', { sourceContext: context })
|
||||
)
|
||||
h.pending[0].resolve(issue('eng-1'))
|
||||
await read
|
||||
const key = scopedLinearCacheKey(
|
||||
getLinearReadScope(useAppStore.getState().settings, context),
|
||||
'all::eng-1'
|
||||
)
|
||||
h.request.mockClear()
|
||||
h.pending.length = 0
|
||||
h.start()
|
||||
h.emit('folder:f')
|
||||
await settle()
|
||||
expect(h.request.mock.calls).toEqual([['local', 'eng-1', 'all']])
|
||||
h.pending[0].resolve({
|
||||
...issue('eng-1'),
|
||||
state: { name: 'Done', type: 'completed', color: '#888888' }
|
||||
})
|
||||
await settle()
|
||||
expect(useAppStore.getState().linearIssueCache[key].data?.state.name).toBe('Done')
|
||||
h.stop()
|
||||
h.finishSetup()
|
||||
})
|
||||
|
||||
it('does not refresh an unpinned all badge whose settled cached issue belongs to another account', async () => {
|
||||
const workspace = row('wt', source('local'))
|
||||
const h = harness([workspace])
|
||||
@@ -555,17 +499,6 @@ it.each([10, 100])(
|
||||
}
|
||||
)
|
||||
|
||||
it('does no badge work for unobserved rows or collection-only source scopes', async () => {
|
||||
const workspace = row('wt', source('local'))
|
||||
const h = harness([workspace])
|
||||
h.start()
|
||||
h.emit('wt')
|
||||
await settle()
|
||||
expect(h.request).not.toHaveBeenCalled()
|
||||
h.stop()
|
||||
h.finishSetup()
|
||||
})
|
||||
|
||||
it('preserves a pending initial badge read as demand for post-write force', async () => {
|
||||
const workspace = row('wt', source('local'))
|
||||
const h = harness([workspace])
|
||||
|
||||
@@ -217,22 +217,6 @@ it('invalidates lineage before unknown-repository discovery can block a structur
|
||||
}
|
||||
})
|
||||
|
||||
it('invalidates hydrated lineage as soon as a project change is queued', async () => {
|
||||
const h = createHarness()
|
||||
try {
|
||||
h.start()
|
||||
beginWorktreeLineageRefresh(useAppStore.getState, {
|
||||
kind: 'environment',
|
||||
environmentId: 'host-a'
|
||||
})(true)
|
||||
h.emit(0, false, { type: 'reposChanged' })
|
||||
expect(isRemoteWorktreeLineageFresh(useAppStore.getState, 'host-a')).toBe(false)
|
||||
expect(h.fetchRuntimeEnvironmentRepos).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
await h.finish()
|
||||
}
|
||||
})
|
||||
|
||||
it('does not mistake a local repo with the same id for the publishing remote repo', async () => {
|
||||
const h = createHarness()
|
||||
useAppStore.setState({
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import { afterAll, beforeAll, describe, expect, test } from 'vitest'
|
||||
import type {
|
||||
ComputerActionResult,
|
||||
ComputerListAppsResult,
|
||||
ComputerSnapshotResult
|
||||
} from '../../src/shared/runtime-types'
|
||||
import type { ComputerActionResult, ComputerSnapshotResult } from '../../src/shared/runtime-types'
|
||||
import {
|
||||
activateFinder,
|
||||
ensureOrcaRuntimeLaunched,
|
||||
@@ -31,22 +27,6 @@ describe.skipIf(!isMac || !e2eOptIn)('computer-use macOS e2e (TextEdit)', () =>
|
||||
await killTextEdit()
|
||||
})
|
||||
|
||||
test('list-apps includes TextEdit', async () => {
|
||||
const result = await runOrcaCli(['computer', 'list-apps', '--json'])
|
||||
const envelope = parseJsonOutput<{ result: ComputerListAppsResult }>(result.stdout)
|
||||
|
||||
expect(envelope.result.apps.some((app) => app.name === 'TextEdit')).toBe(true)
|
||||
})
|
||||
|
||||
test('get-app-state returns TextEdit state', async () => {
|
||||
const result = await runOrcaCli(['computer', 'get-app-state', '--app', 'TextEdit', '--json'])
|
||||
const envelope = parseJsonOutput<{ result: ComputerSnapshotResult }>(result.stdout)
|
||||
|
||||
expect(envelope.result.snapshot.app.name).toBe('TextEdit')
|
||||
expect(envelope.result.snapshot.elementCount).toBeGreaterThan(0)
|
||||
expect(envelope.result.snapshot.treeText).toContain('Window:')
|
||||
})
|
||||
|
||||
test('click, type-text, and re-observe show inserted text', async () => {
|
||||
const before = parseJsonOutput<{ result: ComputerSnapshotResult }>(
|
||||
(await runOrcaCli(['computer', 'get-app-state', '--app', 'TextEdit', '--json'])).stdout
|
||||
@@ -261,15 +241,4 @@ describe.skipIf(!isMac || !e2eOptIn)('computer-use macOS e2e (TextEdit)', () =>
|
||||
expect(after.result.snapshot.treeText).toContain(marker)
|
||||
expect(after.result.snapshot.treeText).not.toContain('orca unfocused first')
|
||||
})
|
||||
|
||||
test('screenshot capture returns image metadata', async () => {
|
||||
const result = await runOrcaCli(['computer', 'get-app-state', '--app', 'TextEdit', '--json'])
|
||||
const envelope = parseJsonOutput<{ result: ComputerSnapshotResult }>(result.stdout)
|
||||
|
||||
expect(envelope.result.screenshotStatus.state).toBe('captured')
|
||||
expect(envelope.result.screenshot?.format).toBe('png')
|
||||
expect(envelope.result.screenshot?.data).toBeUndefined()
|
||||
expect(envelope.result.screenshot?.dataOmitted).toBe(true)
|
||||
expect(envelope.result.screenshot?.path).toContain('orca-computer-use')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user