@@ -18,35 +18,21 @@ vi.mock('@/hooks/use-permissions', () => ({
1818
1919// Mock integration platform hooks
2020const mockStartOAuth = vi . fn ( ) ;
21+ const mockUseIntegrationProviders = vi . fn ( ) ;
22+ const mockUseIntegrationConnections = vi . fn ( ) ;
2123vi . mock ( '@/hooks/use-integration-platform' , ( ) => ( {
22- useIntegrationProviders : ( ) => ( {
23- providers : [
24- {
25- id : 'github' ,
26- name : 'GitHub' ,
27- description : 'Code hosting' ,
28- category : 'Development' ,
29- logoUrl : '/github.png' ,
30- authType : 'oauth2' ,
31- oauthConfigured : true ,
32- isActive : true ,
33- requiredVariables : [ ] ,
34- mappedTasks : [ ] ,
35- supportsMultipleConnections : false ,
36- } ,
37- ] ,
38- isLoading : false ,
39- } ) ,
40- useIntegrationConnections : ( ) => ( {
41- connections : [ ] ,
42- isLoading : false ,
43- refresh : vi . fn ( ) ,
44- } ) ,
24+ useIntegrationProviders : mockUseIntegrationProviders ,
25+ useIntegrationConnections : mockUseIntegrationConnections ,
4526 useIntegrationMutations : ( ) => ( {
4627 startOAuth : mockStartOAuth ,
4728 } ) ,
4829} ) ) ;
4930
31+ const mockUseVendors = vi . fn ( ) ;
32+ vi . mock ( '@/hooks/use-vendors' , ( ) => ( {
33+ useVendors : mockUseVendors ,
34+ } ) ) ;
35+
5036// Mock integrations data
5137vi . mock ( '../data/integrations' , ( ) => ( {
5238 CATEGORIES : [ 'Development' ] ,
@@ -159,6 +145,38 @@ const defaultProps = {
159145describe ( 'PlatformIntegrations' , ( ) => {
160146 beforeEach ( ( ) => {
161147 vi . clearAllMocks ( ) ;
148+ mockUseIntegrationProviders . mockReturnValue ( {
149+ providers : [
150+ {
151+ id : 'github' ,
152+ name : 'GitHub' ,
153+ description : 'Code hosting' ,
154+ category : 'Development' ,
155+ logoUrl : '/github.png' ,
156+ authType : 'oauth2' ,
157+ oauthConfigured : true ,
158+ isActive : true ,
159+ requiredVariables : [ ] ,
160+ mappedTasks : [ ] ,
161+ supportsMultipleConnections : false ,
162+ } ,
163+ ] ,
164+ isLoading : false ,
165+ } ) ;
166+ mockUseIntegrationConnections . mockReturnValue ( {
167+ connections : [ ] ,
168+ isLoading : false ,
169+ refresh : vi . fn ( ) ,
170+ } ) ;
171+ mockUseVendors . mockReturnValue ( {
172+ data : {
173+ data : {
174+ data : [ ] ,
175+ count : 0 ,
176+ } ,
177+ status : 200 ,
178+ } ,
179+ } ) ;
162180 } ) ;
163181
164182 describe ( 'Permission gating' , ( ) => {
@@ -329,4 +347,77 @@ describe('PlatformIntegrations', () => {
329347 expect ( toast . info ) . not . toHaveBeenCalled ( ) ;
330348 } ) ;
331349 } ) ;
350+
351+ describe ( 'Vendor-prioritized ordering' , ( ) => {
352+ it ( 'shows integrations from vendor list before non-vendor integrations' , ( ) => {
353+ mockUseIntegrationProviders . mockReturnValue ( {
354+ providers : [
355+ {
356+ id : 'github' ,
357+ name : 'GitHub' ,
358+ description : 'Code hosting' ,
359+ category : 'Development' ,
360+ logoUrl : '/github.png' ,
361+ authType : 'oauth2' ,
362+ oauthConfigured : true ,
363+ isActive : true ,
364+ requiredVariables : [ ] ,
365+ mappedTasks : [ ] ,
366+ supportsMultipleConnections : false ,
367+ } ,
368+ {
369+ id : 'slack' ,
370+ name : 'Slack' ,
371+ description : 'Team communication' ,
372+ category : 'Communication' ,
373+ logoUrl : '/slack.png' ,
374+ authType : 'api_key' ,
375+ isActive : true ,
376+ requiredVariables : [ ] ,
377+ mappedTasks : [ ] ,
378+ supportsMultipleConnections : false ,
379+ } ,
380+ ] ,
381+ isLoading : false ,
382+ } ) ;
383+ mockUseIntegrationConnections . mockReturnValue ( {
384+ connections : [
385+ {
386+ id : 'conn-1' ,
387+ providerSlug : 'github' ,
388+ status : 'active' ,
389+ variables : { } ,
390+ } ,
391+ ] ,
392+ isLoading : false ,
393+ refresh : vi . fn ( ) ,
394+ } ) ;
395+ mockUseVendors . mockReturnValue ( {
396+ data : {
397+ data : {
398+ data : [
399+ {
400+ id : 'vnd-1' ,
401+ name : 'Slack' ,
402+ } ,
403+ ] ,
404+ count : 1 ,
405+ } ,
406+ status : 200 ,
407+ } ,
408+ } ) ;
409+
410+ setMockPermissions ( ADMIN_PERMISSIONS ) ;
411+
412+ render ( < PlatformIntegrations { ...defaultProps } /> ) ;
413+
414+ const integrationTitles = screen
415+ . getAllByRole ( 'heading' , { level : 3 } )
416+ . map ( ( heading ) => heading . textContent ?. trim ( ) )
417+ . filter ( Boolean ) ;
418+
419+ expect ( integrationTitles [ 0 ] ) . toBe ( 'Slack' ) ;
420+ expect ( integrationTitles [ 1 ] ) . toBe ( 'GitHub' ) ;
421+ } ) ;
422+ } ) ;
332423} ) ;
0 commit comments