1- import { beforeEach , describe , expect , it , vi } from 'vitest'
1+ import { afterEach , beforeEach , describe , expect , it , vi } from 'vitest'
22import { clearAtlassianCloudIdCache } from '@/lib/atlassian/discovery'
33import { createConfluenceClient } from '@/lib/internal/confluence/client'
44import { createJiraClient } from '@/lib/internal/jira/client'
5- import {
6- assertAssistantIntegrationCall ,
7- isAssistantIntegrationTool ,
8- } from '@/lib/mothership/assistant/tool-policy'
5+ import { assertAssistantIntegrationCall } from '@/lib/mothership/assistant/tool-policy'
96import { getToolMetadata } from '@/tools/metadata'
10- import { getToolIds } from '@/tools/tool-ids'
117
128vi . unmock ( '@/tools/metadata' )
13- vi . unmock ( '@/tools/tool-ids' )
149
1510const CLOUD_ID = '12345678-1234-1234-1234-123456789012'
1611const OTHER_CLOUD_ID = '12345678-1234-1234-1234-123456789013'
@@ -26,29 +21,23 @@ describe('Atlassian Assistant resource selection', () => {
2621 vi . stubGlobal ( 'fetch' , fetchMock )
2722 } )
2823
29- it . each ( [ 'jira' , 'confluence' ] ) (
30- 'offers %s operations with a site selector and personal credential' ,
31- ( service ) => {
32- const tools = getToolIds ( )
33- . filter ( ( id ) => id . startsWith ( `${ service } _` ) )
34- . map ( ( id ) => getToolMetadata ( id ) )
35- . filter ( ( tool ) => tool ?. params . domain )
36- expect ( tools . length ) . toBeGreaterThan ( 0 )
37- for ( const tool of tools ) {
38- expect ( tool ?. params . domain . visibility , tool ?. id ) . toBe ( 'user-or-llm' )
39- expect ( isAssistantIntegrationTool ( tool ) , tool ?. id ) . toBe ( true )
24+ afterEach ( ( ) => vi . unstubAllGlobals ( ) )
25+
26+ it . each ( [ 'jira_get_project' , 'confluence_list_spaces' ] ) (
27+ 'allows site selection for %s without accepting credential overrides' ,
28+ ( toolId ) => {
29+ const tool = getToolMetadata ( toolId )
30+ expect ( ( ) =>
31+ assertAssistantIntegrationCall ( tool , { credentialId : 'mine' , domain : DOMAIN } )
32+ ) . not . toThrow ( )
33+ for ( const name of [ 'cloudId' , 'accessToken' , '_context' ] ) {
4034 expect ( ( ) =>
41- assertAssistantIntegrationCall ( tool , { credentialId : 'mine' , domain : DOMAIN } )
42- ) . not . toThrow ( )
43- for ( const name of [ 'cloudId' , 'accessToken' , '_context' ] ) {
44- expect ( ( ) =>
45- assertAssistantIntegrationCall ( tool , {
46- credentialId : 'mine' ,
47- domain : DOMAIN ,
48- [ name ] : 'override' ,
49- } )
50- ) . toThrow ( )
51- }
35+ assertAssistantIntegrationCall ( tool , {
36+ credentialId : 'mine' ,
37+ domain : DOMAIN ,
38+ [ name ] : 'override' ,
39+ } )
40+ ) . toThrow ( )
5241 }
5342 }
5443 )
0 commit comments