@@ -578,11 +578,14 @@ describe('EntriesImport', () => {
578578 if ( path . includes ( 'schema.json' ) ) {
579579 return [ contentTypeWithoutFieldRules ] ;
580580 }
581- return { } ;
581+ if ( path . includes ( 'field_rules_ct.json' ) ) {
582+ return contentTypeWithoutFieldRules ;
583+ }
584+ return undefined ;
582585 } ) ;
583586
584- // Override FsUtility.readFile for this test
585- ( FsUtility . prototype . readFile as sinon . SinonStub ) . returns ( contentTypeWithoutFieldRules ) ;
587+ // Override FsUtility.readdir for this test
588+ ( FsUtility . prototype . readdir as sinon . SinonStub ) . returns ( [ 'field_rules_ct.json' ] ) ;
586589
587590 await entriesImport [ 'updateFieldRules' ] ( ) ;
588591
@@ -3124,25 +3127,17 @@ describe('EntriesImport', () => {
31243127 it ( 'should handle content type fetch error' , async ( ) => {
31253128 const mockContentTypes = [ mockData . simpleContentType , mockData . contentTypeWithReferences ] ;
31263129
3127- // Configure FsUtility.readFile to return the right content type based on file name
3128- ( FsUtility . prototype . readFile as sinon . SinonStub ) . callsFake ( ( filePath : string ) => {
3129- if ( filePath . includes ( 'simple_ct.json' ) ) return JSON . stringify ( mockData . simpleContentType ) ;
3130- if ( filePath . includes ( 'ref_ct.json' ) ) return JSON . stringify ( mockData . contentTypeWithReferences ) ;
3131- return '{}' ;
3132- } ) ;
3133-
3130+ // Configure FsUtility.readFile to handle all file reads (for both fsUtil and readContentTypeSchemas)
31343131 fsUtilityReadFileStub . callsFake ( ( filePath ) => {
3135- console . log ( 'fsUtil.readFile called with path:' , filePath ) ;
31363132 if ( filePath . includes ( 'field_rules_uid.json' ) ) {
3137- console . log ( 'Returning field rules data' ) ;
31383133 return [ 'simple_ct' , 'ref_ct' ] ; // array of strings
31393134 }
3135+ if ( filePath . includes ( 'simple_ct.json' ) ) return mockData . simpleContentType ;
3136+ if ( filePath . includes ( 'ref_ct.json' ) ) return mockData . contentTypeWithReferences ;
31403137 if ( filePath . includes ( 'schema.json' ) ) {
3141- console . log ( 'Returning schema data' ) ;
31423138 return mockContentTypes ;
31433139 }
3144- console . log ( 'Returning empty array' ) ;
3145- return [ ] ;
3140+ return undefined ;
31463141 } ) ;
31473142
31483143 const mockContentType = {
@@ -3166,16 +3161,17 @@ describe('EntriesImport', () => {
31663161 it ( 'should handle content type update error' , async ( ) => {
31673162 const mockContentTypes = [ mockData . simpleContentType , mockData . contentTypeWithReferences ] ;
31683163
3169- ( FsUtility . prototype . readFile as sinon . SinonStub ) . returns ( JSON . stringify ( mockData . simpleContentType ) ) ;
3164+ ( FsUtility . prototype . readdir as sinon . SinonStub ) . returns ( [ 'simple_ct.json' ] ) ;
31703165
31713166 fsUtilityReadFileStub . callsFake ( ( path ) => {
31723167 if ( path . includes ( 'field_rules_uid.json' ) ) {
31733168 return [ 'simple_ct' ] ; // array of strings
31743169 }
3170+ if ( path . includes ( 'simple_ct.json' ) ) return mockData . simpleContentType ;
31753171 if ( path . includes ( 'schema.json' ) ) {
31763172 return mockContentTypes ;
31773173 }
3178- return [ ] ;
3174+ return undefined ;
31793175 } ) ;
31803176
31813177 const mockUpdate = sinon . stub ( ) . rejects ( new Error ( 'Update failed' ) ) ;
@@ -3205,16 +3201,17 @@ describe('EntriesImport', () => {
32053201 it ( 'should skip when content type not found' , async ( ) => {
32063202 const mockContentTypes = [ mockData . simpleContentType , mockData . contentTypeWithReferences ] ;
32073203
3208- ( FsUtility . prototype . readFile as sinon . SinonStub ) . returns ( JSON . stringify ( mockData . simpleContentType ) ) ;
3204+ ( FsUtility . prototype . readdir as sinon . SinonStub ) . returns ( [ 'simple_ct.json' ] ) ;
32093205
32103206 fsUtilityReadFileStub . callsFake ( ( path ) => {
32113207 if ( path . includes ( 'field_rules_uid.json' ) ) {
32123208 return [ 'simple_ct' ] ; // array of strings
32133209 }
3210+ if ( path . includes ( 'simple_ct.json' ) ) return mockData . simpleContentType ;
32143211 if ( path . includes ( 'schema.json' ) ) {
32153212 return mockContentTypes ;
32163213 }
3217- return [ ] ;
3214+ return undefined ;
32183215 } ) ;
32193216
32203217 const mockContentType = {
@@ -3249,16 +3246,17 @@ describe('EntriesImport', () => {
32493246 delete contentTypeWithoutRules . field_rules ;
32503247 const mockContentTypes = [ contentTypeWithoutRules ] ;
32513248
3252- ( FsUtility . prototype . readFile as sinon . SinonStub ) . returns ( JSON . stringify ( contentTypeWithoutRules ) ) ;
3249+ ( FsUtility . prototype . readdir as sinon . SinonStub ) . returns ( [ 'simple_ct.json' ] ) ;
32533250
32543251 fsUtilityReadFileStub . callsFake ( ( path ) => {
32553252 if ( path . includes ( 'field_rules_uid.json' ) ) {
32563253 return [ 'simple_ct' ] ; // array of strings
32573254 }
3255+ if ( path . includes ( 'simple_ct.json' ) ) return contentTypeWithoutRules ;
32583256 if ( path . includes ( 'schema.json' ) ) {
32593257 return mockContentTypes ;
32603258 }
3261- return [ ] ;
3259+ return undefined ;
32623260 } ) ;
32633261
32643262 const mockLog = {
0 commit comments