mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-14 13:22:37 +00:00
test(claude): split the thinking-restart regression into two tests
Each case now states its own setup instead of branching inside one test body.
This commit is contained in:
+30
-12
@@ -278,9 +278,7 @@ afterEach(() => {
|
||||
queryFactory.mockReset();
|
||||
});
|
||||
|
||||
test.each([false, true])(
|
||||
"submits after a thinking change with no live query (previous query ended: %s)",
|
||||
async (previousQueryEnded) => {
|
||||
async function createThinkingRestartSession() {
|
||||
const queries: ScriptedQuery[] = [];
|
||||
queryFactory.mockImplementation(({ prompt }: { prompt: AsyncIterable<unknown> }) => {
|
||||
const scriptedQuery = createScriptedQuery({
|
||||
@@ -296,27 +294,47 @@ test.each([false, true])(
|
||||
queryFactory,
|
||||
resolveBinary: async () => "/test/claude/bin",
|
||||
}).createSession({ provider: "claude", cwd: process.cwd() });
|
||||
return { session, queries };
|
||||
}
|
||||
|
||||
test("submits after a thinking change before the first turn", async () => {
|
||||
const { session, queries } = await createThinkingRestartSession();
|
||||
|
||||
try {
|
||||
if (previousQueryEnded) {
|
||||
await collectUntilTerminal(streamSession(session, "first prompt"));
|
||||
queries[0].end();
|
||||
// Let the pump retire the old query before changing thinking.
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
}
|
||||
await session.setThinkingOption!("medium");
|
||||
const events = await collectUntilTerminal(
|
||||
streamSession(session, "continue", { clientMessageId: "client-continue" }),
|
||||
);
|
||||
expect(events.filter((event) => event.type === "turn_failed")).toEqual([]);
|
||||
expect(events.at(-1)?.type).toBe("turn_completed");
|
||||
expect(queryFactory).toHaveBeenCalledTimes(previousQueryEnded ? 2 : 1);
|
||||
expect(queries.at(-1)?.prompts.map((prompt) => prompt.text)).toEqual(["continue"]);
|
||||
expect(queryFactory).toHaveBeenCalledTimes(1);
|
||||
expect(queries[0].prompts.map((prompt) => prompt.text)).toEqual(["continue"]);
|
||||
} finally {
|
||||
await session.close();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
test("submits after a thinking change once the previous query ended", async () => {
|
||||
const { session, queries } = await createThinkingRestartSession();
|
||||
|
||||
try {
|
||||
await collectUntilTerminal(streamSession(session, "first prompt"));
|
||||
queries[0].end();
|
||||
// Let the pump retire the old query before changing thinking.
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
|
||||
await session.setThinkingOption!("medium");
|
||||
const events = await collectUntilTerminal(
|
||||
streamSession(session, "continue", { clientMessageId: "client-continue" }),
|
||||
);
|
||||
expect(events.filter((event) => event.type === "turn_failed")).toEqual([]);
|
||||
expect(events.at(-1)?.type).toBe("turn_completed");
|
||||
expect(queryFactory).toHaveBeenCalledTimes(2);
|
||||
expect(queries[1].prompts.map((prompt) => prompt.text)).toEqual(["continue"]);
|
||||
} finally {
|
||||
await session.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("interrupt only calls query.interrupt and leaves the query open", async () => {
|
||||
const logger = createTestLogger();
|
||||
|
||||
Reference in New Issue
Block a user