@@ -21,6 +21,7 @@ import { sleep } from '@sim/utils/helpers'
2121import { generateId } from '@sim/utils/id'
2222import { eq , inArray } from 'drizzle-orm'
2323import { afterAll , afterEach , beforeAll , describe , expect , it , vi } from 'vitest'
24+ import { workspaceKnowledgeSearchDataSchema } from '@/lib/api/contracts/mothership-assistant-tools'
2425import { env } from '@/lib/core/config/env'
2526import { runWithOutboundOrganization } from '@/lib/core/network/context.server'
2627import { createManagedMcpConnector } from '@/lib/credential-groups/managed-mcp-service'
@@ -493,6 +494,12 @@ describe('managed Search operation sessions', () => {
493494 'Second topology' ,
494495 TITLE ,
495496 ] )
497+ expect ( found . results ) . toEqual (
498+ expect . arrayContaining ( [
499+ expect . objectContaining ( { documentName : TITLE , queryIndexes : [ 0 ] } ) ,
500+ expect . objectContaining ( { documentName : 'Second topology' , queryIndexes : [ 1 ] } ) ,
501+ ] )
502+ )
496503 expect ( found . retrieval . status ) . toBe ( 'complete' )
497504 expect (
498505 found . live ?. accounts . map ( ( { queryIndex, status } ) => ( { queryIndex, status } ) )
@@ -576,6 +583,12 @@ describe('managed Search operation sessions', () => {
576583 'Second topology' ,
577584 TITLE ,
578585 ] )
586+ expect ( parallel . results ) . toEqual (
587+ expect . arrayContaining ( [
588+ expect . objectContaining ( { documentName : TITLE , queryIndexes : [ 0 ] } ) ,
589+ expect . objectContaining ( { documentName : 'Second topology' , queryIndexes : [ 1 ] } ) ,
590+ ] )
591+ )
579592
580593 for ( const options of [ { project : '42' } , { topK : 5 } , { startDate : '2026-09-01T00:00:00Z' } ] ) {
581594 expect ( ( await browse ( 0 , options ) ) . live ?. accounts [ 0 ] ?. status ) . not . toBe ( 'unavailable' )
@@ -633,17 +646,27 @@ describe('managed Search operation sessions', () => {
633646 kind : 'lucidchart' ,
634647 accountId : actor . credentialId ,
635648 } ,
649+ {
650+ provider : 'lucid' ,
651+ query : 'architecture' ,
652+ kind : 'lucidchart' ,
653+ accountId : actor . credentialId ,
654+ } ,
636655 ] ,
637656 } ,
638657 } )
639658 expect ( found . results ) . toHaveLength ( 1 )
659+ expect ( workspaceKnowledgeSearchDataSchema . parse ( found ) . results [ 0 ] ) . toMatchObject ( {
660+ queryIndexes : [ 1 , 2 ] ,
661+ } )
640662 expect ( found . live ?. accounts ) . toEqual ( [
641663 expect . objectContaining ( {
642664 queryIndex : 0 ,
643665 folders : [ { id : '42' , name : 'Architecture' } ] ,
644666 nextCursor : expect . any ( String ) ,
645667 } ) ,
646668 expect . objectContaining ( { queryIndex : 1 , status : 'ok' } ) ,
669+ expect . objectContaining ( { queryIndex : 2 , status : 'ok' } ) ,
647670 ] )
648671 expect ( openTransports . size ) . toBe ( 0 )
649672 } )
0 commit comments