1
- import { ALL_TOOLS } from '../../src/server/tools.js' ;
2
1
import { TaskManager } from '../../src/server/TaskManager.js' ;
3
2
import * as os from 'node:os' ;
4
3
import * as path from 'node:path' ;
@@ -29,181 +28,6 @@ describe('TaskManager Integration', () => {
29
28
}
30
29
} ) ;
31
30
32
- it ( 'should handle project tool actions' , async ( ) => {
33
- // Test project creation
34
- const createResult = await server . createProject (
35
- 'Test project' ,
36
- [
37
- {
38
- title : 'Test task' ,
39
- description : 'Test description'
40
- }
41
- ] ,
42
- 'Test plan'
43
- ) as {
44
- status : string ;
45
- projectId : string ;
46
- totalTasks : number ;
47
- tasks : { id : string ; title : string ; description : string } [ ] ;
48
- message : string
49
- } ;
50
-
51
- expect ( createResult . status ) . toBe ( 'planned' ) ;
52
- expect ( createResult . projectId ) . toBeDefined ( ) ;
53
- expect ( createResult . totalTasks ) . toBe ( 1 ) ;
54
-
55
- // Test project listing
56
- const listResult = await server . listProjects ( ) as {
57
- status : string ;
58
- message : string ;
59
- projects : { projectId : string ; initialPrompt : string ; totalTasks : number ; completedTasks : number ; approvedTasks : number } [ ] ;
60
- } ;
61
- expect ( listResult . status ) . toBe ( 'projects_listed' ) ;
62
- expect ( listResult . projects ) . toHaveLength ( 1 ) ;
63
-
64
- // Test project deletion
65
- const projectId = createResult . projectId ;
66
- const projectIndex = server [ "data" ] . projects . findIndex ( ( p ) => p . projectId === projectId ) ;
67
- server [ "data" ] . projects . splice ( projectIndex , 1 ) ;
68
- await server [ "saveTasks" ] ( ) ;
69
-
70
- // Verify deletion
71
- const listAfterDelete = await server . listProjects ( ) as {
72
- status : string ;
73
- message : string ;
74
- projects : { projectId : string ; initialPrompt : string ; totalTasks : number ; completedTasks : number ; approvedTasks : number } [ ] ;
75
- } ;
76
- expect ( listAfterDelete . projects ) . toHaveLength ( 0 ) ;
77
- } ) ;
78
-
79
- it ( 'should handle task tool actions' , async ( ) => {
80
- // Create a project first
81
- const createResult = await server . createProject (
82
- 'Test project' ,
83
- [
84
- {
85
- title : 'Test task' ,
86
- description : 'Test description'
87
- }
88
- ] ,
89
- 'Test plan'
90
- ) as {
91
- status : string ;
92
- projectId : string ;
93
- totalTasks : number ;
94
- tasks : { id : string ; title : string ; description : string } [ ] ;
95
- message : string
96
- } ;
97
-
98
- const projectId = createResult . projectId ;
99
- const taskId = createResult . tasks [ 0 ] . id ;
100
-
101
- // Test task reading
102
- const readResult = await server . openTaskDetails ( taskId ) ;
103
- expect ( readResult . status ) . toBe ( 'task_details' ) ;
104
- if ( readResult . status === 'task_details' && readResult . task ) {
105
- expect ( readResult . task . id ) . toBe ( taskId ) ;
106
- }
107
-
108
- // Test task updating
109
- const updatedTask = await server . updateTask ( projectId , taskId , {
110
- title : "Updated task" ,
111
- description : "Updated description"
112
- } ) ;
113
- expect ( updatedTask . title ) . toBe ( "Updated task" ) ;
114
- expect ( updatedTask . description ) . toBe ( "Updated description" ) ;
115
- expect ( updatedTask . status ) . toBe ( "not started" ) ;
116
-
117
- // Also update the status directly
118
- const task = server [ "data" ] . projects . find ( p => p . projectId === projectId ) ?. tasks . find ( t => t . id === taskId ) ;
119
- if ( task ) {
120
- task . status = 'in progress' ;
121
- await server [ "saveTasks" ] ( ) ;
122
- }
123
-
124
- // Test task deletion
125
- const deleteResult = await server . deleteTask (
126
- projectId ,
127
- taskId
128
- ) as {
129
- status : string ;
130
- message : string ;
131
- } ;
132
- expect ( deleteResult . status ) . toBe ( 'task_deleted' ) ;
133
-
134
- // Verify deletion
135
- const readAfterDelete = await server . openTaskDetails ( taskId ) as {
136
- status : string ;
137
- message ?: string ;
138
- } ;
139
- expect ( readAfterDelete . status ) . toBe ( 'task_not_found' ) ;
140
- } ) ;
141
-
142
- it ( 'should get the next task in a project' , async ( ) => {
143
- // Create a project with multiple tasks
144
- const createResult = await server . createProject (
145
- 'Test project with multiple tasks' ,
146
- [
147
- {
148
- title : 'Task 1' ,
149
- description : 'Description 1'
150
- } ,
151
- {
152
- title : 'Task 2' ,
153
- description : 'Description 2'
154
- }
155
- ]
156
- ) as {
157
- projectId : string ;
158
- tasks : { id : string } [ ] ;
159
- } ;
160
-
161
- const projectId = createResult . projectId ;
162
-
163
- // Get the next task
164
- const nextTaskResult = await server . getNextTask ( projectId ) ;
165
-
166
- expect ( nextTaskResult . status ) . toBe ( 'next_task' ) ;
167
- if ( nextTaskResult . status === 'next_task' && nextTaskResult . task ) {
168
- expect ( nextTaskResult . task . id ) . toBe ( createResult . tasks [ 0 ] . id ) ;
169
- }
170
- } ) ;
171
-
172
- it ( 'should approve a completed task' , async ( ) => {
173
- // Create a project with a task
174
- const createResult = await server . createProject (
175
- 'Test project for approval' ,
176
- [
177
- {
178
- title : 'Task to approve' ,
179
- description : 'Description of task to approve'
180
- }
181
- ]
182
- ) as {
183
- projectId : string ;
184
- tasks : { id : string } [ ] ;
185
- } ;
186
-
187
- const projectId = createResult . projectId ;
188
- const taskId = createResult . tasks [ 0 ] . id ;
189
-
190
- // Mark the task as done
191
- const task = server [ "data" ] . projects . find ( p => p . projectId === projectId ) ?. tasks . find ( t => t . id === taskId ) ;
192
- if ( task ) {
193
- task . status = 'done' ;
194
- task . completedDetails = 'Completed task details' ;
195
- await server [ "saveTasks" ] ( ) ;
196
- }
197
-
198
- // Approve the task
199
- const approveResult = await server . approveTaskCompletion ( projectId , taskId ) ;
200
-
201
- expect ( approveResult . status ) . toBe ( 'task_approved' ) ;
202
- if ( approveResult . status === 'task_approved' && approveResult . task ) {
203
- expect ( approveResult . task . approved ) . toBe ( true ) ;
204
- }
205
- } ) ;
206
-
207
31
it ( 'should handle file persistence correctly' , async ( ) => {
208
32
// Create initial data
209
33
const project = await server . createProject ( "Persistent Project" , [
@@ -587,4 +411,5 @@ describe('TaskManager Integration', () => {
587
411
const projectState = await server1 . listProjects ( "completed" ) ;
588
412
expect ( projectState . projects . find ( p => p . projectId === project . projectId ) ) . toBeDefined ( ) ;
589
413
} ) ;
590
- } ) ;
414
+ } ) ;
415
+
0 commit comments