test: remove duplicate scanner and key regressions (#43662)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-11-17 10:14:04 -08:00
committed by GitHub
co-authored by OrcaWin
parent 16e48d19d3
commit ee02433ffe
4 changed files with 1 additions and 123 deletions
@@ -515,7 +515,6 @@
"src/main/ai-vault/session-scanner-timeline.test.ts": 160,
"src/main/ai-vault/session-scanner-values.test.ts": 153,
"src/main/ai-vault/scanners/zcode/session-scanner-zcode.test.ts": 515,
"src/main/ai-vault/session-scanner.test.ts": 731,
"src/main/ai-vault/session-titles/session-title-file-reader-wsl-stall.test.ts": 284,
"src/main/ai-vault/transcripts/session-transcript-consumers.test.ts": 562,
"src/main/ai-vault/transcripts/session-transcript-every-agent-capture.test.ts": 856,
-101
View File
@@ -1,101 +0,0 @@
import { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { scanAiVaultSessions } from './session-scanner'
import { isolatedScanRoots, jsonLines } from './scanner-fixtures/session-scanner-test-fixtures'
// Use synchronous SQLite implementations because worker bundles are absent in the test runtime.
vi.mock(
'./scanners/opencode/reader-transport/session-scanner-opencode-sqlite-worker-spawn',
async () => {
const v1List = await import('./scanners/opencode/sqlite/session-scanner-opencode-sqlite-list')
const v1Parse = await import('./scanners/opencode/sqlite/session-scanner-opencode-sqlite')
const v2List = await import('./scanners/opencode2/session-scanner-opencode2-sqlite-list')
const v2Parse = await import('./scanners/opencode2/session-scanner-opencode2-sqlite')
return {
listOpenCodeSqliteSessionsViaWorker: (
args: Parameters<typeof v1List.listOpenCodeSqliteSessions>[0]
) => v1List.listOpenCodeSqliteSessions(args),
listZcodeSqliteSessionsViaWorker: (
args: Parameters<typeof v1List.listOpenCodeSqliteSessions>[0]
) => v1List.listOpenCodeSqliteSessions({ ...args, agent: 'zcode' }),
parseOpenCodeSqliteSessionViaWorker: (
args: Parameters<typeof v1Parse.parseOpenCodeSqliteSession>[0]
) => v1Parse.parseOpenCodeSqliteSession(args),
parseZcodeSqliteSessionViaWorker: (
args: Parameters<typeof v1Parse.parseOpenCodeSqliteSession>[0]
) => v1Parse.parseOpenCodeSqliteSession({ ...args, agent: 'zcode' }),
listOpenCode2SqliteSessionsViaWorker: (
args: Parameters<typeof v2List.listOpenCode2SqliteSessions>[0]
) => v2List.listOpenCode2SqliteSessions(args),
parseOpenCode2SqliteSessionViaWorker: (
args: Parameters<typeof v2Parse.parseOpenCode2SqliteSession>[0]
) => v2Parse.parseOpenCode2SqliteSession(args)
}
}
)
let tempRoots: string[] = []
afterEach(async () => {
vi.restoreAllMocks()
await Promise.all(tempRoots.map((root) => rm(root, { recursive: true, force: true })))
tempRoots = []
})
describe('scanAiVaultSessions', () => {
it('indexes Codex sessions from Orca runtime homes with resumable commands', async () => {
const root = await mkdtemp(join(tmpdir(), 'orca-ai-vault-codex-runtime-'))
tempRoots.push(root)
const roots = isolatedScanRoots(root)
const runtimeHome = join(root, 'codex-runtime-home', 'home')
const runtimeSessionsDir = join(runtimeHome, 'sessions')
await mkdir(join(runtimeSessionsDir, '2026', '06', '04'), { recursive: true })
await writeFile(
join(
runtimeSessionsDir,
'2026',
'06',
'04',
'rollout-2026-06-04T23-58-22-019e9693-64fc-7370-9c18-7e625c595d0f.jsonl'
),
jsonLines([
{
timestamp: '2026-06-04T23:58:22.000Z',
type: 'session_meta',
payload: {
id: '019e9693-64fc-7370-9c18-7e625c595d0f',
cwd: '/Users/nwparker/orca/workspaces/orca/mem4'
}
},
{
timestamp: '2026-06-04T23:58:23.000Z',
type: 'response_item',
payload: {
type: 'message',
role: 'user',
content: [{ type: 'text', text: 'Resume this managed Codex session' }]
}
}
])
)
const result = await scanAiVaultSessions({
...roots,
additionalCodexSessionsDirs: [runtimeSessionsDir],
platform: 'darwin'
})
expect(result.issues).toEqual([])
expect(result.sessions).toHaveLength(1)
expect(result.sessions[0]).toMatchObject({
agent: 'codex',
sessionId: '019e9693-64fc-7370-9c18-7e625c595d0f',
cwd: '/Users/nwparker/orca/workspaces/orca/mem4',
codexHome: runtimeHome,
resumeCommand: `cd '/Users/nwparker/orca/workspaces/orca/mem4' && CODEX_HOME='${runtimeHome}' codex resume '019e9693-64fc-7370-9c18-7e625c595d0f'`
})
})
})
@@ -28,20 +28,17 @@ describe('bounded Jira attachment downloads', () => {
const response = new Response(new ReadableStream({ cancel }), {
headers: { 'content-length': '9' }
})
const arrayBuffer = vi.spyOn(response, 'arrayBuffer')
fetchImage.mockResolvedValue(response)
await expect(jiraRequestBinary(client, '/image', { maxBytes: 8 })).rejects.toThrow('byte limit')
expect(cancel).toHaveBeenCalledOnce()
expect(arrayBuffer).not.toHaveBeenCalled()
expect(fetchImage.mock.calls[0]?.[1]?.signal?.aborted).toBe(true)
})
it('caps chunked bodies even when Content-Length is missing', async () => {
let part = 0
const cancel = vi.fn()
const response = new Response(
new ReadableStream({
pull(controller) {
controller.enqueue(Uint8Array.from([++part, 0, 0]))
controller.enqueue(Uint8Array.from([1, 0, 0]))
},
cancel
})
@@ -49,7 +46,6 @@ describe('bounded Jira attachment downloads', () => {
fetchImage.mockResolvedValue(response)
await expect(jiraRequestBinary(client, '/image', { maxBytes: 8 })).rejects.toThrow('byte limit')
expect(cancel).toHaveBeenCalledOnce()
expect(part).toBeLessThanOrEqual(4)
expect(fetchImage.mock.calls[0]?.[1]?.signal?.aborted).toBe(true)
})
it('returns complete bytes and releases its transport without aborting the caller', async () => {
@@ -36,7 +36,6 @@ vi.mock('../../shared/secure-storage/secure-file', () => ({
writeSecureFile: writeSecureFileMock
}))
const storePath = '/home/test/.orca/zcode-plan-api-key.enc'
const envelope = (kind: 'encrypted' | 'plaintext', value: string): string =>
`orca-zcode-plan-api-key:v1:${kind}:${Buffer.from(value, 'utf8').toString('base64')}`
@@ -69,21 +68,6 @@ describe('zcode-plan-api-key-store', () => {
expect(writeSecureFileMock).not.toHaveBeenCalled()
})
it('refuses to keep an unrestricted plaintext key when hardening fails', async () => {
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined)
safeStorageMock.isEncryptionAvailable.mockReturnValue(false)
writeSecureFileMock.mockReturnValue(false)
existsSyncMock.mockReturnValue(false)
readFileSyncMock.mockReturnValue(Buffer.from(envelope('plaintext', 'glm-secret')))
const store = await loadStore()
expect(() => store.saveZcodePlanApiKey('glm-secret')).toThrow(
'could not be stored securely on this device'
)
expect(rmSyncMock).toHaveBeenCalledWith(storePath, { force: true })
warn.mockRestore()
})
it('refuses to decrypt an encrypted envelope once safeStorage becomes unavailable', async () => {
safeStorageMock.isEncryptionAvailable.mockReturnValue(false)
existsSyncMock.mockReturnValue(true)