@@ -1505,6 +1505,55 @@ enabled = true
15051505 rmSync ( tmpBase , { recursive : true , force : true } ) ;
15061506 }
15071507 } ) ;
1508+
1509+ test ( 'Codex: n/a with error when plugin cache path cannot be listed' , ( ) => {
1510+ const tmpBase = join ( tmpdir ( ) , `doctor-codex-${ Date . now ( ) } ` ) ;
1511+ const homeDir = join ( tmpBase , 'home' ) ;
1512+ const projectDir = join ( tmpBase , 'project' ) ;
1513+ const codexHome = join ( homeDir , '.codex' ) ;
1514+ const pluginCacheParent = join ( codexHome , 'plugins' , 'cache' , 'cc-marketplace' ) ;
1515+ const pluginCachePath = join ( pluginCacheParent , 'safety-net' ) ;
1516+ mkdirSync ( projectDir , { recursive : true } ) ;
1517+ mkdirSync ( pluginCacheParent , { recursive : true } ) ;
1518+ writeFileSync ( pluginCachePath , 'not a directory' ) ;
1519+
1520+ try {
1521+ const hooks = detectAllHooks ( projectDir , { homeDir } ) ;
1522+ const codex = hooks . find ( ( hook ) => hook . platform === 'codex' ) ;
1523+
1524+ expect ( codex ?. status ) . toBe ( 'n/a' ) ;
1525+ expect ( codex ?. configPath ) . toBe ( pluginCachePath ) ;
1526+ expect ( codex ?. errors ?. some ( ( error ) => error . includes ( 'Failed to read' ) ) ) . toBe ( true ) ;
1527+ expect ( codex ?. selfTest ) . toBeUndefined ( ) ;
1528+ } finally {
1529+ rmSync ( tmpBase , { recursive : true , force : true } ) ;
1530+ }
1531+ } ) ;
1532+
1533+ test ( 'Codex: disabled with read error when config.toml cannot be read' , ( ) => {
1534+ const tmpBase = join ( tmpdir ( ) , `doctor-codex-${ Date . now ( ) } ` ) ;
1535+ const homeDir = join ( tmpBase , 'home' ) ;
1536+ const projectDir = join ( tmpBase , 'project' ) ;
1537+ const codexHome = join ( homeDir , '.codex' ) ;
1538+ const configPath = join ( codexHome , 'config.toml' ) ;
1539+ mkdirSync ( projectDir , { recursive : true } ) ;
1540+ mkdirSync ( codexHome , { recursive : true } ) ;
1541+ _createCodexPluginVersion ( codexHome ) ;
1542+ mkdirSync ( configPath ) ;
1543+
1544+ try {
1545+ const hooks = detectAllHooks ( projectDir , { homeDir } ) ;
1546+ const codex = hooks . find ( ( hook ) => hook . platform === 'codex' ) ;
1547+
1548+ expect ( codex ?. status ) . toBe ( 'disabled' ) ;
1549+ expect ( codex ?. method ) . toBe ( 'plugin cache' ) ;
1550+ expect ( codex ?. configPath ) . toBe ( configPath ) ;
1551+ expect ( codex ?. errors ?. some ( ( error ) => error . includes ( 'Failed to read' ) ) ) . toBe ( true ) ;
1552+ expect ( codex ?. selfTest ) . toBeUndefined ( ) ;
1553+ } finally {
1554+ rmSync ( tmpBase , { recursive : true , force : true } ) ;
1555+ }
1556+ } ) ;
15081557} ) ;
15091558
15101559describe ( 'stripJsonComments' , ( ) => {
0 commit comments