@@ -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+
1853describe ( "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
0 commit comments