test: remove low-value native input, renderer and SQLite tests (#43596)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-11-17 05:05:59 -08:00
committed by GitHub
co-authored by OrcaWin
parent 787138074a
commit fa700641aa
5 changed files with 5 additions and 187 deletions
@@ -3,25 +3,6 @@ import XCTest
@testable import OrcaComputerUseMacOSCore
final class BackgroundInputTransportTests: XCTestCase {
private let target = BackgroundInputTransport.Target(
pid: 4242,
windowID: 9001,
windowFrame: CGRect(x: 300, y: 200, width: 520, height: 560)
)
func testMouseEventsNameTheWindowAndCarryAWindowLocalLocation() throws {
try XCTSkipUnless(BackgroundInputTransport.isAvailable, "private symbols missing: \(BackgroundInputTransport.missingSymbols)")
let point = CGPoint(x: 340, y: 275)
for type in [CGEventType.leftMouseDown] {
let event = try BackgroundInputTransport.mouseEvent(type, target: target, at: point, button: .left, clickState: 2, flags: .maskCommand)
XCTAssertEqual(event.getIntegerValueField(CGEventField(rawValue: 51)!), 9001, "\(type)")
XCTAssertEqual(try windowLocation(of: event), CGPoint(x: 40, y: 75), "\(type)")
XCTAssertEqual(event.location, point)
XCTAssertEqual(event.getIntegerValueField(.mouseEventClickState), 2)
XCTAssertTrue(event.flags.contains(.maskCommand))
}
}
func testTypedTextRidesTheKeyDownOnly() throws {
let bareKeyUp = try XCTUnwrap(CGEvent(keyboardEventSource: nil, virtualKey: 0, keyDown: false))
for (text, characters) in [("🚀e\u{301}👩‍💻", ["🚀", "e\u{301}", "👩‍💻"])] {
@@ -35,14 +16,6 @@ final class BackgroundInputTransportTests: XCTestCase {
}
}
private func windowLocation(of event: CGEvent) throws -> CGPoint {
let skyLight = dlopen("/System/Library/PrivateFrameworks/SkyLight.framework/SkyLight", RTLD_LAZY)
let symbol = try XCTUnwrap(dlsym(skyLight, "CGEventGetWindowLocation"))
typealias GetWindowLocation = @convention(c) (CGEvent) -> CGPoint
// SAFETY: CGEventGetWindowLocation takes a CGEventRef and returns a CGPoint.
return unsafeBitCast(symbol, to: GetWindowLocation.self)(event)
}
private func unicodeString(_ event: CGEvent) -> String {
var length = 0
var buffer = [UniChar](repeating: 0, count: 8)
@@ -2,7 +2,6 @@ import { mkdtempSync, rmSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import type { AiVaultScanIssue } from '../../../../../shared/ai-vault/contracts/ai-vault-types'
import Database from '../../../../sqlite/sync-database'
import { buildOpenCodeSqliteCandidatePath } from '../../../../../shared/agent-session/lifecycle/provider-handles/opencode-sqlite-session-path'
import { listOpenCodeSqliteSessions } from './session-scanner-opencode-sqlite-list'
@@ -132,26 +131,6 @@ describe('listOpenCodeSqliteSessions — LIMIT-first discovery', () => {
])
expect(candidates[0].file.mtimeMs).toBe(1_777_634_003_000)
})
it('lists a session despite a malformed unused message payload', async () => {
const { db, path } = createTempDb()
applySchema(db)
insertSession(db, 'ses_candidate', 1_777_634_001_000)
db.prepare(`INSERT INTO message (id, session_id, time_created, data) VALUES (?, ?, ?, ?)`).run(
'msg_malformed',
'ses_candidate',
1_777_634_000_500,
'malformed JSON'
)
db.close()
const issues: AiVaultScanIssue[] = []
const candidates = await listOpenCodeSqliteSessions({ dbPaths: [path], limit: 10, issues })
expect(candidates.map((candidate) => candidate.file.path)).toEqual([
buildOpenCodeSqliteCandidatePath(path, 'ses_candidate')
])
expect(issues).toEqual([])
})
})
describe('parseOpenCodeSqliteSession — bounded preview window', () => {
@@ -184,46 +163,6 @@ describe('parseOpenCodeSqliteSession — bounded preview window', () => {
expect(previewText).toContain('recent text 104')
})
it('excludes user text whose message falls outside the newest-100 window', async () => {
// Fill the recent window with non-text parts so stale text can surface only if the window is ignored.
const { db, path } = createTempDb()
applySchema(db)
const base = 1_777_634_000_000
insertSession(db, 'ses_window', base + 500_000)
for (let i = 0; i < 3; i++) {
insertMessageWithPart(db, {
id: `old_${i}`,
sessionId: 'ses_window',
timeCreated: base + i * 100,
role: 'user',
partType: 'text',
text: `OLD_USER_TEXT_${i}`
})
}
for (let i = 0; i < 100; i++) {
insertMessageWithPart(db, {
id: `new_${String(i).padStart(3, '0')}`,
sessionId: 'ses_window',
timeCreated: base + 10_000 + i * 100,
role: 'assistant',
partType: 'tool',
text: `tool output ${i}`
})
}
db.close()
const session = await parseOpenCodeSqliteSession({
dbPath: path,
sessionId: 'ses_window',
platform: 'darwin'
})
expect(session).not.toBeNull()
expect(session!.messageCount).toBe(103)
expect(session!.previewMessages).toHaveLength(0)
expect(session!.previewMessages.map((m) => m.text)).not.toContain('OLD_USER_TEXT_0')
})
it('counts only user/assistant messages, ignoring tool/system rows', async () => {
const { db, path } = createTempDb()
applySchema(db)
@@ -52,43 +52,32 @@ function seededDatabase(name: string, sessionId: string): string {
return path
}
// SQLite busy waits block the thread, so only another thread can release the lock during a read.
const LOCK_HOLDER_SOURCE = `
const { parentPort, workerData } = require('node:worker_threads')
const { DatabaseSync } = require('node:sqlite')
const db = new DatabaseSync(workerData.path)
db.exec('BEGIN EXCLUSIVE')
db.exec("INSERT INTO session (id, time_created, time_updated) VALUES ('locked-write', 1, 1)")
parentPort.ref()
parentPort.postMessage('locked')
parentPort.once('message', (message) => {
if (message !== 'reader-started') {
throw new Error('Unexpected lock-holder message')
}
setTimeout(() => {
db.exec('ROLLBACK')
db.close()
parentPort.postMessage('released')
}, workerData.releaseDelayMs)
})
`
async function holdWriteLock(path: string, releaseDelayMs: number): Promise<Worker> {
async function holdWriteLock(path: string): Promise<void> {
const worker = new Worker(LOCK_HOLDER_SOURCE, {
eval: true,
workerData: { path, releaseDelayMs }
workerData: { path }
})
lockHolders.push(worker)
await new Promise<void>((resolve, reject) => {
worker.once('message', () => resolve())
worker.once('error', reject)
})
return worker
}
describe('listOpenCodeSqliteSessions against a database OpenCode is writing to', () => {
it('reports the failure as a whole source, not as a skipped transcript', async () => {
const path = seededDatabase('opencode.db', 'session-a')
await holdWriteLock(path, 60_000)
await holdWriteLock(path)
const issues: AiVaultScanIssue[] = []
const candidates = await listOpenCodeSqliteSessions({ dbPaths: [path], limit: 10, issues })
@@ -103,7 +92,7 @@ describe('listOpenCodeSqliteSessions against a database OpenCode is writing to',
it('still returns sessions from every other database', async () => {
const contended = seededDatabase('opencode.db', 'session-a')
const healthy = seededDatabase('opencode-alt.db', 'session-b')
await holdWriteLock(contended, 60_000)
await holdWriteLock(contended)
const issues: AiVaultScanIssue[] = []
const candidates = await listOpenCodeSqliteSessions({
@@ -116,19 +105,6 @@ describe('listOpenCodeSqliteSessions against a database OpenCode is writing to',
expect(candidates[0]?.file.path).toContain('session-b')
expect(issues).toHaveLength(1)
})
it('reads the sessions once the write finishes inside the busy timeout', async () => {
const path = seededDatabase('opencode.db', 'session-a')
const worker = await holdWriteLock(path, 200)
const issues: AiVaultScanIssue[] = []
worker.postMessage('reader-started')
const candidates = await listOpenCodeSqliteSessions({ dbPaths: [path], limit: 10, issues })
expect(issues).toEqual([])
expect(candidates).toHaveLength(1)
expect(candidates[0]?.file.path).toContain('session-a')
})
})
describe('readOpenCodeDatabase', () => {
@@ -174,18 +150,6 @@ describe('readOpenCodeDatabase', () => {
}
})
it('keeps the query-only guard enabled for successful reads', () => {
const path = seededDatabase('opencode.db', 'session-a')
readOpenCodeDatabase({
dbPath: path,
read: (db) => {
expect(db.pragma('query_only', { simple: true })).toBe(1)
expect(() => db.exec('DELETE FROM session')).toThrow(/readonly/i)
expect(db.prepare('SELECT id FROM session').all()).toEqual([{ id: 'session-a' }])
}
})
})
it('closes the handle when the read throws', () => {
const path = seededDatabase('opencode.db', 'session-a')
let captured: Database.Database | null = null
@@ -40,20 +40,6 @@ describe('remote browser authoritative page state', () => {
expect(useAppStore.getState().browserCertificateFailuresByPageId['page-a']).toBeUndefined()
})
it('redacts a Kagi session token before it reaches history', () => {
const { result } = renderNavigation()
act(() =>
result.current.applyRemoteTabInfo({
browserPageId: 'remote-page-a',
index: 0,
active: true,
url: 'https://kagi.com/search?q=orca&token=secret-session',
title: 'Kagi'
})
)
expect(useAppStore.getState().browserUrlHistory[0].url).not.toContain('secret-session')
})
it.each(['browser.goto', 'browser.back', 'browser.forward', 'browser.reload'] as const)(
'reads authoritative state after %s rejects or resolves, without a pre-command read',
async (method) => {
@@ -155,32 +155,6 @@ describe('notebook kernel session', () => {
expect(getSession(FILE)).toMatchObject({ status: 'off', setup: null, queue: [] })
})
it('creates a .venv for a pip-locked Python and runs the waiting cells in it', async () => {
const created = { path: '/repo/.venv/bin/python', name: '.venv', version: '3.14.0' }
const system = { path: '/opt/homebrew/bin/python3', name: 'python3', version: '3.14.0' }
openFiles.current = [{ filePath: '/repo/nb.ipynb' }]
notebookApi.listPythonEnvironments.mockResolvedValue({ workspace: [], path: [system] })
notebookApi.startKernel.mockResolvedValueOnce({
status: 'missing-ipykernel',
externallyManaged: true
})
notebookApi.createVenv.mockResolvedValue({ ok: true, environment: created })
await session.runCells('/repo/nb.ipynb', [{ key: 'a', code: 'x' }], '/repo')
expect(getSession('/repo/nb.ipynb').setup).toMatchObject({ base: system, offer: 'venv' })
await session.createVirtualEnvironment('/repo/nb.ipynb', '/repo')
expect(notebookApi.createVenv).toHaveBeenCalledWith({
filePath: '/repo/nb.ipynb',
rootPath: '/repo',
python: system.path
})
expect(notebookApi.startKernel).toHaveBeenLastCalledWith({
filePath: '/repo/nb.ipynb',
python: created.path
})
expect(notebookApi.execute).toHaveBeenCalledWith({ filePath: '/repo/nb.ipynb', code: 'x' })
})
it('switches a running notebook to a venv made from the picker, keeping it on failure', async () => {
const created = { path: '/repo/.venv/bin/python', name: '.venv', version: '3.14.0' }
const system = { path: '/usr/bin/python3', name: 'python3', version: '3.14.0' }
@@ -216,24 +190,6 @@ describe('notebook kernel session', () => {
expect(notebookApi.execute).toHaveBeenCalledWith({ filePath: FILE, code: 'x' })
})
it('drops an install result once its tab has closed and reopened', async () => {
notebookApi.startKernel.mockResolvedValueOnce({
status: 'missing-ipykernel',
externallyManaged: false
})
let finish: (value: { ok: boolean; detail: string }) => void = () => {}
notebookApi.installIpykernel.mockReturnValue(new Promise((resolve) => (finish = resolve)))
await session.runCells(FILE, [{ key: 'a', code: 'x' }], null)
const install = session.installIpykernel(FILE)
for (const listener of appStoreListeners) {
listener({ openFiles: [] }, { openFiles: openFiles.current })
}
finish({ ok: false, detail: 'late' })
await install
expect(getSession(FILE).setup).toBeNull()
expect(notebookApi.startKernel).toHaveBeenCalledOnce()
})
it('starts one kernel when a second run lands during discovery', async () => {
openFiles.current = [{ filePath: '/third.ipynb' }]
await Promise.all([