d5fbada13d
Move test coercion out of a hidden global and require each test to import the helper so review tools and runtime scripts can see the unsafe boundary. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
|
|
import { createOrGetSession } from "./session-creator"
|
|
import { _resetForTesting, subagentSessions } from "../../features/claude-code-session-state"
|
|
import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
|
|
|
|
describe("call-omo-agent createOrGetSession", () => {
|
|
test("creates child session without overriding permission and tracks it as subagent session", async () => {
|
|
// given
|
|
_resetForTesting()
|
|
|
|
const createCalls: Array<unknown> = []
|
|
const ctx = {
|
|
directory: "/project",
|
|
client: {
|
|
session: {
|
|
get: async () => ({ data: { directory: "/parent" } }),
|
|
create: async (args: unknown) => {
|
|
createCalls.push(args)
|
|
return { data: { id: "ses_child" } }
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
const toolContext = {
|
|
sessionID: "ses_parent",
|
|
messageID: "msg_parent",
|
|
agent: "sisyphus",
|
|
abort: new AbortController().signal,
|
|
}
|
|
|
|
const args = {
|
|
description: "test",
|
|
prompt: "hello",
|
|
subagent_type: "explore",
|
|
run_in_background: true,
|
|
}
|
|
|
|
// when
|
|
const result = await createOrGetSession(unsafeTestValue(args), unsafeTestValue(toolContext), unsafeTestValue(ctx))
|
|
|
|
// then
|
|
expect(result).toEqual({ sessionID: "ses_child", isNew: true })
|
|
expect(createCalls).toHaveLength(1)
|
|
const createBody = (unsafeTestValue(createCalls[0]))?.body
|
|
expect(createBody?.parentID).toBe("ses_parent")
|
|
expect(createBody?.permission).toBeUndefined()
|
|
expect(subagentSessions.has("ses_child")).toBe(true)
|
|
})
|
|
})
|