|
|
@@ -8,6 +8,8 @@ import { WorkspaceID } from "../../src/control-plane/schema"
|
|
|
import { ControlPaths } from "../../src/server/routes/instance/httpapi/groups/control"
|
|
|
import { InstancePaths } from "../../src/server/routes/instance/httpapi/groups/instance"
|
|
|
import { SessionPaths } from "../../src/server/routes/instance/httpapi/groups/session"
|
|
|
+import { PermissionID } from "../../src/permission/schema"
|
|
|
+import { QuestionID } from "../../src/question/schema"
|
|
|
import { HttpApiApp } from "../../src/server/routes/instance/httpapi/server"
|
|
|
import { HEADER as FenceHeader } from "../../src/server/shared/fence"
|
|
|
import { resetDatabase } from "../fixture/db"
|
|
|
@@ -151,6 +153,58 @@ describe("instance HttpApi", () => {
|
|
|
}),
|
|
|
)
|
|
|
|
|
|
+ it.live("returns typed not found bodies for missing permission and question requests", () =>
|
|
|
+ Effect.gen(function* () {
|
|
|
+ const dir = yield* tmpdirScoped({ git: true })
|
|
|
+ const request = (path: string, init?: RequestInit) =>
|
|
|
+ Effect.promise(() =>
|
|
|
+ HttpApiApp.webHandler().handler(
|
|
|
+ new Request(`http://localhost${path}`, {
|
|
|
+ ...init,
|
|
|
+ headers: { "x-opencode-directory": dir, "content-type": "application/json", ...init?.headers },
|
|
|
+ }),
|
|
|
+ handlerContext,
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ const permissionID = PermissionID.ascending()
|
|
|
+ const questionReplyID = QuestionID.ascending()
|
|
|
+ const questionRejectID = QuestionID.ascending()
|
|
|
+ const [permission, questionReply, questionReject] = yield* Effect.all(
|
|
|
+ [
|
|
|
+ request(`/permission/${permissionID}/reply`, {
|
|
|
+ method: "POST",
|
|
|
+ body: JSON.stringify({ reply: "once" }),
|
|
|
+ }),
|
|
|
+ request(`/question/${questionReplyID}/reply`, {
|
|
|
+ method: "POST",
|
|
|
+ body: JSON.stringify({ answers: [["Yes"]] }),
|
|
|
+ }),
|
|
|
+ request(`/question/${questionRejectID}/reject`, { method: "POST" }),
|
|
|
+ ],
|
|
|
+ { concurrency: "unbounded" },
|
|
|
+ )
|
|
|
+
|
|
|
+ expect(permission.status).toBe(404)
|
|
|
+ expect(yield* Effect.promise(() => permission.json())).toEqual({
|
|
|
+ _tag: "PermissionNotFoundError",
|
|
|
+ requestID: permissionID,
|
|
|
+ message: `Permission request not found: ${permissionID}`,
|
|
|
+ })
|
|
|
+ expect(questionReply.status).toBe(404)
|
|
|
+ expect(yield* Effect.promise(() => questionReply.json())).toEqual({
|
|
|
+ _tag: "QuestionNotFoundError",
|
|
|
+ requestID: questionReplyID,
|
|
|
+ message: `Question request not found: ${questionReplyID}`,
|
|
|
+ })
|
|
|
+ expect(questionReject.status).toBe(404)
|
|
|
+ expect(yield* Effect.promise(() => questionReject.json())).toEqual({
|
|
|
+ _tag: "QuestionNotFoundError",
|
|
|
+ requestID: questionRejectID,
|
|
|
+ message: `Question request not found: ${questionRejectID}`,
|
|
|
+ })
|
|
|
+ }),
|
|
|
+ )
|
|
|
+
|
|
|
it.live("serves path and VCS read endpoints", () =>
|
|
|
Effect.gen(function* () {
|
|
|
const dir = yield* tmpdirScoped({ git: true })
|