@@ -82,15 +82,25 @@ describe("GET /api/settings", () => {
8282 } ) ;
8383
8484 test ( "reports redacted codexRuntime diagnostics and clamp correlation" , async ( ) => {
85- const { persistCodexRuntime, persistEffortClamp, resetCodexRuntimeResolveCacheForTests } = await import ( "../src/codex/runtime" ) ;
85+ const { chmodSync } = await import ( "node:fs" ) ;
86+ const {
87+ persistEffortClamp,
88+ resetCodexRuntimeResolveCacheForTests,
89+ } = await import ( "../src/codex/runtime" ) ;
8690 resetCodexRuntimeResolveCacheForTests ( ) ;
87- persistCodexRuntime ( {
88- command : join ( TEST_DIR , "Users" , "Alice" , "codex.exe" ) ,
89- version : "0.133.0" ,
90- source : "configured" ,
91- } , { configDir : TEST_DIR } ) ;
91+
92+ const fakeCodex = process . platform === "win32"
93+ ? join ( TEST_DIR , "bin" , "codex.cmd" )
94+ : join ( TEST_DIR , "bin" , "codex" ) ;
95+ mkdirSync ( join ( TEST_DIR , "bin" ) , { recursive : true } ) ;
96+ if ( process . platform === "win32" ) {
97+ writeFileSync ( fakeCodex , "@echo off\r\necho codex-cli 0.133.0\r\n" , "utf8" ) ;
98+ } else {
99+ writeFileSync ( fakeCodex , "#!/bin/sh\necho 'codex-cli 0.133.0'\n" , "utf8" ) ;
100+ chmodSync ( fakeCodex , 0o755 ) ;
101+ }
92102 persistEffortClamp ( {
93- runtimePath : join ( TEST_DIR , "Users" , "Alice" , "codex.exe" ) ,
103+ runtimePath : fakeCodex ,
94104 runtimeVersion : "0.133.0" ,
95105 removedEfforts : [ "max" , "ultra" ] ,
96106 affectedModels : [ "gpt-5.6-sol" ] ,
@@ -99,10 +109,8 @@ describe("GET /api/settings", () => {
99109 const previousCli = process . env . CODEX_CLI_PATH ;
100110 const previousPath = process . env . PATH ;
101111 try {
102- process . env . CODEX_CLI_PATH = join ( TEST_DIR , "Users" , "Alice" , "codex.exe" ) ;
112+ process . env . CODEX_CLI_PATH = fakeCodex ;
103113 process . env . PATH = "" ;
104- // Force resolve to use the persisted/env path without spawning a real Codex.
105- // The settings handler catches resolve failures; probe will fail existence and fall back.
106114 const body = await ( await getSettings ( baseConfig ( ) ) ) ! . json ( ) as {
107115 codexRuntime ?: {
108116 path ?: string ;
@@ -114,17 +122,21 @@ describe("GET /api/settings", () => {
114122 } ;
115123 } ;
116124 expect ( typeof body . codexRuntime ?. path ) . toBe ( "string" ) ;
117- expect ( body . codexRuntime ?. path ?. toLowerCase ( ) ) . not . toContain ( "alice" ) ;
125+ // OPENCODEX_HOME lives under the OS user profile; username must stay redacted.
126+ expect ( body . codexRuntime ?. path ?. toLowerCase ( ) ) . not . toMatch ( / \\ u s e r s \\ [ ^ \\ [ \] / ] + \\ / i) ;
127+ expect ( body . codexRuntime ?. version ) . toBe ( "0.133.0" ) ;
128+ expect ( body . codexRuntime ?. source ) . toBe ( "environment" ) ;
129+ expect ( body . codexRuntime ?. catalogClamp ) . toEqual ( {
130+ active : true ,
131+ removedEfforts : [ "max" , "ultra" ] ,
132+ runtimeVersion : "0.133.0" ,
133+ } ) ;
118134 expect (
119135 body . codexRuntime ?. newerAvailable === null
120136 || ( typeof body . codexRuntime ?. newerAvailable === "object" && body . codexRuntime ?. newerAvailable !== null ) ,
121137 ) . toBe ( true ) ;
122- expect ( body . codexRuntime ?. warning === null || typeof body . codexRuntime ?. warning === "string" ) . toBe ( true ) ;
123- expect ( Array . isArray ( body . codexRuntime ?. catalogClamp ?. removedEfforts ) ) . toBe ( true ) ;
124- expect (
125- body . codexRuntime ?. catalogClamp ?. runtimeVersion === null
126- || typeof body . codexRuntime ?. catalogClamp ?. runtimeVersion === "string" ,
127- ) . toBe ( true ) ;
138+ expect ( typeof body . codexRuntime ?. warning ) . toBe ( "string" ) ;
139+ expect ( body . codexRuntime ?. warning ) . toContain ( "0.133.0" ) ;
128140 } finally {
129141 if ( previousCli === undefined ) delete process . env . CODEX_CLI_PATH ;
130142 else process . env . CODEX_CLI_PATH = previousCli ;
0 commit comments