test(features): remove unsafe test assertions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -20,14 +20,14 @@ describe("resolveSubagentSpawnContext", () => {
|
||||
test("passes query.directory to each session.get call", async () => {
|
||||
// given
|
||||
const sessionGetCalls: Array<Record<string, unknown>> = []
|
||||
const client = createMockClient((async (input) => {
|
||||
const client = createMockClient(testCoerce<OpencodeClient["session"]["get"]>((async (input) => {
|
||||
sessionGetCalls.push(input as Record<string, unknown>)
|
||||
if (input.path.id === "child-session") {
|
||||
return { data: { id: "child-session", parentID: "root-session" } }
|
||||
}
|
||||
|
||||
return { data: { id: "root-session", parentID: undefined } }
|
||||
}) as unknown as OpencodeClient["session"]["get"])
|
||||
})))
|
||||
|
||||
// when
|
||||
const result = await resolveSubagentSpawnContext(client, "child-session", "/project/root")
|
||||
@@ -50,10 +50,10 @@ describe("resolveSubagentSpawnContext", () => {
|
||||
describe("#given session.get returns an SDK error response", () => {
|
||||
test("throws a fail-closed spawn blocked error", async () => {
|
||||
// given
|
||||
const client = createMockClient((async () => ({
|
||||
const client = createMockClient(testCoerce<OpencodeClient["session"]["get"]>((async () => ({
|
||||
error: "lookup failed",
|
||||
data: undefined,
|
||||
})) as unknown as OpencodeClient["session"]["get"])
|
||||
}))))
|
||||
|
||||
// when
|
||||
const result = resolveSubagentSpawnContext(client, "parent-session")
|
||||
@@ -66,9 +66,9 @@ describe("resolveSubagentSpawnContext", () => {
|
||||
describe("#given session.get returns no session data", () => {
|
||||
test("throws a fail-closed spawn blocked error", async () => {
|
||||
// given
|
||||
const client = createMockClient((async () => ({
|
||||
const client = createMockClient(testCoerce<OpencodeClient["session"]["get"]>((async () => ({
|
||||
data: undefined,
|
||||
})) as unknown as OpencodeClient["session"]["get"])
|
||||
}))))
|
||||
|
||||
// when
|
||||
const result = resolveSubagentSpawnContext(client, "parent-session")
|
||||
@@ -81,12 +81,12 @@ describe("resolveSubagentSpawnContext", () => {
|
||||
describe("depth calculation smoke tests (regression guard)", () => {
|
||||
test("root session (no parentID) reports depth 0 and childDepth 1", async () => {
|
||||
// given - a root session with no parent
|
||||
const client = createMockClient((async (opts) => {
|
||||
const client = createMockClient(testCoerce<OpencodeClient["session"]["get"]>((async (opts) => {
|
||||
if (opts.path.id === "root-session") {
|
||||
return { data: { id: "root-session", parentID: undefined } }
|
||||
}
|
||||
return { error: "not found", data: undefined }
|
||||
}) as unknown as OpencodeClient["session"]["get"])
|
||||
})))
|
||||
|
||||
// when
|
||||
const result = await resolveSubagentSpawnContext(client, "root-session")
|
||||
@@ -99,7 +99,7 @@ describe("resolveSubagentSpawnContext", () => {
|
||||
|
||||
test("depth-1 child reports childDepth 2", async () => {
|
||||
// given - child -> root chain
|
||||
const client = createMockClient((async (opts) => {
|
||||
const client = createMockClient(testCoerce<OpencodeClient["session"]["get"]>((async (opts) => {
|
||||
if (opts.path.id === "child-1") {
|
||||
return { data: { id: "child-1", parentID: "root-session" } }
|
||||
}
|
||||
@@ -107,7 +107,7 @@ describe("resolveSubagentSpawnContext", () => {
|
||||
return { data: { id: "root-session", parentID: undefined } }
|
||||
}
|
||||
return { error: "not found", data: undefined }
|
||||
}) as unknown as OpencodeClient["session"]["get"])
|
||||
})))
|
||||
|
||||
// when
|
||||
const result = await resolveSubagentSpawnContext(client, "child-1")
|
||||
@@ -120,7 +120,7 @@ describe("resolveSubagentSpawnContext", () => {
|
||||
|
||||
test("depth-2 grandchild reports childDepth 3", async () => {
|
||||
// given - grandchild -> child -> root chain
|
||||
const client = createMockClient((async (opts) => {
|
||||
const client = createMockClient(testCoerce<OpencodeClient["session"]["get"]>((async (opts) => {
|
||||
const sessions: Record<string, { id: string; parentID?: string }> = {
|
||||
"grandchild": { id: "grandchild", parentID: "child" },
|
||||
"child": { id: "child", parentID: "root" },
|
||||
@@ -129,7 +129,7 @@ describe("resolveSubagentSpawnContext", () => {
|
||||
const session = sessions[opts.path.id]
|
||||
if (session) return { data: session }
|
||||
return { error: "not found", data: undefined }
|
||||
}) as unknown as OpencodeClient["session"]["get"])
|
||||
})))
|
||||
|
||||
// when
|
||||
const result = await resolveSubagentSpawnContext(client, "grandchild")
|
||||
@@ -153,11 +153,11 @@ describe("resolveSubagentSpawnContext", () => {
|
||||
}
|
||||
}
|
||||
|
||||
const client = createMockClient((async (opts) => {
|
||||
const client = createMockClient(testCoerce<OpencodeClient["session"]["get"]>((async (opts) => {
|
||||
const session = sessions[opts.path.id]
|
||||
if (session) return { data: session }
|
||||
return { error: "not found", data: undefined }
|
||||
}) as unknown as OpencodeClient["session"]["get"])
|
||||
})))
|
||||
|
||||
// when - resolve from the deepest session
|
||||
const deepest = `session-${DEFAULT_MAX_SUBAGENT_DEPTH}`
|
||||
@@ -170,7 +170,7 @@ describe("resolveSubagentSpawnContext", () => {
|
||||
|
||||
test("detects parent cycle and throws", async () => {
|
||||
// given - A -> B -> A (cycle)
|
||||
const client = createMockClient((async (opts) => {
|
||||
const client = createMockClient(testCoerce<OpencodeClient["session"]["get"]>((async (opts) => {
|
||||
const sessions: Record<string, { id: string; parentID?: string }> = {
|
||||
"session-a": { id: "session-a", parentID: "session-b" },
|
||||
"session-b": { id: "session-b", parentID: "session-a" },
|
||||
@@ -178,7 +178,7 @@ describe("resolveSubagentSpawnContext", () => {
|
||||
const session = sessions[opts.path.id]
|
||||
if (session) return { data: session }
|
||||
return { error: "not found", data: undefined }
|
||||
}) as unknown as OpencodeClient["session"]["get"])
|
||||
})))
|
||||
|
||||
// when
|
||||
const result = resolveSubagentSpawnContext(client, "session-a")
|
||||
|
||||
Reference in New Issue
Block a user