test(cli): 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:
YeonGyu-Kim
2026-05-12 14:21:39 +09:00
parent 9c6090a208
commit 7365163885
13 changed files with 118 additions and 118 deletions
+42 -42
View File
@@ -26,7 +26,7 @@ function createTempDir(): string {
function createMockContext(directory: string): RunContext {
return {
client: {
client: testCoerce<RunContext["client"]>({
session: {
todo: mock(() => Promise.resolve({ data: [] })),
children: mock(() => Promise.resolve({ data: [] })),
@@ -39,7 +39,7 @@ function createMockContext(directory: string): RunContext {
})),
messages: mock(async () => ({ data: [] })),
},
} as unknown as RunContext["client"],
}),
sessionID: "test-session",
directory,
abortController: new AbortController(),
@@ -155,17 +155,17 @@ describe("checkCompletionConditions continuation coverage", () => {
const ctx = createMockContext(directory)
ctx.sessionID = "child-session"
setSessionAgent("child-session", "atlas")
ctx.client.session.get = mock(async ({ path }: { path: { id: string } }) => ({
ctx.client.session.get = testCoerce<RunContext["client"]["session"]["get"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: {
id: path.id,
parentID: path.id === "child-session" ? "root-session" : undefined,
},
})) as unknown as RunContext["client"]["session"]["get"]
ctx.client.session.messages = mock(async ({ path }: { path: { id: string } }) => ({
})))
ctx.client.session.messages = testCoerce<RunContext["client"]["session"]["messages"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: path.id === "child-session"
? [{ info: { agent: "atlas", providerID: "openai", modelID: "gpt-5.4" } }]
: [],
})) as unknown as RunContext["client"]["session"]["messages"]
})))
const { checkCompletionConditions } = await import("./completion")
@@ -187,13 +187,13 @@ describe("checkCompletionConditions continuation coverage", () => {
const ctx = createMockContext(directory)
ctx.sessionID = "lineage-only-session"
ctx.client.session.get = mock(async ({ path }: { path: { id: string } }) => ({
ctx.client.session.get = testCoerce<RunContext["client"]["session"]["get"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: {
id: path.id,
parentID: path.id === "lineage-only-session" ? "root-session" : undefined,
},
})) as unknown as RunContext["client"]["session"]["get"]
ctx.client.session.messages = mock(async () => ({ data: [] })) as unknown as RunContext["client"]["session"]["messages"]
})))
ctx.client.session.messages = testCoerce<RunContext["client"]["session"]["messages"]>(mock(async () => ({ data: [] })))
const { checkCompletionConditions } = await import("./completion")
@@ -218,17 +218,17 @@ describe("checkCompletionConditions continuation coverage", () => {
const ctx = createMockContext(directory)
ctx.sessionID = "mismatch-subagent-session"
ctx.client.session.get = mock(async ({ path }: { path: { id: string } }) => ({
ctx.client.session.get = testCoerce<RunContext["client"]["session"]["get"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: {
id: path.id,
parentID: path.id === "mismatch-subagent-session" ? "root-session" : undefined,
},
})) as unknown as RunContext["client"]["session"]["get"]
ctx.client.session.messages = mock(async ({ path }: { path: { id: string } }) => ({
})))
ctx.client.session.messages = testCoerce<RunContext["client"]["session"]["messages"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: path.id === "mismatch-subagent-session"
? [{ info: { agent: "sisyphus-junior", providerID: "openai", modelID: "gpt-5.4" } }]
: [],
})) as unknown as RunContext["client"]["session"]["messages"]
})))
const { checkCompletionConditions } = await import("./completion")
@@ -253,17 +253,17 @@ describe("checkCompletionConditions continuation coverage", () => {
const ctx = createMockContext(directory)
ctx.sessionID = "appended-mismatch-session"
ctx.client.session.get = mock(async ({ path }: { path: { id: string } }) => ({
ctx.client.session.get = testCoerce<RunContext["client"]["session"]["get"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: {
id: path.id,
parentID: path.id === "appended-mismatch-session" ? "root-session" : undefined,
},
})) as unknown as RunContext["client"]["session"]["get"]
ctx.client.session.messages = mock(async ({ path }: { path: { id: string } }) => ({
})))
ctx.client.session.messages = testCoerce<RunContext["client"]["session"]["messages"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: path.id === "appended-mismatch-session"
? [{ info: { agent: "sisyphus-junior", providerID: "openai", modelID: "gpt-5.4" } }]
: [],
})) as unknown as RunContext["client"]["session"]["messages"]
})))
const { checkCompletionConditions } = await import("./completion")
@@ -288,14 +288,14 @@ describe("checkCompletionConditions continuation coverage", () => {
const ctx = createMockContext(directory)
ctx.sessionID = "ses_appended_descendant"
ctx.client.session.get = mock(async () => {
ctx.client.session.get = testCoerce<RunContext["client"]["session"]["get"]>(mock(async () => {
throw new Error("session lookup failed")
}) as unknown as RunContext["client"]["session"]["get"]
ctx.client.session.messages = mock(async ({ path }: { path: { id: string } }) => ({
}))
ctx.client.session.messages = testCoerce<RunContext["client"]["session"]["messages"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: path.id === "ses_appended_descendant"
? [{ info: { agent: "atlas", providerID: "openai", modelID: "gpt-5.4" } }]
: [],
})) as unknown as RunContext["client"]["session"]["messages"]
})))
const { checkCompletionConditions } = await import("./completion")
@@ -317,12 +317,12 @@ describe("checkCompletionConditions continuation coverage", () => {
const ctx = createMockContext(directory)
ctx.sessionID = "ses_direct_child"
ctx.client.session.get = mock(async ({ path }: { path: { id: string } }) => ({
ctx.client.session.get = testCoerce<RunContext["client"]["session"]["get"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: {
id: path.id,
parentID: path.id === "ses_direct_child" ? "ses_parent" : undefined,
},
})) as unknown as RunContext["client"]["session"]["get"]
})))
const { checkCompletionConditions } = await import("./completion")
@@ -347,12 +347,12 @@ describe("checkCompletionConditions continuation coverage", () => {
const ctx = createMockContext(directory)
ctx.sessionID = "ses_direct_tracked"
ctx.client.session.get = mock(async ({ path }: { path: { id: string } }) => ({
ctx.client.session.get = testCoerce<RunContext["client"]["session"]["get"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: {
id: path.id,
parentID: undefined,
},
})) as unknown as RunContext["client"]["session"]["get"]
})))
const { checkCompletionConditions } = await import("./completion")
@@ -374,9 +374,9 @@ describe("checkCompletionConditions continuation coverage", () => {
const ctx = createMockContext(directory)
ctx.sessionID = "ses_unknown_child"
ctx.client.session.get = mock(async () => {
ctx.client.session.get = testCoerce<RunContext["client"]["session"]["get"]>(mock(async () => {
throw new Error("lineage unavailable")
}) as unknown as RunContext["client"]["session"]["get"]
}))
const { checkCompletionConditions } = await import("./completion")
@@ -401,17 +401,17 @@ describe("checkCompletionConditions continuation coverage", () => {
const ctx = createMockContext(directory)
ctx.sessionID = "ses_direct_child"
ctx.client.session.get = mock(async ({ path }: { path: { id: string } }) => ({
ctx.client.session.get = testCoerce<RunContext["client"]["session"]["get"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: {
id: path.id,
parentID: path.id === "ses_direct_child" ? "ses_root_tracked" : undefined,
},
})) as unknown as RunContext["client"]["session"]["get"]
ctx.client.session.messages = mock(async ({ path }: { path: { id: string } }) => ({
})))
ctx.client.session.messages = testCoerce<RunContext["client"]["session"]["messages"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: path.id === "ses_direct_child"
? [{ info: { agent: "sisyphus-junior", providerID: "openai", modelID: "gpt-5.4" } }]
: [],
})) as unknown as RunContext["client"]["session"]["messages"]
})))
const { checkCompletionConditions } = await import("./completion")
@@ -437,20 +437,20 @@ describe("checkCompletionConditions continuation coverage", () => {
const ctx = createMockContext(directory)
ctx.sessionID = "ses_child_after_compaction"
setSessionAgent("ses_child_after_compaction", "atlas")
ctx.client.session.get = mock(async ({ path }: { path: { id: string } }) => ({
ctx.client.session.get = testCoerce<RunContext["client"]["session"]["get"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: {
id: path.id,
parentID: path.id === "ses_child_after_compaction" ? "root-session" : undefined,
},
})) as unknown as RunContext["client"]["session"]["get"]
ctx.client.session.messages = mock(async ({ path }: { path: { id: string } }) => ({
})))
ctx.client.session.messages = testCoerce<RunContext["client"]["session"]["messages"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: path.id === "ses_child_after_compaction"
? [
{ info: { agent: "atlas", providerID: "openai", modelID: "gpt-5.4" } },
{ info: { agent: "compaction", providerID: "openai", modelID: "gpt-5.4" } },
]
: [],
})) as unknown as RunContext["client"]["session"]["messages"]
})))
const { checkCompletionConditions } = await import("./completion")
@@ -472,13 +472,13 @@ describe("checkCompletionConditions continuation coverage", () => {
const ctx = createMockContext(directory)
ctx.sessionID = "ses_sqlite_descendant"
ctx.client.session.get = mock(async ({ path }: { path: { id: string } }) => ({
ctx.client.session.get = testCoerce<RunContext["client"]["session"]["get"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: {
id: path.id,
parentID: path.id === "ses_sqlite_descendant" ? "root-session" : undefined,
},
})) as unknown as RunContext["client"]["session"]["get"]
ctx.client.session.messages = mock(async ({ path }: { path: { id: string } }) => ({
})))
ctx.client.session.messages = testCoerce<RunContext["client"]["session"]["messages"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: path.id === "ses_sqlite_descendant"
? [
{ id: "msg_0001", info: { agent: "atlas", providerID: "openai", modelID: "gpt-5.4", time: { created: 100 } } },
@@ -486,7 +486,7 @@ describe("checkCompletionConditions continuation coverage", () => {
{ id: "msg_0002", info: { agent: "sisyphus-junior", providerID: "openai", modelID: "gpt-5.4", time: { created: 100 } } },
]
: [],
})) as unknown as RunContext["client"]["session"]["messages"]
})))
const { checkCompletionConditions } = await import("./completion")
@@ -512,13 +512,13 @@ describe("checkCompletionConditions continuation coverage", () => {
const ctx = createMockContext(directory)
ctx.sessionID = "ses_appended_child"
setSessionAgent("ses_appended_child", "atlas")
ctx.client.session.get = mock(async ({ path }: { path: { id: string } }) => ({
ctx.client.session.get = testCoerce<RunContext["client"]["session"]["get"]>(mock(async ({ path }: { path: { id: string } }) => ({
data: {
id: path.id,
parentID: path.id === "ses_appended_child" ? "ses_root_tracked" : undefined,
},
})) as unknown as RunContext["client"]["session"]["get"]
ctx.client.session.messages = mock(async () => ({ data: [] })) as unknown as RunContext["client"]["session"]["messages"]
})))
ctx.client.session.messages = testCoerce<RunContext["client"]["session"]["messages"]>(mock(async () => ({ data: [] })))
const { checkCompletionConditions } = await import("./completion")