mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-30 13:54:01 +00:00
- Rename packages/opencode → packages/tfcode (directory only) - Rename bin/opencode → bin/tfcode (CLI binary) - Rename .opencode → .tfcode (config directory) - Update package.json name and bin field - Update config directory path references (.tfcode) - Keep internal code references as 'opencode' for easy upstream sync - Keep @opencode-ai/* workspace package names This minimal branding approach allows clean merges from upstream opencode repository while providing tfcode branding for users.
79 lines
2.2 KiB
TypeScript
79 lines
2.2 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import path from "path"
|
|
import { Session } from "../../src/session"
|
|
import { Log } from "../../src/util/log"
|
|
import { Instance } from "../../src/project/instance"
|
|
import { Server } from "../../src/server/server"
|
|
|
|
const projectRoot = path.join(__dirname, "../..")
|
|
Log.init({ print: false })
|
|
|
|
describe("tui.selectSession endpoint", () => {
|
|
test("should return 200 when called with valid session", async () => {
|
|
await Instance.provide({
|
|
directory: projectRoot,
|
|
fn: async () => {
|
|
// #given
|
|
const session = await Session.create({})
|
|
|
|
// #when
|
|
const app = Server.Default()
|
|
const response = await app.request("/tui/select-session", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ sessionID: session.id }),
|
|
})
|
|
|
|
// #then
|
|
expect(response.status).toBe(200)
|
|
const body = await response.json()
|
|
expect(body).toBe(true)
|
|
|
|
await Session.remove(session.id)
|
|
},
|
|
})
|
|
})
|
|
|
|
test("should return 404 when session does not exist", async () => {
|
|
await Instance.provide({
|
|
directory: projectRoot,
|
|
fn: async () => {
|
|
// #given
|
|
const nonExistentSessionID = "ses_nonexistent123"
|
|
|
|
// #when
|
|
const app = Server.Default()
|
|
const response = await app.request("/tui/select-session", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ sessionID: nonExistentSessionID }),
|
|
})
|
|
|
|
// #then
|
|
expect(response.status).toBe(404)
|
|
},
|
|
})
|
|
})
|
|
|
|
test("should return 400 when session ID format is invalid", async () => {
|
|
await Instance.provide({
|
|
directory: projectRoot,
|
|
fn: async () => {
|
|
// #given
|
|
const invalidSessionID = "invalid_session_id"
|
|
|
|
// #when
|
|
const app = Server.Default()
|
|
const response = await app.request("/tui/select-session", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ sessionID: invalidSessionID }),
|
|
})
|
|
|
|
// #then
|
|
expect(response.status).toBe(400)
|
|
},
|
|
})
|
|
})
|
|
})
|