mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
Fix catalog regression fixture types
This commit is contained in:
@@ -24,7 +24,9 @@ const LEARNED_EFFORTS = [
|
||||
|
||||
it('publishes inventory before a slow optional effort reply and retains its valid late result', async () => {
|
||||
vi.useFakeTimers()
|
||||
onTestFinished(() => vi.useRealTimers())
|
||||
onTestFinished(() => {
|
||||
vi.useRealTimers()
|
||||
})
|
||||
const late =
|
||||
Promise.withResolvers<
|
||||
Awaited<ReturnType<AcpModelCatalogSessionConnection['setConfigOption']>>
|
||||
@@ -44,7 +46,10 @@ it('publishes inventory before a slow optional effort reply and retains its vali
|
||||
deleteSession: async () => ({}),
|
||||
close: async () => {}
|
||||
}
|
||||
const run = runAgentModelCatalogSession(
|
||||
const run = runAgentModelCatalogSession<
|
||||
AcpModelCatalogSessionConnection,
|
||||
Awaited<ReturnType<typeof readSessionModels>>
|
||||
>(
|
||||
() => connection,
|
||||
(connection, ready) =>
|
||||
readSessionModels(
|
||||
@@ -164,8 +169,18 @@ function accumulatedCatalogHarness(count: number) {
|
||||
serialize: async (_id, task) => task(),
|
||||
scopeOwned: async () => null
|
||||
}))
|
||||
const read = (waitForListing = true, selectedModel?: string) =>
|
||||
externalRead({ agent: 'opencode2', workspacePath: '/workspace', waitForListing, selectedModel })
|
||||
const read = async (waitForListing = true, selectedModel?: string) => {
|
||||
const result = await externalRead({
|
||||
agent: 'opencode2',
|
||||
workspacePath: '/workspace',
|
||||
waitForListing,
|
||||
selectedModel
|
||||
})
|
||||
if (result.origin === 'unknown') {
|
||||
throw new Error('Expected the listing inventory')
|
||||
}
|
||||
return result
|
||||
}
|
||||
onTestFinished(() => service.stop())
|
||||
const answer = (index: number) => {
|
||||
const request = requests[index]!
|
||||
@@ -178,7 +193,9 @@ it.each([10, 100])(
|
||||
'accumulates %i untargeted menus without publishing the full catalog per reply',
|
||||
async (count) => {
|
||||
vi.useFakeTimers()
|
||||
onTestFinished(() => vi.useRealTimers())
|
||||
onTestFinished(() => {
|
||||
vi.useRealTimers()
|
||||
})
|
||||
const h = accumulatedCatalogHarness(count)
|
||||
const first = h.read()
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
@@ -211,7 +228,9 @@ it.each(['snapshot', 'deadline', 'selected'])(
|
||||
'exposes accumulated menus at a %s boundary while the next switch is unanswered',
|
||||
async (boundary) => {
|
||||
vi.useFakeTimers()
|
||||
onTestFinished(() => vi.useRealTimers())
|
||||
onTestFinished(() => {
|
||||
vi.useRealTimers()
|
||||
})
|
||||
const h = accumulatedCatalogHarness(5)
|
||||
const first = h.read()
|
||||
await first
|
||||
@@ -259,7 +278,9 @@ it.each(['snapshot', 'deadline', 'selected'])(
|
||||
|
||||
it('keeps a slow OpenCode 1.x version response and selects its command listing', async () => {
|
||||
vi.useFakeTimers()
|
||||
onTestFinished(() => vi.useRealTimers())
|
||||
onTestFinished(() => {
|
||||
vi.useRealTimers()
|
||||
})
|
||||
const version = Promise.withResolvers<{ version: string }>()
|
||||
const requested = Promise.withResolvers<void>()
|
||||
const base = acpLaunchSpecFor('opencode')!
|
||||
|
||||
@@ -83,6 +83,9 @@ it('starts the first OMP listing on demand collected before admission, without a
|
||||
selectedModel: 'provider/selected',
|
||||
waitForListing: true
|
||||
})
|
||||
if (result.origin === 'unknown') {
|
||||
throw new Error('Expected the selected model inventory')
|
||||
}
|
||||
expect(result.models?.find((row) => row.id === 'provider/selected')).toMatchObject({
|
||||
efforts: [{ value: 'high', label: 'High' }]
|
||||
})
|
||||
|
||||
+15
-4
@@ -162,7 +162,9 @@ it.each([false, true])(
|
||||
'keeps a slow successful listing after its reader leaves (saved=%s)',
|
||||
async (saved) => {
|
||||
vi.useFakeTimers()
|
||||
onTestFinished(() => vi.useRealTimers())
|
||||
onTestFinished(() => {
|
||||
vi.useRealTimers()
|
||||
})
|
||||
const h = sharedListingHarness()
|
||||
if (saved) {
|
||||
const initial = h.service.read({ agent: 'codex', waitForListing: true })
|
||||
@@ -186,7 +188,12 @@ it.each([false, true])(
|
||||
const reader = h.service.read({ agent: 'codex', waitForListing: true })
|
||||
await vi.advanceTimersByTimeAsync(30_000)
|
||||
expect(await reader).toMatchObject({ listingInProgress: true, waitExpired: true })
|
||||
expect(h.service.snapshot({ agent: 'codex' }).models?.[0]?.id).toBe(saved ? 'saved' : undefined)
|
||||
const snapshot = h.service.snapshot({ agent: 'codex' })
|
||||
if (saved) {
|
||||
expect(snapshot).toMatchObject({ models: [{ id: 'saved' }] })
|
||||
} else {
|
||||
expect(snapshot.origin).toBe('unknown')
|
||||
}
|
||||
await vi.advanceTimersByTimeAsync(15_000)
|
||||
answer.resolve({ ...listing('slow-success'), complete: true })
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
@@ -201,7 +208,9 @@ it.each([true, false])(
|
||||
'delivers progress and waits for a changed observation (progress=%s)',
|
||||
async (progress) => {
|
||||
vi.useFakeTimers()
|
||||
onTestFinished(() => vi.useRealTimers())
|
||||
onTestFinished(() => {
|
||||
vi.useRealTimers()
|
||||
})
|
||||
const h = sharedListingHarness()
|
||||
const answer = Promise.withResolvers<AgentModelCatalogSuccess>()
|
||||
let publish: AgentModelCatalogProgress | undefined
|
||||
@@ -324,7 +333,9 @@ it('fences obsolete progress and final results while retaining admission until c
|
||||
|
||||
it('withdraws an abandoned queued scope while the two admitted listings continue', async () => {
|
||||
vi.useFakeTimers()
|
||||
onTestFinished(() => vi.useRealTimers())
|
||||
onTestFinished(() => {
|
||||
vi.useRealTimers()
|
||||
})
|
||||
const h = sharedListingHarness()
|
||||
void h.service.demand({ agent: 'codex', workspacePath: '/own-a' })
|
||||
void h.service.demand({ agent: 'codex', workspacePath: '/own-b' })
|
||||
|
||||
@@ -229,7 +229,9 @@ it("keeps the folder's defaults when they arrive after a shorter last reader lef
|
||||
|
||||
it('delivers inventory before slow folder defaults, then delivers the proven default', async () => {
|
||||
vi.useFakeTimers()
|
||||
onTestFinished(() => vi.useRealTimers())
|
||||
onTestFinished(() => {
|
||||
vi.useRealTimers()
|
||||
})
|
||||
const h = harness(agent)
|
||||
const settings = Promise.withResolvers<void>()
|
||||
h.folder.settings = settings
|
||||
@@ -336,7 +338,9 @@ it.each([10, 100])(
|
||||
'registers %i readers and unique targets once per shared flight',
|
||||
async (count) => {
|
||||
vi.useFakeTimers()
|
||||
onTestFinished(() => vi.useRealTimers())
|
||||
onTestFinished(() => {
|
||||
vi.useRealTimers()
|
||||
})
|
||||
for (const delayedScope of [false, true]) {
|
||||
const h = harness('opencode2')
|
||||
const scope = Promise.withResolvers<void>()
|
||||
|
||||
@@ -4,7 +4,9 @@ import type { AgentModelCatalogSuccess } from '../../../native-chat/agent-model-
|
||||
|
||||
it('publishes a slow inventory independently of state, then keeps the late default', async () => {
|
||||
vi.useFakeTimers()
|
||||
onTestFinished(() => vi.useRealTimers())
|
||||
onTestFinished(() => {
|
||||
vi.useRealTimers()
|
||||
})
|
||||
const inventory = Promise.withResolvers<unknown>()
|
||||
const state = Promise.withResolvers<unknown>()
|
||||
const requested = Promise.withResolvers<void>()
|
||||
|
||||
@@ -230,13 +230,19 @@ it('keeps an open picker subscribed after usable progress until late enrichment
|
||||
onTestFinished(close)
|
||||
await vi.waitFor(() => expect(published[0]?.catalog).toMatchObject({ listingInProgress: true }))
|
||||
next = enriched.promise
|
||||
inventory.resolve({ origin: 'probe', models: [model('listed')], listingInProgress: true })
|
||||
inventory.resolve({
|
||||
origin: 'probe',
|
||||
fetchedAt: 1,
|
||||
models: [model('listed')],
|
||||
listingInProgress: true
|
||||
})
|
||||
await vi.waitFor(() =>
|
||||
expect(published[0]?.catalog).toMatchObject({ models: [{ id: 'listed' }] })
|
||||
)
|
||||
expect(published[0]?.catalogRead).toBe('pending')
|
||||
enriched.resolve({
|
||||
origin: 'probe',
|
||||
fetchedAt: 2,
|
||||
models: [
|
||||
{ ...model('listed'), defaultEffort: 'high', efforts: [{ value: 'high', label: 'High' }] }
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user