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
pull/20593/head
Kit Langton 2026-04-02 12:20:56 -04:00
parent 4453ff26f6
commit fae97cc559
2 changed files with 30 additions and 7 deletions

View File

@ -56,6 +56,19 @@ type LLMWorker = LLMFixture & {
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"
const seedModel = (() => {
@ -127,6 +140,7 @@ type ProjectFixture = ProjectHandle & {
type TestFixtures = {
llm: LLMFixture
assistant: AssistantFixture
project: ProjectFixture
sdk: ReturnType<typeof createSdk>
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`)
}
},
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) => {
let boundary: string | undefined
setHealthPhase(page, "test")
@ -567,10 +595,7 @@ async function seedStorage(
prompt: { enabled: true },
terminal: { enabled: true, terminals: {} },
}
localStorage.setItem(
"opencode.global.dat:model",
JSON.stringify({ recent: [args.model], user: [], variant: {} }),
)
localStorage.setItem("opencode.global.dat:model", JSON.stringify({ recent: [args.model], user: [], variant: {} }))
},
{ directory: input.directory, serverUrl: origin, extra: input.extra ?? [], model: input.model ?? seedModel },
)

View File

@ -242,9 +242,7 @@ async function withMockPermission<T>(
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)
await route.fulfill({
status: res.status(),
headers: res.headers(),
contentType: "application/json",
response: res,
body: JSON.stringify(json),
})
}