55import { createLogger } from '@sim/logger'
66import { beforeEach , describe , expect , it , vi } from 'vitest'
77import { ResolvedSecretTraceRegistry } from '@/executor/utils/resolved-secret-trace-registry'
8+ import { slackGetUserTool } from '@/tools/slack/get_user'
89
910const { getToolEntry, isKnownTool, isSimExecuted, isClientExecuted } = vi . hoisted ( ( ) => ( {
1011 getToolEntry : vi . fn ( ) ,
@@ -13,8 +14,9 @@ const { getToolEntry, isKnownTool, isSimExecuted, isClientExecuted } = vi.hoiste
1314 isClientExecuted : vi . fn ( ) ,
1415} ) )
1516
16- const { executeAppTool, recordSecretUsage } = vi . hoisted ( ( ) => ( {
17+ const { executeAppTool, recordSecretUsage, searchIntegrationToolsEnabled } = vi . hoisted ( ( ) => ( {
1718 executeAppTool : vi . fn ( ) ,
19+ searchIntegrationToolsEnabled : vi . fn ( async ( ) => true ) ,
1820 recordSecretUsage : vi . fn ( ) ,
1921} ) )
2022
@@ -32,6 +34,15 @@ vi.mock('./router', () => ({
3234 isClientExecuted,
3335} ) )
3436
37+ vi . mock ( '@/lib/mothership/feature-flags' , ( ) => ( {
38+ isSearchIntegrationToolsEnabled : searchIntegrationToolsEnabled ,
39+ } ) )
40+ beforeEach ( ( ) => searchIntegrationToolsEnabled . mockResolvedValue ( true ) )
41+
42+ vi . mock ( '@/tools/metadata' , ( ) => ( {
43+ getToolMetadata : ( id : string ) => ( id === slackGetUserTool . id ? slackGetUserTool : undefined ) ,
44+ } ) )
45+
3546vi . mock ( '@/tools' , ( ) => ( {
3647 executeTool : executeAppTool ,
3748} ) )
@@ -772,3 +783,29 @@ describe('organization direct tool targets', () => {
772783 expect ( targets . environment ) . not . toHaveBeenCalled ( )
773784 } )
774785} )
786+
787+ it . each ( [ { organizationId : 'org-1' } , { workspaceId : 'ws-1' } ] ) (
788+ 'stops a previously admitted Search integration call after flag revocation for %j' ,
789+ async ( scope ) => {
790+ isKnownTool . mockReturnValue ( false )
791+ isClientExecuted . mockReturnValue ( false )
792+ executeAppTool . mockResolvedValue ( { success : true , output : { user : { id : 'U123' } } } )
793+ for ( const enabled of [ true , false , true ] ) {
794+ searchIntegrationToolsEnabled . mockResolvedValue ( enabled )
795+ const result = await executeTool (
796+ 'slack_get_user' ,
797+ { credentialId : 'own' , userId : 'U123' } ,
798+ {
799+ userId : 'person' ,
800+ requestMode : 'assistant' ,
801+ ...scope ,
802+ }
803+ )
804+ expect ( result ) . toEqual (
805+ enabled
806+ ? { success : true , output : { user : { id : 'U123' } } }
807+ : { success : false , error : 'This operation is not available in Search Assistant.' }
808+ )
809+ }
810+ }
811+ )
0 commit comments