@@ -2,7 +2,8 @@ import { envFlagsMockFns, resetEnvFlagsMock, setEnvFlags, workflowsUtilsMock } f
22import { beforeEach , describe , expect , it , vi } from 'vitest'
33import { getExposedIntegrationTools } from '@/lib/integrations/tool-catalog'
44import { ChatPayloadSchema } from '@/lib/mothership/generated/protocol'
5- import { searchIssuesV2Tool } from '@/tools/github/search_issues'
5+ import { searchUsersV2Tool } from '@/tools/github/search_users'
6+ import { gmailListLabelsV2Tool } from '@/tools/gmail/list_labels'
67
78const {
89 mockCreateUserToolSchema,
@@ -153,15 +154,17 @@ vi.mock('@/tools/params', () => ({
153154
154155vi . mock ( '@/tools/metadata' , ( ) => ( {
155156 getToolMetadata : ( id : string ) =>
156- id === 'github_search_issues_v2'
157- ? searchIssuesV2Tool
158- : id === 'gmail_send'
159- ? {
160- id,
161- params : { accessToken : { type : 'string' , visibility : 'hidden' , required : true } } ,
162- oauth : { required : true , provider : 'google-email' } ,
163- }
164- : undefined ,
157+ id === gmailListLabelsV2Tool . id
158+ ? gmailListLabelsV2Tool
159+ : id === 'github_search_users_v2'
160+ ? searchUsersV2Tool
161+ : id === 'gmail_send'
162+ ? {
163+ id,
164+ params : { accessToken : { type : 'string' , visibility : 'hidden' , required : true } } ,
165+ oauth : { required : true , provider : 'google-email' } ,
166+ }
167+ : undefined ,
165168} ) )
166169
167170vi . mock ( '@/lib/uploads/contexts/workspace/workspace-file-manager' , ( ) => ( {
@@ -630,16 +633,16 @@ describe('Assistant payload', () => {
630633 mockCreateUserToolSchema . mockReturnValue ( { type : 'object' , properties : { } } )
631634 mockSearchApprovals . mockResolvedValue ( new Map ( ) )
632635 } )
633- it ( 'discovers the existing GitHub PR-count tool with a personal credential in live Search' , async ( ) => {
636+ it ( 'discovers the existing GitHub user lookup tool with a personal credential in live Search' , async ( ) => {
634637 clearIntegrationToolSchemaCacheForTests ( )
635638 setEnvFlags ( { isLiveEnterpriseSearchEnabled : true } )
636639 mockSearchApprovals . mockResolvedValue ( new Map ( [ [ 'github' , true ] ] ) )
637640 vi . mocked ( getExposedIntegrationTools ) . mockReturnValueOnce ( [
638641 {
639- toolId : searchIssuesV2Tool . id ,
640- config : searchIssuesV2Tool ,
642+ toolId : searchUsersV2Tool . id ,
643+ config : searchUsersV2Tool ,
641644 service : 'github' ,
642- operation : 'search_issues ' ,
645+ operation : 'search_users ' ,
643646 blockType : 'github_v2' ,
644647 owners : [ { service : 'github' , blockType : 'github_v2' } ] ,
645648 } ,
@@ -653,7 +656,7 @@ describe('Assistant payload', () => {
653656 } )
654657 expect ( tools ) . toHaveLength ( 1 )
655658 expect ( tools [ 0 ] ) . toMatchObject ( {
656- name : 'github_search_issues_v2 ' ,
659+ name : 'github_search_users_v2 ' ,
657660 oauth : { provider : 'github-repositories' } ,
658661 input_schema : { required : expect . arrayContaining ( [ 'q' , 'credentialId' ] ) } ,
659662 } )
@@ -668,14 +671,25 @@ describe('Assistant payload', () => {
668671 ) . toEqual ( [ ] )
669672 } )
670673 it ( 'advertises approved personal organization integrations and rechecks revocation' , async ( ) => {
674+ clearIntegrationToolSchemaCacheForTests ( )
675+ vi . mocked ( getExposedIntegrationTools ) . mockReturnValueOnce ( [
676+ {
677+ toolId : gmailListLabelsV2Tool . id ,
678+ config : gmailListLabelsV2Tool ,
679+ service : 'gmail' ,
680+ operation : 'list_labels' ,
681+ blockType : 'gmail' ,
682+ owners : [ { service : 'gmail' , blockType : 'gmail' } ] ,
683+ } ,
684+ ] )
671685 mockSearchApprovals . mockResolvedValue ( new Map ( [ [ 'gmail' , true ] ] ) )
672686 const options = {
673687 schemaSurface : 'copilot' as const ,
674688 personalAccountsOnly : true ,
675689 organizationId : 'org' ,
676690 }
677691 const approved = await buildIntegrationToolSchemas ( 'person' , options )
678- expect ( approved . map ( ( tool ) => tool . name ) ) . toContain ( 'gmail_send' )
692+ expect ( approved . map ( ( tool ) => tool . name ) ) . toEqual ( [ 'gmail_list_labels_v2' ] )
679693 mockSearchApprovals . mockResolvedValue ( new Map ( [ [ 'gmail' , false ] ] ) )
680694 expect ( await buildIntegrationToolSchemas ( 'person' , options ) ) . toEqual ( [ ] )
681695 mockSearchApprovals . mockResolvedValue ( new Map ( [ [ 'gmail' , true ] ] ) )
@@ -709,7 +723,7 @@ describe('Assistant payload', () => {
709723 expect ( mockTrackChatUpload ) . not . toHaveBeenCalled ( )
710724 } )
711725
712- it ( 'forwards organization scope without workspace, integration, or desktop authority' , async ( ) => {
726+ it ( 'forwards organization scope without workspace or desktop authority' , async ( ) => {
713727 const payload = await buildCopilotRequestPayload (
714728 {
715729 message : 'Find the policy' ,
@@ -726,13 +740,13 @@ describe('Assistant payload', () => {
726740 { selectedModel : '' }
727741 )
728742 expect ( payload . organizationId ) . toBe ( 'org-1' )
729- expect ( payload ) . not . toHaveProperty ( 'integrationCatalog' )
743+ expect ( payload . integrationCatalog ) . toEqual ( { mcpServerIds : [ ] } )
730744 expect ( payload ) . not . toHaveProperty ( 'workspaceId' )
731745 expect ( payload ) . not . toHaveProperty ( 'desktopCapabilities' )
732746 expect ( payload ) . not . toHaveProperty ( 'integrationTools' )
733747 } )
734748
735- it ( 'keeps the shared search scope without an integration gateway catalog ' , async ( ) => {
749+ it ( 'keeps the shared search scope with native discovery and no MCP servers ' , async ( ) => {
736750 clearIntegrationToolSchemaCacheForTests ( )
737751 const payload = await buildCopilotRequestPayload (
738752 {
@@ -762,7 +776,7 @@ describe('Assistant payload', () => {
762776 expect ( payload ) . not . toHaveProperty ( field )
763777 }
764778 expect ( payload ) . not . toHaveProperty ( 'integrationTools' )
765- expect ( payload ) . not . toHaveProperty ( 'integrationCatalog' )
779+ expect ( payload . integrationCatalog ) . toEqual ( { mcpServerIds : [ ] } )
766780 } )
767781} )
768782
0 commit comments