Skip to content

Commit 5af395e

Browse files
committed
test(auth): complete doctor context and stabilize MCP pagination
1 parent dea0db6 commit 5af395e

2 files changed

Lines changed: 44 additions & 9 deletions

File tree

‎src/flows/doctor-health-contribution-runners.state.codex.test.ts‎

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,41 @@ vi.mock("../../packages/terminal-core/src/note.js", () => ({
1515
note: mocks.note,
1616
}));
1717

18+
function createDoctorHealthContext(params: {
19+
cfg: DoctorHealthFlowContext["cfg"];
20+
env: NodeJS.ProcessEnv;
21+
shouldRepair: boolean;
22+
configResult?: Omit<DoctorHealthFlowContext["configResult"], "cfg">;
23+
}): DoctorHealthFlowContext {
24+
const { cfg, env, shouldRepair, configResult } = params;
25+
return {
26+
runtime: { log: vi.fn(), error: vi.fn(), exit: vi.fn() },
27+
options: {},
28+
prompter: {
29+
confirm: vi.fn(async () => shouldRepair),
30+
confirmAutoFix: vi.fn(async () => shouldRepair),
31+
confirmAggressiveAutoFix: vi.fn(async () => shouldRepair),
32+
confirmRuntimeRepair: vi.fn(async () => shouldRepair),
33+
select: vi.fn(async (_params, fallback) => fallback),
34+
shouldRepair,
35+
shouldForce: false,
36+
repairMode: {
37+
shouldRepair,
38+
shouldForce: false,
39+
nonInteractive: true,
40+
canPrompt: false,
41+
updateInProgress: false,
42+
},
43+
},
44+
configResult: { cfg, ...configResult },
45+
cfg,
46+
cfgForPersistence: cfg,
47+
sourceConfigValid: true,
48+
configPath: "/tmp/openclaw-doctor-session-owner/openclaw.json",
49+
env,
50+
};
51+
}
52+
1853
describe("Codex session doctor health owner", () => {
1954
beforeEach(() => {
2055
vi.clearAllMocks();
@@ -31,16 +66,15 @@ describe("Codex session doctor health owner", () => {
3166
const authProfileIdMap = new Map([["openai-codex:default", "openai:chatgpt-default"]]);
3267
const env = { OPENCLAW_STATE_DIR: "/tmp/openclaw-doctor-session-owner" };
3368
const cfg = {};
34-
const ctx = {
69+
const ctx = createDoctorHealthContext({
3570
cfg,
3671
env,
37-
prompter: { shouldRepair: true },
72+
shouldRepair: true,
3873
configResult: {
39-
cfg,
4074
openAICodexAuthProfileIdMap: authProfileIdMap,
4175
blockedCodexModelIdentities: ["codex\0gpt-5.6-sol"],
4276
},
43-
} as DoctorHealthFlowContext;
77+
});
4478

4579
await runCodexSessionRouteHealth(ctx);
4680

@@ -55,12 +89,11 @@ describe("Codex session doctor health owner", () => {
5589

5690
it("keeps preview mode read-only without inventing an auth migration map", async () => {
5791
const cfg = {};
58-
const ctx = {
92+
const ctx = createDoctorHealthContext({
5993
cfg,
6094
env: {},
61-
prompter: { shouldRepair: false },
62-
configResult: { cfg },
63-
} as DoctorHealthFlowContext;
95+
shouldRepair: false,
96+
});
6497

6598
await runCodexSessionRouteHealth(ctx);
6699

‎src/node-host/mcp.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ describe("node host MCP manager", () => {
305305
{ endless: { command: "endless" }, healthy: { command: "healthy" } },
306306
{
307307
createClient: (serverName) => (serverName === "endless" ? endless : healthy),
308-
resolveTransport: () => transport,
308+
// Prove the page ceiling without loaded CI accidentally hitting the
309+
// catalog deadline; timeout behavior has its own dedicated coverage.
310+
resolveTransport: () => ({ ...transport, requestTimeoutMs: 1_000 }),
309311
warn,
310312
},
311313
);

0 commit comments

Comments
 (0)