chore: generate
This commit is contained in:
@@ -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", () =>
|
it.instance(
|
||||||
Effect.gen(function* () {
|
"should return 200 when called with valid session",
|
||||||
const tmp = yield* TestInstance
|
() =>
|
||||||
const session = yield* Session.Service.use((svc) => svc.create({}))
|
Effect.gen(function* () {
|
||||||
|
const tmp = yield* TestInstance
|
||||||
|
const session = yield* Session.Service.use((svc) => svc.create({}))
|
||||||
|
|
||||||
const app = Server.Default().app
|
const app = Server.Default().app
|
||||||
const response = yield* Effect.promise(() =>
|
const response = yield* Effect.promise(() =>
|
||||||
Promise.resolve(
|
Promise.resolve(
|
||||||
app.request("/tui/select-session", {
|
app.request("/tui/select-session", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"x-opencode-directory": tmp.directory,
|
"x-opencode-directory": tmp.directory,
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ sessionID: session.id }),
|
body: JSON.stringify({ sessionID: session.id }),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(response.status).toBe(200)
|
expect(response.status).toBe(200)
|
||||||
const body = yield* Effect.promise(() => response.json())
|
const body = yield* Effect.promise(() => response.json())
|
||||||
expect(body).toBe(true)
|
expect(body).toBe(true)
|
||||||
}),
|
}),
|
||||||
{ git: true },
|
{ git: true },
|
||||||
)
|
)
|
||||||
|
|
||||||
it.instance("should return 404 when session does not exist", () =>
|
it.instance(
|
||||||
Effect.gen(function* () {
|
"should return 404 when session does not exist",
|
||||||
const tmp = yield* TestInstance
|
() =>
|
||||||
const nonExistentSessionID = "ses_nonexistent123"
|
Effect.gen(function* () {
|
||||||
|
const tmp = yield* TestInstance
|
||||||
|
const nonExistentSessionID = "ses_nonexistent123"
|
||||||
|
|
||||||
const app = Server.Default().app
|
const app = Server.Default().app
|
||||||
const response = yield* Effect.promise(() =>
|
const response = yield* Effect.promise(() =>
|
||||||
Promise.resolve(
|
Promise.resolve(
|
||||||
app.request("/tui/select-session", {
|
app.request("/tui/select-session", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"x-opencode-directory": tmp.directory,
|
"x-opencode-directory": tmp.directory,
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ sessionID: nonExistentSessionID }),
|
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", () =>
|
it.instance(
|
||||||
Effect.gen(function* () {
|
"should return 400 when session ID format is invalid",
|
||||||
const tmp = yield* TestInstance
|
() =>
|
||||||
const invalidSessionID = "invalid_session_id"
|
Effect.gen(function* () {
|
||||||
|
const tmp = yield* TestInstance
|
||||||
|
const invalidSessionID = "invalid_session_id"
|
||||||
|
|
||||||
const app = Server.Default().app
|
const app = Server.Default().app
|
||||||
const response = yield* Effect.promise(() =>
|
const response = yield* Effect.promise(() =>
|
||||||
Promise.resolve(
|
Promise.resolve(
|
||||||
app.request("/tui/select-session", {
|
app.request("/tui/select-session", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"x-opencode-directory": tmp.directory,
|
"x-opencode-directory": tmp.directory,
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ sessionID: invalidSessionID }),
|
body: JSON.stringify({ sessionID: invalidSessionID }),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(response.status).toBe(400)
|
expect(response.status).toBe(400)
|
||||||
}),
|
}),
|
||||||
{ git: true },
|
{ git: true },
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user