

























@@ -2421,10 +2421,14 @@ describe("runCodexAppServerAttempt", () => {
24212421await expect(response).resolves.toEqual({
24222422answers: { mode: { answers: ["Deep"] } },
24232423});
2424-expect(request).not.toHaveBeenCalledWith(
2425-"turn/steer",
2426-expect.objectContaining({ expectedTurnId: "turn-1" }),
2427-);
2424+const requestCalls = request.mock.calls as unknown as Array<[string, unknown]>;
2425+expect(
2426+requestCalls.some(
2427+([method, callParams]) =>
2428+method === "turn/steer" &&
2429+(callParams as { expectedTurnId?: string } | undefined)?.expectedTurnId === "turn-1",
2430+),
2431+).toBe(false);
2428243224292433await notify({
24302434method: "turn/completed",
@@ -2460,7 +2464,8 @@ describe("runCodexAppServerAttempt", () => {
24602464await waitForMethod("turn/start");
24612465abortController.abort("shutdown");
246224662463-await expect(run).resolves.toMatchObject({ aborted: true });
2467+const result = await run;
2468+expect(result.aborted).toBe(true);
24642469await new Promise((resolve) => setImmediate(resolve));
24652470expect(unhandledRejections).toStrictEqual([]);
24662471} finally {
@@ -2488,19 +2493,14 @@ describe("runCodexAppServerAttempt", () => {
24882493await completeTurn({ threadId: "thread-1", turnId: "turn-1" });
24892494await run;
249024952491-expect(requests).toEqual(
2492-expect.arrayContaining([
2493-{
2494-method: "turn/start",
2495-params: expect.objectContaining({
2496-input: [
2497-{ type: "text", text: "hello", text_elements: [] },
2498-{ type: "image", url: "data:image/png;base64,aW1hZ2UtYnl0ZXM=" },
2499-],
2500-}),
2501-},
2502-]),
2503-);
2496+const turnStart = requests.find((entry) => entry.method === "turn/start");
2497+const turnStartParams = turnStart?.params as
2498+| { input?: Array<{ text?: string; text_elements?: unknown[]; type?: string; url?: string }> }
2499+| undefined;
2500+expect(turnStartParams?.input).toEqual([
2501+{ type: "text", text: "hello", text_elements: [] },
2502+{ type: "image", url: "data:image/png;base64,aW1hZ2UtYnl0ZXM=" },
2503+]);
25042504});
2505250525062506it("does not drop turn completion notifications emitted while turn/start is in flight", async () => {
@@ -2516,14 +2516,11 @@ describe("runCodexAppServerAttempt", () => {
25162516return {};
25172517});
251825182519-await expect(
2520-runCodexAppServerAttempt(
2521-createParams(path.join(tempDir, "session.jsonl"), path.join(tempDir, "workspace")),
2522-),
2523-).resolves.toMatchObject({
2524-aborted: false,
2525-timedOut: false,
2526-});
2519+const result = await runCodexAppServerAttempt(
2520+createParams(path.join(tempDir, "session.jsonl"), path.join(tempDir, "workspace")),
2521+);
2522+expect(result.aborted).toBe(false);
2523+expect(result.timedOut).toBe(false);
25272524});
2528252525292526it("completes when turn/start returns a terminal turn without a follow-up notification", async () => {
@@ -2548,11 +2545,9 @@ describe("runCodexAppServerAttempt", () => {
25482545);
2549254625502547expect(harness.requests.map((entry) => entry.method)).toContain("turn/start");
2551-expect(result).toMatchObject({
2552-assistantTexts: ["done from response"],
2553-aborted: false,
2554-timedOut: false,
2555-});
2548+expect(result.assistantTexts).toEqual(["done from response"]);
2549+expect(result.aborted).toBe(false);
2550+expect(result.timedOut).toBe(false);
25562551});
2557255225582553it("does not complete on unscoped turn/completed notifications", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。