@@ -16,7 +16,7 @@ describe('scanAppDirectory', () => {
1616 readDir : mock ( ( dir : string ) => {
1717 if ( dir === 'app' ) {
1818 return Promise . resolve ( [
19- { name : 'page.tsx' , type : 'file' , isSymlink : false }
19+ { name : 'page.tsx' , type : 'file' as const , isSymlink : false }
2020 ] ) ;
2121 }
2222 return Promise . resolve ( [ ] ) ;
@@ -29,16 +29,16 @@ describe('scanAppDirectory', () => {
2929 } ;
3030
3131 const result = await scanAppDirectory ( mockSandboxManager as any , 'app' ) ;
32-
32+
3333 expect ( result ) . toHaveLength ( 1 ) ;
34- expect ( result [ 0 ] . name ) . toBe ( 'Home' ) ; // Root page is named "Home"
35- expect ( result [ 0 ] . path ) . toBe ( '/' ) ; // Root page has path "/"
34+ expect ( result [ 0 ] ? .name ) . toBe ( 'Home' ) ; // Root page is named "Home"
35+ expect ( result [ 0 ] ? .path ) . toBe ( '/' ) ; // Root page has path "/"
3636 } ) ;
3737
3838 test ( 'should handle directory with only page file' , async ( ) => {
3939 const mockSandboxManager : MockSandboxManager = {
4040 readDir : mock ( ( ) => Promise . resolve ( [
41- { name : 'page.tsx' , type : 'file' , isSymlink : false }
41+ { name : 'page.tsx' , type : 'file' as const , isSymlink : false }
4242 ] ) ) ,
4343 readFile : mock ( ( path : string ) => {
4444 return Promise . resolve ( 'export default function Page() { return <div>Test</div>; }' ) ;
@@ -47,17 +47,17 @@ describe('scanAppDirectory', () => {
4747 } ;
4848
4949 const result = await scanAppDirectory ( mockSandboxManager as any , 'app' ) ;
50-
50+
5151 expect ( result ) . toHaveLength ( 1 ) ;
52- expect ( result [ 0 ] . name ) . toBe ( 'Home' ) ;
53- expect ( result [ 0 ] . path ) . toBe ( '/' ) ;
52+ expect ( result [ 0 ] ? .name ) . toBe ( 'Home' ) ;
53+ expect ( result [ 0 ] ? .path ) . toBe ( '/' ) ;
5454 } ) ;
5555
5656 test ( 'should handle directories without page files' , async ( ) => {
5757 const mockSandboxManager : MockSandboxManager = {
5858 readDir : mock ( ( ) => Promise . resolve ( [
59- { name : 'components' , type : 'directory' , isSymlink : false } ,
60- { name : 'utils' , type : 'directory' , isSymlink : false }
59+ { name : 'components' , type : 'directory' as const , isSymlink : false } ,
60+ { name : 'utils' , type : 'directory' as const , isSymlink : false }
6161 ] ) ) ,
6262 readFile : mock ( ( path : string ) => {
6363 return Promise . resolve ( 'export default function Page() { return <div>Test</div>; }' ) ;
@@ -66,7 +66,7 @@ describe('scanAppDirectory', () => {
6666 } ;
6767
6868 const result = await scanAppDirectory ( mockSandboxManager as any , 'app' ) ;
69-
69+
7070 // Should return empty array when no page files found
7171 expect ( result ) . toEqual ( [ ] ) ;
7272 } ) ;
@@ -88,7 +88,7 @@ describe('scanAppDirectory', () => {
8888 test ( 'should handle file read errors gracefully' , async ( ) => {
8989 const mockSandboxManager : MockSandboxManager = {
9090 readDir : mock ( ( ) => Promise . resolve ( [
91- { name : 'page.tsx' , type : 'file' , isSymlink : false }
91+ { name : 'page.tsx' , type : 'file' as const , isSymlink : false }
9292 ] ) ) ,
9393 readFile : mock ( ( ) => {
9494 throw new Error ( 'File read error' ) ;
@@ -97,11 +97,11 @@ describe('scanAppDirectory', () => {
9797 } ;
9898
9999 const result = await scanAppDirectory ( mockSandboxManager as any , 'app' ) ;
100-
100+
101101 // Should still return page structure even if file reading fails
102102 expect ( result ) . toHaveLength ( 1 ) ;
103- expect ( result [ 0 ] . name ) . toBe ( 'Home' ) ; // Root page is named "Home"
104- expect ( result [ 0 ] . path ) . toBe ( '/' ) ; // Root page path
103+ expect ( result [ 0 ] ? .name ) . toBe ( 'Home' ) ; // Root page is named "Home"
104+ expect ( result [ 0 ] ? .path ) . toBe ( '/' ) ; // Root page path
105105 } ) ;
106106
107107 test ( 'should handle directory read errors' , async ( ) => {
0 commit comments