fix(core): await plugin readiness
This commit is contained in:
parent
d2c866bf70
commit
4a710e4679
5 changed files with 98 additions and 10 deletions
|
|
@ -4,6 +4,8 @@ import { Server } from "../../src/server/server"
|
|||
import { Global } from "@opencode-ai/core/global"
|
||||
import { resetDatabase } from "../fixture/db"
|
||||
import { disposeAllInstances, tmpdir } from "../fixture/fixture"
|
||||
import { Effect } from "effect"
|
||||
import { pollWithTimeout } from "../lib/effect"
|
||||
|
||||
afterEach(async () => {
|
||||
await disposeAllInstances()
|
||||
|
|
@ -24,12 +26,19 @@ describe("reference HttpApi", () => {
|
|||
},
|
||||
})
|
||||
|
||||
const response = await Server.Default().app.request("/api/reference", {
|
||||
headers: { "x-opencode-directory": tmp.path },
|
||||
})
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
const body = await response.json()
|
||||
const body = await Effect.runPromise(
|
||||
pollWithTimeout(
|
||||
Effect.promise(async () => {
|
||||
const response = await Server.Default().app.request("/api/reference", {
|
||||
headers: { "x-opencode-directory": tmp.path },
|
||||
})
|
||||
expect(response.status).toBe(200)
|
||||
const body = await response.json()
|
||||
return body.data.length === 0 ? undefined : body
|
||||
}),
|
||||
"references were not loaded",
|
||||
),
|
||||
)
|
||||
expect(body).toMatchObject({ location: { directory: tmp.path } })
|
||||
expect(body.data).toEqual([
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue