@@ -3,7 +3,7 @@ import { HttpStatus } from '@nestjs/common';
33import { Task } from 'omniboxd/tasks/tasks.entity' ;
44import { TaskCallbackDto } from 'omniboxd/wizard/dto/task-callback.dto' ;
55import { isEmpty } from 'omniboxd/utils/is-empty' ;
6- import { TaskDto } from 'omniboxd/tasks/dto/task.dto' ;
6+ import { TaskDto , TaskMetaDto } from 'omniboxd/tasks/dto/task.dto' ;
77
88/**
99 * Mock wizard worker that simulates the wizard worker service behavior
@@ -515,20 +515,22 @@ describe('Task Pipeline (e2e)', () => {
515515 await MockWizardWorker . waitFor ( async ( ) => {
516516 // Check if extract_tags task was created and completed
517517 const tasksResponse = await client . get (
518- `/api/v1/namespaces/${ client . namespace . id } /tasks?namespace= ${ client . namespace . id } ` ,
518+ `/api/v1/namespaces/${ client . namespace . id } /tasks` ,
519519 ) ;
520520 if ( tasksResponse . status !== 200 ) return false ;
521521
522- const tasks = tasksResponse . body ;
523- const collectTask = tasks . find ( ( t : any ) => t . id === collectTaskId ) ;
524- const extractTagsTask = tasks . find (
525- ( t : any ) =>
522+ const tasks : TaskMetaDto [ ] = tasksResponse . body ;
523+ const collectTask : TaskMetaDto | undefined = tasks . find (
524+ ( t : any ) => t . id === collectTaskId ,
525+ ) ;
526+ const extractTagsTask : TaskMetaDto | undefined = tasks . find (
527+ ( t : TaskMetaDto ) =>
526528 t . function === 'extract_tags' &&
527- t . payload ?. parent_task_id === collectTaskId ,
529+ t . attrs ?. parent_task_id === collectTaskId ,
528530 ) ;
529531
530- expect ( isEmpty ( collectTask ?. exception ) ) . toBe ( true ) ;
531- expect ( isEmpty ( extractTagsTask ?. exception ) ) . toBe ( true ) ;
532+ expect ( collectTask ?. status ) . not . toBe ( 'error' ) ;
533+ expect ( extractTagsTask ?. status ) . not . toBe ( 'error' ) ;
532534
533535 return (
534536 ! isEmpty ( collectTask ?. ended_at ) && ! isEmpty ( extractTagsTask ?. ended_at )
@@ -537,25 +539,31 @@ describe('Task Pipeline (e2e)', () => {
537539
538540 // Verify both tasks completed successfully
539541 const tasksResponse = await client . get (
540- `/api/v1/namespaces/${ client . namespace . id } /tasks?namespace= ${ client . namespace . id } ` ,
542+ `/api/v1/namespaces/${ client . namespace . id } /tasks` ,
541543 ) ;
542- const tasks = tasksResponse . body ;
543-
544- const collectTask = tasks . find ( ( t : any ) => t . id === collectTaskId ) ;
545- const extractTagsTask = tasks . find (
546- ( t : any ) =>
544+ const taskMetaList : TaskMetaDto [ ] = tasksResponse . body ;
545+ const extractTagsTaskMeta = taskMetaList . find (
546+ ( t : TaskMetaDto ) =>
547547 t . function === 'extract_tags' &&
548- t . payload ?. parent_task_id === collectTaskId ,
549- ) ;
548+ t . attrs ?. parent_task_id === collectTaskId ,
549+ ) ! ;
550+ const collectTask : TaskDto = await client
551+ . get ( `/api/v1/namespaces/${ client . namespace . id } /tasks/${ collectTaskId } ` )
552+ . then ( ( res ) => res . body ) ;
553+ const extractTagsTask : TaskDto = await client
554+ . get (
555+ `/api/v1/namespaces/${ client . namespace . id } /tasks/${ extractTagsTaskMeta . id } ` ,
556+ )
557+ . then ( ( res ) => res . body ) ;
550558
551559 expect ( collectTask ) . toBeDefined ( ) ;
552560 expect ( collectTask . ended_at ) . toBeDefined ( ) ;
553- expect ( collectTask . output . markdown ) . toBeDefined ( ) ;
561+ expect ( collectTask . output ? .markdown ) . toBeDefined ( ) ;
554562
555563 expect ( extractTagsTask ) . toBeDefined ( ) ;
556564 expect ( extractTagsTask . ended_at ) . toBeDefined ( ) ;
557- expect ( extractTagsTask . output . tags ) . toBeDefined ( ) ;
558- expect ( extractTagsTask . payload . resource_id ) . toBe ( resourceId ) ;
565+ expect ( extractTagsTask . output ? .tags ) . toBeDefined ( ) ;
566+ expect ( extractTagsTask . attrs ? .resource_id ) . toBe ( resourceId ) ;
559567
560568 const resource = (
561569 await client . get (
@@ -588,16 +596,16 @@ describe('Task Pipeline (e2e)', () => {
588596
589597 await MockWizardWorker . waitFor ( async ( ) => {
590598 const tasksResponse = await client . get (
591- `/api/v1/namespaces/${ client . namespace . id } /tasks?namespace= ${ client . namespace . id } ` ,
599+ `/api/v1/namespaces/${ client . namespace . id } /tasks` ,
592600 ) ;
593- const tasks = tasksResponse . body ;
601+ const tasks : TaskMetaDto [ ] = tasksResponse . body ;
594602 const generateTitleTask = tasks . find (
595- ( t : any ) =>
603+ ( t : TaskMetaDto ) =>
596604 t . function === 'generate_title' &&
597- t . payload . resource_id === resourceId ,
605+ t . attrs ? .resource_id === resourceId ,
598606 ) ;
599607 if ( ! generateTitleTask ) return false ;
600- expect ( isEmpty ( generateTitleTask . exception ) ) . toBe ( true ) ;
608+ expect ( generateTitleTask . status ) . not . toBe ( 'error' ) ;
601609 return ! isEmpty ( generateTitleTask . ended_at ) ;
602610 } ) ;
603611
0 commit comments