fix(app): restore assistant fixture, simplify route.fulfill
- Re-add AssistantFixture type and assistant fixture (used by prompt specs) - Simplify route.fulfill to use response param directly
This commit is contained in:
parent
4453ff26f6
commit
fae97cc559
2 changed files with 30 additions and 7 deletions
|
|
@ -56,6 +56,19 @@ type LLMWorker = LLMFixture & {
|
||||||
reset: () => Promise<void>
|
reset: () => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AssistantFixture = {
|
||||||
|
reply: LLMFixture["text"]
|
||||||
|
tool: LLMFixture["tool"]
|
||||||
|
toolHang: LLMFixture["toolHang"]
|
||||||
|
reason: LLMFixture["reason"]
|
||||||
|
fail: LLMFixture["fail"]
|
||||||
|
error: LLMFixture["error"]
|
||||||
|
hang: LLMFixture["hang"]
|
||||||
|
hold: LLMFixture["hold"]
|
||||||
|
calls: LLMFixture["calls"]
|
||||||
|
pending: LLMFixture["pending"]
|
||||||
|
}
|
||||||
|
|
||||||
export const settingsKey = "settings.v3"
|
export const settingsKey = "settings.v3"
|
||||||
|
|
||||||
const seedModel = (() => {
|
const seedModel = (() => {
|
||||||
|
|
@ -127,6 +140,7 @@ type ProjectFixture = ProjectHandle & {
|
||||||
|
|
||||||
type TestFixtures = {
|
type TestFixtures = {
|
||||||
llm: LLMFixture
|
llm: LLMFixture
|
||||||
|
assistant: AssistantFixture
|
||||||
project: ProjectFixture
|
project: ProjectFixture
|
||||||
sdk: ReturnType<typeof createSdk>
|
sdk: ReturnType<typeof createSdk>
|
||||||
gotoSession: (sessionID?: string) => Promise<void>
|
gotoSession: (sessionID?: string) => Promise<void>
|
||||||
|
|
@ -218,6 +232,20 @@ export const test = base.extend<TestFixtures, WorkerFixtures>({
|
||||||
throw new Error(`TestLLMServer still has ${pending} queued response(s) after the test finished`)
|
throw new Error(`TestLLMServer still has ${pending} queued response(s) after the test finished`)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
assistant: async ({ llm }, use) => {
|
||||||
|
await use({
|
||||||
|
reply: llm.text,
|
||||||
|
tool: llm.tool,
|
||||||
|
toolHang: llm.toolHang,
|
||||||
|
reason: llm.reason,
|
||||||
|
fail: llm.fail,
|
||||||
|
error: llm.error,
|
||||||
|
hang: llm.hang,
|
||||||
|
hold: llm.hold,
|
||||||
|
calls: llm.calls,
|
||||||
|
pending: llm.pending,
|
||||||
|
})
|
||||||
|
},
|
||||||
page: async ({ page }, use) => {
|
page: async ({ page }, use) => {
|
||||||
let boundary: string | undefined
|
let boundary: string | undefined
|
||||||
setHealthPhase(page, "test")
|
setHealthPhase(page, "test")
|
||||||
|
|
@ -567,10 +595,7 @@ async function seedStorage(
|
||||||
prompt: { enabled: true },
|
prompt: { enabled: true },
|
||||||
terminal: { enabled: true, terminals: {} },
|
terminal: { enabled: true, terminals: {} },
|
||||||
}
|
}
|
||||||
localStorage.setItem(
|
localStorage.setItem("opencode.global.dat:model", JSON.stringify({ recent: [args.model], user: [], variant: {} }))
|
||||||
"opencode.global.dat:model",
|
|
||||||
JSON.stringify({ recent: [args.model], user: [], variant: {} }),
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
{ directory: input.directory, serverUrl: origin, extra: input.extra ?? [], model: input.model ?? seedModel },
|
{ directory: input.directory, serverUrl: origin, extra: input.extra ?? [], model: input.model ?? seedModel },
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -242,9 +242,7 @@ async function withMockPermission<T>(
|
||||||
const list = Array.isArray(json) ? json : Array.isArray(json?.data) ? json.data : undefined
|
const list = Array.isArray(json) ? json : Array.isArray(json?.data) ? json.data : undefined
|
||||||
if (Array.isArray(list) && !list.some((item) => item?.id === opts.child?.id)) list.push(opts.child)
|
if (Array.isArray(list) && !list.some((item) => item?.id === opts.child?.id)) list.push(opts.child)
|
||||||
await route.fulfill({
|
await route.fulfill({
|
||||||
status: res.status(),
|
response: res,
|
||||||
headers: res.headers(),
|
|
||||||
contentType: "application/json",
|
|
||||||
body: JSON.stringify(json),
|
body: JSON.stringify(json),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue