fix(core): await plugin readiness
This commit is contained in:
@@ -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([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user