@@ -56,40 +56,59 @@ Lorem ipsum.`
5656 expect ( result ) . not . toContain ( 'src/main.ts' )
5757 } )
5858
59- it ( 'extracts nested, relative paths with line and column numbers' , ( ) => {
60- const text =
61- '`./src/features/checkpoints/actions/restore-checkpoint.ts:56:9`'
59+ it ( 'extracts paths starting with a slash' , ( ) => {
60+ const text = 'Look at /src/hello.ts'
61+ const workspace_files = [ 'src/hello.ts' ]
62+ const result = extract_paths_from_text ( { text, workspace_files } )
63+
64+ expect ( result ) . toContain ( 'src/hello.ts' )
65+ } )
66+
67+ it ( 'extracts paths from an ASCII tree' , ( ) => {
68+ const text = `Here is the project structure:
69+ └── apps
70+ ├── editor
71+ │ └── src
72+ │ ├── features
73+ │ │ └── checkpoints
74+ │ │ └── actions
75+ │ │ └── restore-checkpoint.ts
76+ │ └── utils
77+ │ ├── ascii-tree.ts
78+ │ └── extract-paths-from-text
79+ │ ├── extract-paths-from-text.spec.ts
80+ │ └── extract-paths-from-text.ts
81+ └── server
82+ └── src
83+ └── features
84+ └── checkpoints
85+ └── actions
86+ └── restore-checkpoint.ts`
87+
6288 const workspace_files = [
6389 'apps/editor/src/features/checkpoints/actions/restore-checkpoint.ts' ,
64- 'apps/server/src/features/checkpoints/actions/restore-checkpoint.ts'
90+ 'apps/editor/src/utils/ascii-tree.ts' ,
91+ 'apps/editor/src/utils/extract-paths-from-text/extract-paths-from-text.spec.ts' ,
92+ 'apps/editor/src/utils/extract-paths-from-text/extract-paths-from-text.ts' ,
93+ 'apps/server/src/features/checkpoints/actions/restore-checkpoint.ts' ,
94+ 'other-file.ts'
6595 ]
96+
6697 const result = extract_paths_from_text ( { text, workspace_files } )
6798
6899 expect ( result ) . toContain (
69100 'apps/editor/src/features/checkpoints/actions/restore-checkpoint.ts'
70101 )
102+ expect ( result ) . toContain ( 'apps/editor/src/utils/ascii-tree.ts' )
71103 expect ( result ) . toContain (
72- 'apps/server /src/features/checkpoints/actions/restore-checkpoint .ts'
104+ 'apps/editor /src/utils/extract-paths-from-text/extract-paths-from-text.spec .ts'
73105 )
74- } )
75-
76- it ( 'extracts path by filename' , ( ) => {
77- const text = 'Edit the restore-checkpoint.ts file.'
78- const workspace_files = [
79- 'apps/editor/src/features/checkpoints/actions/restore-checkpoint.ts'
80- ]
81- const result = extract_paths_from_text ( { text, workspace_files } )
82-
83106 expect ( result ) . toContain (
84- 'apps/editor/src/features/checkpoints/actions/restore-checkpoint .ts'
107+ 'apps/editor/src/utils/extract-paths-from-text/extract-paths-from-text .ts'
85108 )
86- } )
87-
88- it ( 'extracts paths starting with a slash' , ( ) => {
89- const text = 'Look at /src/hello.ts'
90- const workspace_files = [ 'src/hello.ts' ]
91- const result = extract_paths_from_text ( { text, workspace_files } )
92-
93- expect ( result ) . toContain ( 'src/hello.ts' )
109+ expect ( result ) . toContain (
110+ 'apps/server/src/features/checkpoints/actions/restore-checkpoint.ts'
111+ )
112+ expect ( result ) . not . toContain ( 'other-file.ts' )
94113 } )
95114} )
0 commit comments