@@ -11,7 +11,7 @@ import {
1111} from '../../src/integration' ;
1212import { setCurrentClient } from '../../src/sdk' ;
1313import type { Integration } from '../../src/types-hoist/integration' ;
14- import type { Options } from '../../src/types-hoist/options' ;
14+ import type { CoreOptions } from '../../src/types-hoist/options' ;
1515import { debug } from '../../src/utils/debug-logger' ;
1616import { getDefaultTestClientOptions , TestClient } from '../mocks/client' ;
1717
@@ -40,8 +40,8 @@ class MockIntegration implements Integration {
4040
4141type TestCase = [
4242 string , // test name
43- Options [ 'defaultIntegrations' ] , // default integrations
44- Options [ 'integrations' ] , // user-provided integrations
43+ CoreOptions [ 'defaultIntegrations' ] , // default integrations
44+ CoreOptions [ 'integrations' ] , // user-provided integrations
4545 Array < string | string [ ] > , // expected results
4646] ;
4747
@@ -694,124 +694,57 @@ describe('addIntegration', () => {
694694
695695describe ( 'Integration marking system' , ( ) => {
696696 beforeEach ( ( ) => {
697- // Clear marks before each test
698697 _clearDisabledIntegrationsMarks ( ) ;
699- // Reset installed integrations
700698 installedIntegrations . splice ( 0 , installedIntegrations . length ) ;
701699 } ) ;
702700
703701 afterEach ( ( ) => {
704- // Clean up after tests
705702 _clearDisabledIntegrationsMarks ( ) ;
706703 } ) ;
707704
708- describe ( '_markIntegrationsDisabled' , ( ) => {
709- it ( 'marks a single integration as disabled' , ( ) => {
710- _markIntegrationsDisabled ( 'TestIntegration' ) ;
711- expect ( _isIntegrationMarkedDisabled ( 'TestIntegration' ) ) . toBe ( true ) ;
712- } ) ;
705+ it ( 'marks and checks single integration' , ( ) => {
706+ expect ( _isIntegrationMarkedDisabled ( 'TestIntegration' ) ) . toBe ( false ) ;
713707
714- it ( 'marks multiple integrations as disabled using array' , ( ) => {
715- _markIntegrationsDisabled ( [ 'Integration1' , 'Integration2' , 'Integration3' ] ) ;
716- expect ( _isIntegrationMarkedDisabled ( 'Integration1' ) ) . toBe ( true ) ;
717- expect ( _isIntegrationMarkedDisabled ( 'Integration2' ) ) . toBe ( true ) ;
718- expect ( _isIntegrationMarkedDisabled ( 'Integration3' ) ) . toBe ( true ) ;
719- } ) ;
708+ _markIntegrationsDisabled ( 'TestIntegration' ) ;
720709
721- it ( 'does not affect unmarked integrations' , ( ) => {
722- _markIntegrationsDisabled ( 'Integration1' ) ;
723- expect ( _isIntegrationMarkedDisabled ( 'Integration1' ) ) . toBe ( true ) ;
724- expect ( _isIntegrationMarkedDisabled ( 'Integration2' ) ) . toBe ( false ) ;
725- } ) ;
710+ expect ( _isIntegrationMarkedDisabled ( 'TestIntegration' ) ) . toBe ( true ) ;
726711 } ) ;
727712
728- describe ( '_isIntegrationMarkedDisabled' , ( ) => {
729- it ( 'returns false for integrations that are not marked' , ( ) => {
730- expect ( _isIntegrationMarkedDisabled ( 'SomeIntegration' ) ) . toBe ( false ) ;
731- } ) ;
713+ it ( 'marks and checks multiple integrations' , ( ) => {
714+ _markIntegrationsDisabled ( [ 'OpenAI' , 'Anthropic' , 'GoogleGenAI' ] ) ;
732715
733- it ( 'returns true for integrations that are marked' , ( ) => {
734- _markIntegrationsDisabled ( 'MarkedIntegration' ) ;
735- expect ( _isIntegrationMarkedDisabled ( 'MarkedIntegration ' ) ) . toBe ( true ) ;
736- } ) ;
716+ expect ( _isIntegrationMarkedDisabled ( 'OpenAI' ) ) . toBe ( true ) ;
717+ expect ( _isIntegrationMarkedDisabled ( 'Anthropic' ) ) . toBe ( true ) ;
718+ expect ( _isIntegrationMarkedDisabled ( 'GoogleGenAI ' ) ) . toBe ( true ) ;
719+ expect ( _isIntegrationMarkedDisabled ( 'Other' ) ) . toBe ( false ) ;
737720 } ) ;
738721
739- describe ( '_clearDisabledIntegrationsMarks' , ( ) => {
740- it ( 'clears all marks' , ( ) => {
741- _markIntegrationsDisabled ( [ 'Integration1' , 'Integration2' ] ) ;
742- expect ( _isIntegrationMarkedDisabled ( 'Integration1' ) ) . toBe ( true ) ;
743- expect ( _isIntegrationMarkedDisabled ( 'Integration2' ) ) . toBe ( true ) ;
744-
745- _clearDisabledIntegrationsMarks ( ) ;
746-
747- expect ( _isIntegrationMarkedDisabled ( 'Integration1' ) ) . toBe ( false ) ;
748- expect ( _isIntegrationMarkedDisabled ( 'Integration2' ) ) . toBe ( false ) ;
749- } ) ;
750-
751- it ( 'removes marked integrations from installedIntegrations list' , ( ) => {
752- // Simulate integrations being installed
753- installedIntegrations . push ( 'Integration1' , 'Integration2' , 'Integration3' ) ;
754-
755- // Mark some as disabled
756- _markIntegrationsDisabled ( [ 'Integration1' , 'Integration3' ] ) ;
757-
758- // Clear should remove marked ones from installed list
759- _clearDisabledIntegrationsMarks ( ) ;
722+ it ( 'clears marks and removes from installedIntegrations' , ( ) => {
723+ // Simulate scenario: integrations installed, some marked for cleanup
724+ installedIntegrations . push ( 'LangChain' , 'OpenAI' , 'Anthropic' , 'Normal' ) ;
725+ _markIntegrationsDisabled ( [ 'OpenAI' , 'Anthropic' ] ) ;
760726
761- expect ( installedIntegrations ) . toEqual ( [ 'Integration2' ] ) ;
762- } ) ;
763-
764- it ( 'preserves integrations that are not marked when clearing' , ( ) => {
765- installedIntegrations . push ( 'Integration1' , 'Integration2' , 'Integration3' ) ;
766- _markIntegrationsDisabled ( 'Integration2' ) ;
727+ _clearDisabledIntegrationsMarks ( ) ;
767728
768- _clearDisabledIntegrationsMarks ( ) ;
729+ // Marks are cleared
730+ expect ( _isIntegrationMarkedDisabled ( 'OpenAI' ) ) . toBe ( false ) ;
731+ expect ( _isIntegrationMarkedDisabled ( 'Anthropic' ) ) . toBe ( false ) ;
769732
770- expect ( installedIntegrations ) . toEqual ( [ 'Integration1' , 'Integration3' ] ) ;
771- } ) ;
733+ // Marked integrations removed from installed list (can setup again in new client)
734+ expect ( installedIntegrations ) . toEqual ( [ 'LangChain' , 'Normal' ] ) ;
772735 } ) ;
773736
774- describe ( 'setupIntegration with marked integrations' , ( ) => {
775- it ( 'skips setupOnce for marked integrations' , ( ) => {
776- const client = getTestClient ( ) ;
777- const integration = new MockIntegration ( 'MarkedIntegration' ) ;
778-
779- // Mark the integration as disabled before setup
780- _markIntegrationsDisabled ( 'MarkedIntegration' ) ;
781-
782- setupIntegration ( client , integration , { } ) ;
783-
784- // setupOnce should not be called
785- expect ( integration . setupOnce ) . not . toHaveBeenCalled ( ) ;
786- // Integration should not be in installed list
787- expect ( installedIntegrations ) . not . toContain ( 'MarkedIntegration' ) ;
788- } ) ;
789-
790- it ( 'calls setupOnce for non-marked integrations' , ( ) => {
791- const client = getTestClient ( ) ;
792- const integration = new MockIntegration ( 'NormalIntegration' ) ;
793-
794- setupIntegration ( client , integration , { } ) ;
737+ it ( 'handles multi-client scenario correctly' , ( ) => {
738+ // First client with LangChain
739+ installedIntegrations . push ( 'LangChain' , 'OpenAI' ) ;
740+ _markIntegrationsDisabled ( 'OpenAI' ) ;
741+ expect ( _isIntegrationMarkedDisabled ( 'OpenAI' ) ) . toBe ( true ) ;
795742
796- // setupOnce should be called
797- expect ( integration . setupOnce ) . toHaveBeenCalledTimes ( 1 ) ;
798- // Integration should be in installed list
799- expect ( installedIntegrations ) . toContain ( 'NormalIntegration' ) ;
800- } ) ;
801-
802- it ( 'allows setup after clearing marks' , ( ) => {
803- const client = getTestClient ( ) ;
804- const integration = new MockIntegration ( 'TestIntegration' ) ;
805-
806- // Mark, clear, then setup
807- _markIntegrationsDisabled ( 'TestIntegration' ) ;
808- _clearDisabledIntegrationsMarks ( ) ;
809-
810- setupIntegration ( client , integration , { } ) ;
743+ // Second client initialization clears marks
744+ _clearDisabledIntegrationsMarks ( ) ;
811745
812- // setupOnce should be called after marks are cleared
813- expect ( integration . setupOnce ) . toHaveBeenCalledTimes ( 1 ) ;
814- expect ( installedIntegrations ) . toContain ( 'TestIntegration' ) ;
815- } ) ;
746+ // OpenAI can be used standalone in second client
747+ expect ( _isIntegrationMarkedDisabled ( 'OpenAI' ) ) . toBe ( false ) ;
748+ expect ( installedIntegrations ) . toEqual ( [ 'LangChain' ] ) ; // OpenAI removed, can setup fresh
816749 } ) ;
817750} ) ;
0 commit comments