@@ -37,6 +37,7 @@ const {
3737 getLatestHumanComment,
3838 getLatestReworkComment,
3939 listProjects,
40+ listProjectTaskOverviews,
4041 findProjectById,
4142 createProject,
4243 updateProject,
@@ -253,6 +254,68 @@ describe("data layer", () => {
253254 } ) ;
254255 } ) ;
255256
257+ describe ( "listProjectTaskOverviews" , ( ) => {
258+ it ( "returns compact per-project aggregates and limited previews" , ( ) => {
259+ seedProject ( "proj-2" ) ;
260+ createTask ( {
261+ projectId : "proj-1" ,
262+ title : "Backlog A" ,
263+ description : "D" ,
264+ isFix : true ,
265+ tags : [ "x" ] ,
266+ } ) ;
267+ const firstBacklog = createTask ( {
268+ projectId : "proj-1" ,
269+ title : "Backlog first by position" ,
270+ description : "D" ,
271+ position : 10 ,
272+ } ) ! ;
273+ const backlog = listTasks ( "proj-1" ) . find ( ( task ) => task . title === "Backlog A" ) ! ;
274+ updateTask ( backlog . id , {
275+ tokenInput : 5 ,
276+ tokenOutput : 6 ,
277+ tokenTotal : 11 ,
278+ } ) ;
279+ const done = createTask ( {
280+ projectId : "proj-1" ,
281+ title : "Done B" ,
282+ description : "D" ,
283+ autoMode : false ,
284+ } ) ! ;
285+ updateTaskStatus ( done . id , "done" , {
286+ retryCount : 2 ,
287+ } ) ;
288+ updateTask ( done . id , {
289+ tokenInput : 10 ,
290+ tokenOutput : 15 ,
291+ tokenTotal : 25 ,
292+ costUsd : 0.5 ,
293+ } ) ;
294+ createTask ( { projectId : "proj-2" , title : "Other project" , description : "D" } ) ;
295+
296+ const overviews = listProjectTaskOverviews ( 1 ) ;
297+ const proj1 = overviews . find ( ( overview ) => overview . projectId === "proj-1" ) ! ;
298+ const proj2 = overviews . find ( ( overview ) => overview . projectId === "proj-2" ) ! ;
299+
300+ expect ( proj1 . totalTasks ) . toBe ( 3 ) ;
301+ expect ( proj1 . completedTasks ) . toBe ( 1 ) ;
302+ expect ( proj1 . backlogTasks ) . toBe ( 2 ) ;
303+ expect ( proj1 . fixTasks ) . toBe ( 1 ) ;
304+ expect ( proj1 . totalRetries ) . toBe ( 2 ) ;
305+ expect ( proj1 . totalTokenInput ) . toBe ( 15 ) ;
306+ expect ( proj1 . totalTokenOutput ) . toBe ( 21 ) ;
307+ expect ( proj1 . totalTokenTotal ) . toBe ( 36 ) ;
308+ expect ( proj1 . totalCostUsd ) . toBe ( 0.5 ) ;
309+ expect ( proj1 . statusCounts . backlog ) . toBe ( 2 ) ;
310+ expect ( proj1 . statusCounts . done ) . toBe ( 1 ) ;
311+ expect ( proj1 . statusPreviews . backlog ) . toEqual ( [
312+ { id : firstBacklog . id , title : "Backlog first by position" } ,
313+ ] ) ;
314+ expect ( proj1 . statusPreviews . done ) . toEqual ( [ { id : done . id , title : "Done B" } ] ) ;
315+ expect ( proj2 . totalTasks ) . toBe ( 1 ) ;
316+ } ) ;
317+ } ) ;
318+
256319 describe ( "updateTask" , ( ) => {
257320 it ( "updates basic fields" , ( ) => {
258321 const t = createTask ( { projectId : "proj-1" , title : "Old" , description : "D" } ) ;
0 commit comments