@@ -303,19 +303,131 @@ describe('MCPDevlogAdapter', () => {
303303 } ) ;
304304
305305 expect ( completeResult ) . toBeDefined ( ) ;
306- expect ( completeResult . content [ 0 ] . text ) . toContain ( 'Completed devlog' ) ;
307- expect ( completeResult . content [ 0 ] . text ) . toContain ( 'Task completed successfully' ) ;
306+ expect ( ( completeResult . content [ 0 ] as any ) . text ) . toContain ( 'Completed devlog' ) ;
307+ expect ( ( completeResult . content [ 0 ] as any ) . text ) . toContain ( 'Task completed successfully' ) ;
308+
309+ // Verify the completion note was added to the entry
310+ const completedEntry = await adapter . getDevlog ( { id : testEntryId } ) ;
311+ expect ( completedEntry ) . toBeDefined ( ) ;
312+ const entryData = JSON . parse ( ( completedEntry . content [ 0 ] as any ) . text ) ;
313+ expect ( entryData . status ) . toBe ( 'done' ) ;
314+ expect ( entryData . closedAt ) . toBeDefined ( ) ;
315+ expect ( entryData . notes ) . toBeDefined ( ) ;
316+ expect ( entryData . notes . length ) . toBeGreaterThan ( 0 ) ;
317+
318+ // Find the completion note
319+ const completionNote = entryData . notes . find ( ( note : any ) =>
320+ note . content . includes ( 'Completed: Task completed successfully' ) ,
321+ ) ;
322+ expect ( completionNote ) . toBeDefined ( ) ;
323+ expect ( completionNote . category ) . toBe ( 'progress' ) ;
324+ } ) ;
325+
326+ it ( 'should complete devlog entry without summary' , async ( ) => {
327+ // Create a new entry for this test
328+ const createResult = await adapter . createDevlog ( {
329+ title : 'Test Entry for Completion Without Summary' ,
330+ type : 'task' ,
331+ description : 'Test completion without summary' ,
332+ } ) ;
333+
334+ const entryIdMatch = ( createResult . content [ 0 ] as any ) . text . match (
335+ / C r e a t e d d e v l o g e n t r y : ( \d + ) / ,
336+ ) ;
337+ const noSummaryEntryId = parseInt ( entryIdMatch ! [ 1 ] , 10 ) ;
338+
339+ const completeResult = await adapter . completeDevlog ( {
340+ id : noSummaryEntryId ,
341+ } ) ;
342+
343+ expect ( completeResult ) . toBeDefined ( ) ;
344+ expect ( ( completeResult . content [ 0 ] as any ) . text ) . toContain ( 'Completed devlog' ) ;
345+ expect ( ( completeResult . content [ 0 ] as any ) . text ) . not . toContain ( 'with summary' ) ;
346+
347+ // Verify the entry is completed but no completion note was added
348+ const completedEntry = await adapter . getDevlog ( { id : noSummaryEntryId } ) ;
349+ expect ( completedEntry ) . toBeDefined ( ) ;
350+ const entryData = JSON . parse ( ( completedEntry . content [ 0 ] as any ) . text ) ;
351+ expect ( entryData . status ) . toBe ( 'done' ) ;
352+ expect ( entryData . closedAt ) . toBeDefined ( ) ;
353+
354+ // Should not have any completion notes (no summary provided)
355+ const completionNote = entryData . notes . find ( ( note : any ) =>
356+ note . content . includes ( 'Completed:' ) ,
357+ ) ;
358+ expect ( completionNote ) . toBeUndefined ( ) ;
308359 } ) ;
309360
310361 it ( 'should close devlog entry' , async ( ) => {
362+ // Create a new entry for this test since the previous tests modified testEntryId
363+ const createResult = await adapter . createDevlog ( {
364+ title : 'Test Entry for Closure' ,
365+ type : 'task' ,
366+ description : 'Test closure with reason' ,
367+ } ) ;
368+
369+ const entryIdMatch = ( createResult . content [ 0 ] as any ) . text . match (
370+ / C r e a t e d d e v l o g e n t r y : ( \d + ) / ,
371+ ) ;
372+ const closeEntryId = parseInt ( entryIdMatch ! [ 1 ] , 10 ) ;
373+
311374 const closeResult = await adapter . closeDevlog ( {
312- id : testEntryId ,
375+ id : closeEntryId ,
313376 reason : 'No longer needed' ,
314377 } ) ;
315378
316379 expect ( closeResult ) . toBeDefined ( ) ;
317- expect ( closeResult . content [ 0 ] . text ) . toContain ( 'Closed devlog' ) ;
318- expect ( closeResult . content [ 0 ] . text ) . toContain ( 'No longer needed' ) ;
380+ expect ( ( closeResult . content [ 0 ] as any ) . text ) . toContain ( 'Closed devlog' ) ;
381+ expect ( ( closeResult . content [ 0 ] as any ) . text ) . toContain ( 'No longer needed' ) ;
382+
383+ // Verify the closure note was added to the entry
384+ const closedEntry = await adapter . getDevlog ( { id : closeEntryId } ) ;
385+ expect ( closedEntry ) . toBeDefined ( ) ;
386+ const entryData = JSON . parse ( ( closedEntry . content [ 0 ] as any ) . text ) ;
387+ expect ( entryData . status ) . toBe ( 'cancelled' ) ;
388+ expect ( entryData . closedAt ) . toBeDefined ( ) ;
389+ expect ( entryData . notes ) . toBeDefined ( ) ;
390+ expect ( entryData . notes . length ) . toBeGreaterThan ( 0 ) ;
391+
392+ // Find the closure note
393+ const closureNote = entryData . notes . find ( ( note : any ) =>
394+ note . content . includes ( 'Cancelled: No longer needed' ) ,
395+ ) ;
396+ expect ( closureNote ) . toBeDefined ( ) ;
397+ expect ( closureNote . category ) . toBe ( 'progress' ) ;
398+ } ) ;
399+
400+ it ( 'should close devlog entry without reason' , async ( ) => {
401+ // Create a new entry for this test
402+ const createResult = await adapter . createDevlog ( {
403+ title : 'Test Entry for Closure Without Reason' ,
404+ type : 'task' ,
405+ description : 'Test closure without reason' ,
406+ } ) ;
407+
408+ const entryIdMatch = ( createResult . content [ 0 ] as any ) . text . match (
409+ / C r e a t e d d e v l o g e n t r y : ( \d + ) / ,
410+ ) ;
411+ const noReasonEntryId = parseInt ( entryIdMatch ! [ 1 ] , 10 ) ;
412+
413+ const closeResult = await adapter . closeDevlog ( {
414+ id : noReasonEntryId ,
415+ } ) ;
416+
417+ expect ( closeResult ) . toBeDefined ( ) ;
418+ expect ( ( closeResult . content [ 0 ] as any ) . text ) . toContain ( 'Closed devlog' ) ;
419+ expect ( ( closeResult . content [ 0 ] as any ) . text ) . toContain ( 'None provided' ) ;
420+
421+ // Verify the entry is closed but no closure note was added
422+ const closedEntry = await adapter . getDevlog ( { id : noReasonEntryId } ) ;
423+ expect ( closedEntry ) . toBeDefined ( ) ;
424+ const entryData = JSON . parse ( ( closedEntry . content [ 0 ] as any ) . text ) ;
425+ expect ( entryData . status ) . toBe ( 'cancelled' ) ;
426+ expect ( entryData . closedAt ) . toBeDefined ( ) ;
427+
428+ // Should not have any closure notes (no reason provided)
429+ const closureNote = entryData . notes . find ( ( note : any ) => note . content . includes ( 'Cancelled:' ) ) ;
430+ expect ( closureNote ) . toBeUndefined ( ) ;
319431 } ) ;
320432
321433 it ( 'should archive and unarchive devlog entry' , async ( ) => {
0 commit comments