|
@@ -11,77 +11,83 @@ void Log.init({ print: false })
|
|
|
const it = testEffect(Session.defaultLayer)
|
|
const it = testEffect(Session.defaultLayer)
|
|
|
|
|
|
|
|
describe("tui.selectSession endpoint", () => {
|
|
describe("tui.selectSession endpoint", () => {
|
|
|
- it.instance("should return 200 when called with valid session", () =>
|
|
|
|
|
- Effect.gen(function* () {
|
|
|
|
|
- const tmp = yield* TestInstance
|
|
|
|
|
- const session = yield* Session.Service.use((svc) => svc.create({}))
|
|
|
|
|
|
|
+ it.instance(
|
|
|
|
|
+ "should return 200 when called with valid session",
|
|
|
|
|
+ () =>
|
|
|
|
|
+ Effect.gen(function* () {
|
|
|
|
|
+ const tmp = yield* TestInstance
|
|
|
|
|
+ const session = yield* Session.Service.use((svc) => svc.create({}))
|
|
|
|
|
|
|
|
- const app = Server.Default().app
|
|
|
|
|
- const response = yield* Effect.promise(() =>
|
|
|
|
|
- Promise.resolve(
|
|
|
|
|
- app.request("/tui/select-session", {
|
|
|
|
|
- method: "POST",
|
|
|
|
|
- headers: {
|
|
|
|
|
- "Content-Type": "application/json",
|
|
|
|
|
- "x-opencode-directory": tmp.directory,
|
|
|
|
|
- },
|
|
|
|
|
- body: JSON.stringify({ sessionID: session.id }),
|
|
|
|
|
- }),
|
|
|
|
|
- ),
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ const app = Server.Default().app
|
|
|
|
|
+ const response = yield* Effect.promise(() =>
|
|
|
|
|
+ Promise.resolve(
|
|
|
|
|
+ app.request("/tui/select-session", {
|
|
|
|
|
+ method: "POST",
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ "Content-Type": "application/json",
|
|
|
|
|
+ "x-opencode-directory": tmp.directory,
|
|
|
|
|
+ },
|
|
|
|
|
+ body: JSON.stringify({ sessionID: session.id }),
|
|
|
|
|
+ }),
|
|
|
|
|
+ ),
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
- expect(response.status).toBe(200)
|
|
|
|
|
- const body = yield* Effect.promise(() => response.json())
|
|
|
|
|
- expect(body).toBe(true)
|
|
|
|
|
- }),
|
|
|
|
|
|
|
+ expect(response.status).toBe(200)
|
|
|
|
|
+ const body = yield* Effect.promise(() => response.json())
|
|
|
|
|
+ expect(body).toBe(true)
|
|
|
|
|
+ }),
|
|
|
{ git: true },
|
|
{ git: true },
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- it.instance("should return 404 when session does not exist", () =>
|
|
|
|
|
- Effect.gen(function* () {
|
|
|
|
|
- const tmp = yield* TestInstance
|
|
|
|
|
- const nonExistentSessionID = "ses_nonexistent123"
|
|
|
|
|
|
|
+ it.instance(
|
|
|
|
|
+ "should return 404 when session does not exist",
|
|
|
|
|
+ () =>
|
|
|
|
|
+ Effect.gen(function* () {
|
|
|
|
|
+ const tmp = yield* TestInstance
|
|
|
|
|
+ const nonExistentSessionID = "ses_nonexistent123"
|
|
|
|
|
|
|
|
- const app = Server.Default().app
|
|
|
|
|
- const response = yield* Effect.promise(() =>
|
|
|
|
|
- Promise.resolve(
|
|
|
|
|
- app.request("/tui/select-session", {
|
|
|
|
|
- method: "POST",
|
|
|
|
|
- headers: {
|
|
|
|
|
- "Content-Type": "application/json",
|
|
|
|
|
- "x-opencode-directory": tmp.directory,
|
|
|
|
|
- },
|
|
|
|
|
- body: JSON.stringify({ sessionID: nonExistentSessionID }),
|
|
|
|
|
- }),
|
|
|
|
|
- ),
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ const app = Server.Default().app
|
|
|
|
|
+ const response = yield* Effect.promise(() =>
|
|
|
|
|
+ Promise.resolve(
|
|
|
|
|
+ app.request("/tui/select-session", {
|
|
|
|
|
+ method: "POST",
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ "Content-Type": "application/json",
|
|
|
|
|
+ "x-opencode-directory": tmp.directory,
|
|
|
|
|
+ },
|
|
|
|
|
+ body: JSON.stringify({ sessionID: nonExistentSessionID }),
|
|
|
|
|
+ }),
|
|
|
|
|
+ ),
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
- expect(response.status).toBe(404)
|
|
|
|
|
- }),
|
|
|
|
|
|
|
+ expect(response.status).toBe(404)
|
|
|
|
|
+ }),
|
|
|
{ git: true },
|
|
{ git: true },
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- it.instance("should return 400 when session ID format is invalid", () =>
|
|
|
|
|
- Effect.gen(function* () {
|
|
|
|
|
- const tmp = yield* TestInstance
|
|
|
|
|
- const invalidSessionID = "invalid_session_id"
|
|
|
|
|
|
|
+ it.instance(
|
|
|
|
|
+ "should return 400 when session ID format is invalid",
|
|
|
|
|
+ () =>
|
|
|
|
|
+ Effect.gen(function* () {
|
|
|
|
|
+ const tmp = yield* TestInstance
|
|
|
|
|
+ const invalidSessionID = "invalid_session_id"
|
|
|
|
|
|
|
|
- const app = Server.Default().app
|
|
|
|
|
- const response = yield* Effect.promise(() =>
|
|
|
|
|
- Promise.resolve(
|
|
|
|
|
- app.request("/tui/select-session", {
|
|
|
|
|
- method: "POST",
|
|
|
|
|
- headers: {
|
|
|
|
|
- "Content-Type": "application/json",
|
|
|
|
|
- "x-opencode-directory": tmp.directory,
|
|
|
|
|
- },
|
|
|
|
|
- body: JSON.stringify({ sessionID: invalidSessionID }),
|
|
|
|
|
- }),
|
|
|
|
|
- ),
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ const app = Server.Default().app
|
|
|
|
|
+ const response = yield* Effect.promise(() =>
|
|
|
|
|
+ Promise.resolve(
|
|
|
|
|
+ app.request("/tui/select-session", {
|
|
|
|
|
+ method: "POST",
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ "Content-Type": "application/json",
|
|
|
|
|
+ "x-opencode-directory": tmp.directory,
|
|
|
|
|
+ },
|
|
|
|
|
+ body: JSON.stringify({ sessionID: invalidSessionID }),
|
|
|
|
|
+ }),
|
|
|
|
|
+ ),
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
- expect(response.status).toBe(400)
|
|
|
|
|
- }),
|
|
|
|
|
|
|
+ expect(response.status).toBe(400)
|
|
|
|
|
+ }),
|
|
|
{ git: true },
|
|
{ git: true },
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|