cloudaxe-opencode/packages/opencode/test/server/workspace-httpapi.test.ts
Kit Langton ce035ec4d3 add experimental workspace HttpApi read slice
Add a parallel experimental workspace HttpApi surface for adaptor/list/status reads using route-local Effect schemas and cover the new endpoints with a server test.
2026-04-14 20:43:38 -04:00

38 lines
1.6 KiB
TypeScript

import { describe, expect, test } from "bun:test"
import { Server } from "../../src/server/server"
import { Log } from "../../src/util/log"
import { tmpdir } from "../fixture/fixture"
Log.init({ print: false })
describe("experimental workspace httpapi", () => {
test("lists adaptors, workspaces, status, and serves docs", async () => {
await using tmp = await tmpdir({ git: true })
const app = Server.Default().app
const headers = {
"content-type": "application/json",
"x-opencode-directory": tmp.path,
}
const adaptors = await app.request("/experimental/httpapi/workspace/adaptor", { headers })
expect(adaptors.status).toBe(200)
expect(Array.isArray(await adaptors.json())).toBe(true)
const list = await app.request("/experimental/httpapi/workspace", { headers })
expect(list.status).toBe(200)
expect(Array.isArray(await list.json())).toBe(true)
const status = await app.request("/experimental/httpapi/workspace/status", { headers })
expect(status.status).toBe(200)
expect(Array.isArray(await status.json())).toBe(true)
const doc = await app.request("/experimental/httpapi/workspace/doc", { headers })
expect(doc.status).toBe(200)
const spec = await doc.json()
expect(spec.paths["/experimental/httpapi/workspace/adaptor"]?.get?.operationId).toBe(
"experimental.workspace.adaptor.list",
)
expect(spec.paths["/experimental/httpapi/workspace"]?.get?.operationId).toBe("experimental.workspace.list")
expect(spec.paths["/experimental/httpapi/workspace/status"]?.get?.operationId).toBe("experimental.workspace.status")
})
})