mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 19:34:29 +00:00
test: remove low-value input and native decoder checks
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -6285,7 +6285,6 @@
|
||||
"src/shared/claude-background-task-status.test.ts": 315,
|
||||
"src/shared/claude-model-list-probe.test.ts": 55,
|
||||
"src/shared/claude-shell-function.test.ts": 220,
|
||||
"src/shared/cli-runtime-pairing-inputs.test.ts": 64,
|
||||
"src/shared/cloud-service-url.test.ts": 37,
|
||||
"src/shared/coalescing-keyed-runner.test.ts": 119,
|
||||
"src/shared/codebuddy-agent.test.ts": 301,
|
||||
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package expo.modules.orcagziputf8codec
|
||||
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class StrictUtf8Test {
|
||||
@Test
|
||||
fun `hands back to JS what TextDecoder would repair or strip`() {
|
||||
val refused = listOf(
|
||||
byteArrayOf(0xef.toByte(), 0xbb.toByte(), 0xbf.toByte(), 0x41),
|
||||
byteArrayOf(0xc0.toByte(), 0x80.toByte()),
|
||||
byteArrayOf(0xed.toByte(), 0xa0.toByte(), 0x80.toByte()),
|
||||
byteArrayOf(0x41, 0xe2.toByte(), 0x82.toByte()),
|
||||
byteArrayOf(0x80.toByte()),
|
||||
byteArrayOf(0xf5.toByte(), 0x80.toByte(), 0x80.toByte(), 0x80.toByte())
|
||||
)
|
||||
for (bytes in refused) {
|
||||
assertNull(decodeStrictUtf8(bytes))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import Foundation
|
||||
// The codec's decisions, compiled and run without a device, from the module directory:
|
||||
//
|
||||
// swiftc -O -o /tmp/gzip-utf8-codec-checks ios/BoundedGunzip.swift \
|
||||
// ios/StrictUtf8.swift tests/GzipUtf8CodecChecks.swift && /tmp/gzip-utf8-codec-checks
|
||||
// tests/GzipUtf8CodecChecks.swift && /tmp/gzip-utf8-codec-checks
|
||||
@main struct GzipUtf8CodecChecks {
|
||||
static var failures = 0
|
||||
|
||||
@@ -37,14 +37,6 @@ import Foundation
|
||||
check(actual == expected, "gunzip: \(name)")
|
||||
}
|
||||
|
||||
let refused: [[UInt8]] = [
|
||||
[0xef, 0xbb, 0xbf, 0x41], [0xc0, 0x80], [0xed, 0xa0, 0x80], [0x41, 0xe2, 0x82], [0x80],
|
||||
[0xf5, 0x80, 0x80, 0x80],
|
||||
]
|
||||
for input in refused {
|
||||
check(decodeStrictUtf8(Data(input)) == nil, "utf8: refuses \(input)")
|
||||
}
|
||||
|
||||
print(failures == 0 ? "all checks passed" : "\(failures) check(s) failed")
|
||||
exit(failures == 0 ? 0 : 1)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
sourceShapedKimiOutput,
|
||||
realKimiOccupiedOutput
|
||||
} from '../../shared/__fixtures__/kimi-generation-source-shaped'
|
||||
import { realKimiOccupiedOutput } from '../../shared/__fixtures__/kimi-generation-source-shaped'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { createMockDiscoveryChild } from './commit-message-text-generation-test-harness'
|
||||
import { generateConversationNameFromContext } from './commit-message-text-generation'
|
||||
@@ -108,33 +105,4 @@ describe('generateConversationName', () => {
|
||||
cancelLocalGeneration('conversation-name', '/repo')
|
||||
expect(await pending).toMatchObject({ success: false, canceled: true })
|
||||
})
|
||||
|
||||
it.each(['custom', 'kimi'] as const)('%s local title', async (agentId) => {
|
||||
const child = createMockDiscoveryChild()
|
||||
const spawnAgent = vi.fn(() => {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: The test child implements every process member the generation lane reads.
|
||||
return child as unknown as SpawnedSourceControlAgentProcess
|
||||
})
|
||||
const pending = generateConversationName({
|
||||
context: { firstPrompt: 'Fix login' },
|
||||
params: { agentId, model: agentId === 'kimi' ? 'default' : '', customAgentCommand: 'agent' },
|
||||
target: { kind: 'local', cwd: '/repo' },
|
||||
spawnAgent
|
||||
})
|
||||
await vi.waitFor(() => expect(spawnAgent).toHaveBeenCalledOnce())
|
||||
child.stdout.emit(
|
||||
'data',
|
||||
Buffer.from(
|
||||
agentId === 'kimi'
|
||||
? sourceShapedKimiOutput('Title: "Fix login flow"')
|
||||
: 'Title: "Fix login flow"\n'
|
||||
)
|
||||
)
|
||||
child.emit('close', 0)
|
||||
expect(await pending).toEqual({
|
||||
success: true,
|
||||
name: 'Fix login flow',
|
||||
agentLabel: agentId === 'kimi' ? 'Kimi' : 'agent'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
import { act } from 'react'
|
||||
import { createRoot, type Root } from 'react-dom/client'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
summarizeContextUsage,
|
||||
type NativeChatContextUsageSummary
|
||||
} from '../../../../../shared/native-chat/native-chat-context-usage-summary'
|
||||
import type { NativeChatContextUsageSummary } from '../../../../../shared/native-chat/native-chat-context-usage-summary'
|
||||
|
||||
globalThis.IS_REACT_ACT_ENVIRONMENT = true
|
||||
|
||||
@@ -98,26 +95,6 @@ function pointer(type: 'pointerover' | 'pointerout', pointerType: string): Point
|
||||
}
|
||||
|
||||
describe('NativeChatContextUsageRing', () => {
|
||||
it('lists deferred rows apart from the used total, in tokens rather than a share of the window', async () => {
|
||||
const usage = summarizeContextUsage({
|
||||
usedTokens: 607_700,
|
||||
windowTokens: 1_000_000,
|
||||
percentage: 61,
|
||||
estimated: false,
|
||||
categories: [
|
||||
{ name: 'Messages', tokens: 589_000 },
|
||||
{ name: 'MCP tools (deferred)', tokens: 542_000, deferred: true },
|
||||
{ name: 'System prompt', tokens: 18_700 }
|
||||
]
|
||||
})
|
||||
await click(await renderRing(usage))
|
||||
|
||||
const groups = [...card()!.querySelectorAll('ul')].map((list) =>
|
||||
[...list.querySelectorAll('li')].map((row) => row.textContent)
|
||||
)
|
||||
expect(groups).toEqual([['Messages58.9%', 'System prompt1.9%'], ['MCP tools (deferred)542k']])
|
||||
})
|
||||
|
||||
it('stays open while the pointer crosses the gap from the ring into the card', async () => {
|
||||
const trigger = await renderRing()
|
||||
const hoverTarget = trigger.parentElement!
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
import * as fs from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { delimiter, join } from 'node:path'
|
||||
import { afterEach, describe, expect, it, onTestFinished, vi } from 'vitest'
|
||||
import { withCliRuntimeOnPath } from './node-cli-command-resolution'
|
||||
|
||||
const realFs = vi.hoisted((): { closeSync: typeof fs.closeSync } => ({
|
||||
closeSync: () => {
|
||||
throw new Error('real closeSync was not captured by the node:fs mock')
|
||||
}
|
||||
}))
|
||||
|
||||
vi.mock('node:fs', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof fs>()
|
||||
realFs.closeSync = actual.closeSync
|
||||
return { ...actual, closeSync: vi.fn(actual.closeSync), readSync: vi.fn(actual.readSync) }
|
||||
})
|
||||
|
||||
afterEach(() => vi.resetAllMocks())
|
||||
|
||||
describe('advisory executable inspection cleanup', () => {
|
||||
it.each([
|
||||
{ kind: 'native', contents: Buffer.from([0x7f, 0x45, 0x4c, 0x46]), readError: false },
|
||||
{ kind: 'script', contents: Buffer.from('#!/usr/bin/env node\n'), readError: false },
|
||||
{ kind: 'unreadable', contents: Buffer.from('#!/usr/bin/env node\n'), readError: true }
|
||||
])(
|
||||
'preserves $kind runtime pairing when close reports EIO after releasing the handle',
|
||||
(input) => {
|
||||
const root = fs.mkdtempSync(join(tmpdir(), 'orca-cli-close-'))
|
||||
onTestFinished(() => fs.rmSync(root, { recursive: true, force: true }))
|
||||
const command = join(root, 'codex')
|
||||
fs.writeFileSync(command, input.contents, { mode: 0o755 })
|
||||
fs.writeFileSync(join(root, process.platform === 'win32' ? 'node.exe' : 'node'), '', {
|
||||
mode: 0o755
|
||||
})
|
||||
if (input.readError) {
|
||||
vi.mocked(fs.readSync).mockImplementationOnce(() => {
|
||||
throw Object.assign(new Error('read failed'), { code: 'EIO' })
|
||||
})
|
||||
}
|
||||
let released = false
|
||||
vi.mocked(fs.closeSync).mockImplementationOnce((fd) => {
|
||||
realFs.closeSync(fd)
|
||||
released = true
|
||||
throw Object.assign(new Error('close failed'), { code: 'EIO' })
|
||||
})
|
||||
const env = { PATH: join(root, 'other-runtime'), ORCA_TEST_ENV: 'preserved' }
|
||||
const paired = withCliRuntimeOnPath(command, env)
|
||||
|
||||
expect(paired).toEqual(
|
||||
input.kind === 'native' ? env : { ...env, PATH: [root, env.PATH].join(delimiter) }
|
||||
)
|
||||
if (input.kind === 'native') {
|
||||
expect(paired).toBe(env)
|
||||
}
|
||||
expect(fs.closeSync).toHaveBeenCalledExactlyOnceWith(expect.any(Number))
|
||||
expect(released).toBe(true)
|
||||
}
|
||||
)
|
||||
})
|
||||
@@ -1,8 +1,5 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
TERMINAL_INPUT_TOO_LARGE_ERROR,
|
||||
assertTerminalInputWithinLimit,
|
||||
isTerminalInputTooLarge,
|
||||
isTerminalInputTooLargeWithDeferredMeasurement,
|
||||
isTerminalInputTooLargeWithYield,
|
||||
splitTerminalInputChunks
|
||||
@@ -29,21 +26,6 @@ describe('terminal input bounds', () => {
|
||||
expect(chunks.join('')).toBe('😀a')
|
||||
})
|
||||
|
||||
it('rejects oversized terminal input with a metadata-only error', () => {
|
||||
const secret = 'terminal-secret-token'
|
||||
const payload = [secret, 'payload'].join('')
|
||||
|
||||
expect(() => assertTerminalInputWithinLimit(payload, 4)).toThrow(TERMINAL_INPUT_TOO_LARGE_ERROR)
|
||||
expect(() => assertTerminalInputWithinLimit(payload, 4)).not.toThrow(secret)
|
||||
})
|
||||
|
||||
it('rejects multibyte oversized terminal input at the byte boundary', () => {
|
||||
expect(isTerminalInputTooLarge('😀'.repeat(3), 5)).toBe(true)
|
||||
expect(() => assertTerminalInputWithinLimit('😀'.repeat(3), 5)).toThrow(
|
||||
TERMINAL_INPUT_TOO_LARGE_ERROR
|
||||
)
|
||||
})
|
||||
|
||||
it('yields while measuring accepted large terminal input', async () => {
|
||||
vi.useFakeTimers()
|
||||
const text = 'é'.repeat(CLIPBOARD_TEXT_MEASURE_YIELD_CODE_UNITS + 1)
|
||||
|
||||
Reference in New Issue
Block a user