mirror of
https://github.com/stablyai/orca.git
synced 2026-11-14 01:47:24 +00:00
test: remove 65 low-value tests (#39491)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -48,64 +48,6 @@ function json(response: ServerResponse, value: unknown) {
|
||||
response.end(JSON.stringify(value))
|
||||
}
|
||||
|
||||
it('v1 applies ordered session authority and preserves the selected native prompt', async () => {
|
||||
const requests = new Map<string, unknown>()
|
||||
const url = await fixture((path, body, response) => {
|
||||
requests.set(path, body)
|
||||
if (path.startsWith('GET /agent?')) {
|
||||
json(response, [{ name: 'configured-agent', mode: 'primary' }])
|
||||
} else if (path.startsWith('POST /session?')) {
|
||||
json(response, { id: 'ses_v1', permission: appliedV1Policy })
|
||||
} else if (path.startsWith('POST /session/ses_v1/message?')) {
|
||||
json(response, {
|
||||
info: {},
|
||||
parts: [
|
||||
{ type: 'reasoning', text: 'private' },
|
||||
{ type: 'text', text: 'Harbor Lantern' }
|
||||
]
|
||||
})
|
||||
} else {
|
||||
json(response, true)
|
||||
}
|
||||
})
|
||||
await expect(
|
||||
runOpenCodeTextTaskSession({
|
||||
version: 'v1',
|
||||
v1SessionPolicyFiltersTools: true,
|
||||
url,
|
||||
password: 'test',
|
||||
directory: '/workspace with spaces',
|
||||
prompt: 'Name this chat',
|
||||
agent: 'configured-agent',
|
||||
model: { providerID: 'opencode', modelID: 'crouton-alpha-free' },
|
||||
variant: 'low',
|
||||
signal: new AbortController().signal
|
||||
})
|
||||
).resolves.toBe('Harbor Lantern')
|
||||
expect(requests.get('POST /session?directory=%2Fworkspace%20with%20spaces')).toEqual({
|
||||
title: expect.stringMatching(/^Orca text generation /),
|
||||
agent: 'configured-agent',
|
||||
permission: [
|
||||
{ permission: '*', pattern: '*', action: 'deny' },
|
||||
{ permission: 'read', pattern: '*', action: 'allow' },
|
||||
{ permission: 'grep', pattern: '*', action: 'allow' },
|
||||
{ permission: 'glob', pattern: '*', action: 'allow' },
|
||||
{ permission: 'external_directory', pattern: '*', action: 'allow' },
|
||||
{ permission: 'read', pattern: 'mcp:*', action: 'deny' }
|
||||
]
|
||||
})
|
||||
expect(
|
||||
requests.get('POST /session/ses_v1/message?directory=%2Fworkspace%20with%20spaces')
|
||||
).toEqual({
|
||||
messageID: expect.stringMatching(/^msg_[0-9a-f]{12}[0-9A-Za-z]{14}$/),
|
||||
model: { providerID: 'opencode', modelID: 'crouton-alpha-free' },
|
||||
agent: 'configured-agent',
|
||||
variant: 'low',
|
||||
parts: [{ type: 'text', text: 'Name this chat' }]
|
||||
})
|
||||
expect(requests.has('DELETE /session/ses_v1?directory=%2Fworkspace%20with%20spaces')).toBe(true)
|
||||
})
|
||||
|
||||
it('v2 rejects an unexpected permission and reads final text across fragmented CRLF events', async () => {
|
||||
let events: ServerResponse | undefined
|
||||
const requests = new Map<string, unknown>()
|
||||
@@ -207,55 +149,6 @@ it('recovers and deletes an owned session when cancelled during creation without
|
||||
expect(requests).not.toContain('POST /api/session/ses_late/prompt')
|
||||
})
|
||||
|
||||
it('uses the native v1 command endpoint with its arguments and selected model', async () => {
|
||||
const requests = new Map<string, unknown>()
|
||||
const url = await fixture((path, body, response) => {
|
||||
requests.set(path, body)
|
||||
if (path.startsWith('POST /session?')) {
|
||||
json(response, { id: 'ses_command', permission: appliedV1Policy })
|
||||
} else if (path.startsWith('GET /command?')) {
|
||||
json(response, [{ name: 'review', agent: 'reviewer' }])
|
||||
} else if (path.startsWith('GET /agent?')) {
|
||||
json(response, [
|
||||
{ name: 'reviewer', mode: 'primary' },
|
||||
{ name: 'build', mode: 'primary' }
|
||||
])
|
||||
} else if (path.startsWith('POST /session/ses_command/command?')) {
|
||||
json(response, {
|
||||
info: {},
|
||||
parts: [{ type: 'text', text: 'Harbor Lantern' }]
|
||||
})
|
||||
} else {
|
||||
json(response, true)
|
||||
}
|
||||
})
|
||||
await expect(
|
||||
runOpenCodeTextTaskSession({
|
||||
version: 'v1',
|
||||
v1SessionPolicyFiltersTools: true,
|
||||
url,
|
||||
password: 'test',
|
||||
directory: '/workspace',
|
||||
prompt: 'extra\ngenerated',
|
||||
command: 'review',
|
||||
agent: 'build',
|
||||
title: 'Recipe',
|
||||
model: { providerID: 'opencode', modelID: 'crouton-alpha-free' },
|
||||
variant: 'low',
|
||||
signal: new AbortController().signal
|
||||
})
|
||||
).resolves.toBe('Harbor Lantern')
|
||||
expect(requests.get('POST /session/ses_command/command?directory=%2Fworkspace')).toEqual({
|
||||
messageID: expect.stringMatching(/^msg_[0-9a-f]{12}[0-9A-Za-z]{14}$/),
|
||||
command: 'review',
|
||||
arguments: 'extra\ngenerated',
|
||||
agent: 'build',
|
||||
model: 'opencode/crouton-alpha-free',
|
||||
variant: 'low'
|
||||
})
|
||||
expect(requests.has('POST /session/ses_command/message?directory=%2Fworkspace')).toBe(false)
|
||||
})
|
||||
|
||||
it('preserves a completed title when deleting its session fails', async () => {
|
||||
const warning = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
||||
const url = await fixture((path, _body, response) => {
|
||||
@@ -284,126 +177,6 @@ it('preserves a completed title when deleting its session fails', async () => {
|
||||
}
|
||||
})
|
||||
|
||||
it.each(['', 'missing', 'explore'])(
|
||||
'v1 preserves default-agent fallback for %j in a normal command',
|
||||
async (agent) => {
|
||||
let submitted: unknown
|
||||
const url = await fixture((path, body, response) => {
|
||||
if (path.startsWith('GET /agent?')) {
|
||||
json(response, [
|
||||
{ name: 'explore', mode: 'subagent' },
|
||||
{ name: 'build', mode: 'primary' }
|
||||
])
|
||||
} else if (path.startsWith('GET /command?')) {
|
||||
json(response, [{ name: 'review' }])
|
||||
} else if (path.startsWith('POST /session?')) {
|
||||
json(response, { id: 'ses_default', permission: appliedV1Policy })
|
||||
} else if (path.startsWith('POST /session/ses_default/command?')) {
|
||||
submitted = body
|
||||
json(response, { info: {}, parts: [{ type: 'text', text: 'Harbor Lantern' }] })
|
||||
} else {
|
||||
json(response, true)
|
||||
}
|
||||
})
|
||||
await expect(
|
||||
runOpenCodeTextTaskSession({
|
||||
version: 'v1',
|
||||
v1SessionPolicyFiltersTools: true,
|
||||
url,
|
||||
password: 'test',
|
||||
directory: '/workspace',
|
||||
prompt: 'input',
|
||||
command: 'review',
|
||||
agent,
|
||||
signal: new AbortController().signal
|
||||
})
|
||||
).resolves.toBe('Harbor Lantern')
|
||||
expect(submitted).toEqual({
|
||||
command: 'review',
|
||||
arguments: 'input',
|
||||
messageID: expect.stringMatching(/^msg_[0-9a-f]{12}[0-9A-Za-z]{14}$/)
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
it.each([
|
||||
{
|
||||
resume: false,
|
||||
command: undefined,
|
||||
parentID: 'msg_compaction_continue',
|
||||
title: 'Harbor Lantern'
|
||||
},
|
||||
{ resume: true, command: undefined, parentID: 'msg_replay', title: 'Harbor Lantern' },
|
||||
{
|
||||
resume: false,
|
||||
command: 'inspect',
|
||||
parentID: 'msg_subtask_compaction',
|
||||
title: 'Harbor Lantern'
|
||||
},
|
||||
{ resume: false, command: undefined, parentID: 'msg_other_caller', title: 'Shared run title' }
|
||||
])(
|
||||
'uses the borrowed v1 HTTP response as best effort (%j)',
|
||||
async ({ resume, command, parentID, title }) => {
|
||||
const requests: string[] = []
|
||||
const url = await fixture((path, body, response) => {
|
||||
requests.push(path)
|
||||
path = path.replace('/prefix/', '/')
|
||||
if (path.startsWith('GET /session/saved?')) {
|
||||
json(response, { id: 'saved', directory: '/old' })
|
||||
} else if (path.startsWith('GET /session?')) {
|
||||
json(response, [{ id: 'saved', directory: '/old' }])
|
||||
} else if (path.startsWith('GET /agent?')) {
|
||||
json(response, [{ name: 'reader', mode: 'subagent' }])
|
||||
} else if (path.startsWith('GET /command?')) {
|
||||
json(response, [{ name: 'inspect', agent: 'reader', subtask: true }])
|
||||
} else if (path.startsWith(`POST /session/saved/${command ? 'command' : 'message'}?`)) {
|
||||
expect(body).toMatchObject(
|
||||
command
|
||||
? { command: 'inspect', arguments: 'Name only', model: 'configured/model' }
|
||||
: {
|
||||
parts: [{ type: 'text', text: 'Name only' }],
|
||||
model: { providerID: 'configured', modelID: 'model' }
|
||||
}
|
||||
)
|
||||
json(response, {
|
||||
info: { id: 'msg_native_reply', parentID, role: 'assistant', time: { completed: 300 } },
|
||||
parts: [{ type: 'text', text: title }]
|
||||
})
|
||||
} else {
|
||||
response.statusCode = 400
|
||||
json(response, {})
|
||||
}
|
||||
})
|
||||
await expect(
|
||||
runOpenCodeTextTaskSession({
|
||||
version: 'v1',
|
||||
v1SessionPolicyFiltersTools: true,
|
||||
url: `${url}/prefix/`,
|
||||
directory: '/workspace',
|
||||
externalDirectory: '/requested',
|
||||
external: { url },
|
||||
exclusiveServer: false,
|
||||
prompt: 'Name only',
|
||||
model: { providerID: 'configured', modelID: 'model' },
|
||||
sessionId: resume ? undefined : 'saved',
|
||||
continue: resume,
|
||||
command,
|
||||
operation: 'conversation-name',
|
||||
signal: new AbortController().signal
|
||||
})
|
||||
).resolves.toBe(title)
|
||||
expect(requests).toEqual([
|
||||
resume
|
||||
? 'GET /prefix/session?directory=%2Frequested'
|
||||
: 'GET /prefix/session/saved?directory=%2Frequested',
|
||||
...(command
|
||||
? ['GET /prefix/agent?directory=%2Frequested', 'GET /prefix/command?directory=%2Frequested']
|
||||
: []),
|
||||
`POST /prefix/session/saved/${command ? 'command' : 'message'}?directory=%2Frequested`
|
||||
])
|
||||
}
|
||||
)
|
||||
|
||||
it('discards a cancelled borrowed v1 response without aborting or deleting its session', async () => {
|
||||
const controller = new AbortController()
|
||||
const submitted = Promise.withResolvers<void>()
|
||||
@@ -594,78 +367,6 @@ it('retains explicitly shared native history even when publication fails ambiguo
|
||||
])
|
||||
})
|
||||
|
||||
it('selects the newest matching root with one filtered request at N and 10N histories', async () => {
|
||||
for (const population of [200, 2000]) {
|
||||
let pages = 0
|
||||
const history = Array.from({ length: population }, (_, index) => ({
|
||||
id: index === population - 2 ? 'selected' : `other_${index}`,
|
||||
location: { directory: index % 2 === 0 ? '/workspace' : '/elsewhere' },
|
||||
parentID: index !== population - 2 && index % 3 === 0 ? 'parent' : null,
|
||||
updated: index
|
||||
}))
|
||||
let events: ServerResponse | undefined
|
||||
const url = await fixture((path, body, response) => {
|
||||
const parsed = new URL(path.slice(path.indexOf(' ') + 1), 'http://fixture')
|
||||
if (path === 'GET /api/event') {
|
||||
events = response
|
||||
response.writeHead(200, { 'content-type': 'text/event-stream' })
|
||||
response.flushHeaders()
|
||||
} else if (parsed.pathname === '/api/location') {
|
||||
json(response, { directory: '/workspace' })
|
||||
} else if (path.startsWith('GET /api/session?')) {
|
||||
pages++
|
||||
expect(parsed.searchParams.get('directory')).toBe('/workspace')
|
||||
expect(parsed.searchParams.get('parentID')).toBe('null')
|
||||
expect(parsed.searchParams.get('order')).toBe('desc')
|
||||
const matching = history
|
||||
.filter(
|
||||
(item) =>
|
||||
item.location.directory === parsed.searchParams.get('directory') && !item.parentID
|
||||
)
|
||||
.sort((a, b) => b.updated - a.updated)
|
||||
json(response, {
|
||||
data: matching.slice(0, Number(parsed.searchParams.get('limit'))),
|
||||
cursor: {}
|
||||
})
|
||||
} else if (path === 'POST /api/session/selected/prompt') {
|
||||
const { id } = z.object({ id: z.string() }).parse(body)
|
||||
const emitted: [string, Record<string, unknown>][] = [
|
||||
['session.inbox.delivered', { inboxID: id }],
|
||||
['session.step.started', { assistantMessageID: 'msg_selected' }],
|
||||
[
|
||||
'session.text.ended',
|
||||
{ assistantMessageID: 'msg_selected', ordinal: 0, text: 'Harbor Lantern' }
|
||||
],
|
||||
['session.execution.succeeded', {}]
|
||||
]
|
||||
for (const [type, data] of emitted) {
|
||||
events!.write(
|
||||
`data: ${JSON.stringify({ type, data: { sessionID: 'selected', ...data } })}\n\n`
|
||||
)
|
||||
}
|
||||
json(response, {})
|
||||
} else {
|
||||
response.statusCode = 400
|
||||
json(response, {})
|
||||
}
|
||||
})
|
||||
await expect(
|
||||
runOpenCodeTextTaskSession({
|
||||
version: 'v2',
|
||||
v1SessionPolicyFiltersTools: false,
|
||||
url,
|
||||
directory: '/workspace',
|
||||
continue: true,
|
||||
exclusiveServer: false,
|
||||
operation: 'conversation-name',
|
||||
prompt: 'Name only',
|
||||
signal: new AbortController().signal
|
||||
})
|
||||
).resolves.toBe('Harbor Lantern')
|
||||
expect(pages).toBe(1)
|
||||
}
|
||||
})
|
||||
|
||||
it.each([false, true])(
|
||||
'rejects owned subtask asks with session routing field: %s',
|
||||
async (routing) => {
|
||||
|
||||
Reference in New Issue
Block a user