@@ -533,6 +533,167 @@ describe('Remote Loader', () => {
533533 )
534534 } )
535535
536+ // Action destinations should be toggled using the `integration` name which matches the `creationName`
537+ // Most action destinations have the same value for creationName and name, but a few (Amplitude) do not.
538+ // Continue to support toggling with plugin.name for backwards compatibility.
539+ it ( 'loads destinations when `All: false` but is enabled (pluginName)' , async ( ) => {
540+ const cdnSettings = {
541+ integrations : {
542+ oldValidName : {
543+ versionSettings : {
544+ componentTypes : [ ] ,
545+ } ,
546+ } ,
547+ } ,
548+ remotePlugins : [
549+ {
550+ name : 'valid' ,
551+ creationName : 'oldValidName' ,
552+ url : 'cdn/path/to/file.js' ,
553+ libraryName : 'testPlugin' ,
554+ settings : {
555+ subscriptions : [ ] ,
556+ versionSettings : {
557+ componentTypes : [ ] ,
558+ } ,
559+ } ,
560+ } ,
561+ ] ,
562+ }
563+
564+ await AnalyticsBrowser . load (
565+ { writeKey : '' , cdnSettings } ,
566+ {
567+ integrations : {
568+ All : false ,
569+ valid : true ,
570+ } ,
571+ }
572+ )
573+
574+ expect ( pluginFactory ) . toHaveBeenCalledTimes ( 1 )
575+ expect ( pluginFactory ) . toHaveBeenCalledWith (
576+ expect . objectContaining ( cdnSettings . remotePlugins [ 0 ] . settings )
577+ )
578+ } )
579+
580+ it ( 'loads destinations when `All: false` but is enabled (creationName)' , async ( ) => {
581+ const cdnSettings = {
582+ integrations : {
583+ oldValidName : {
584+ versionSettings : {
585+ componentTypes : [ ] ,
586+ } ,
587+ } ,
588+ } ,
589+ remotePlugins : [
590+ {
591+ name : 'valid' ,
592+ creationName : 'oldValidName' ,
593+ url : 'cdn/path/to/file.js' ,
594+ libraryName : 'testPlugin' ,
595+ settings : {
596+ subscriptions : [ ] ,
597+ versionSettings : {
598+ componentTypes : [ ] ,
599+ } ,
600+ } ,
601+ } ,
602+ ] ,
603+ }
604+
605+ await AnalyticsBrowser . load (
606+ { writeKey : '' , cdnSettings } ,
607+ {
608+ integrations : {
609+ All : false ,
610+ oldValidName : true ,
611+ } ,
612+ }
613+ )
614+
615+ expect ( pluginFactory ) . toHaveBeenCalledTimes ( 1 )
616+ expect ( pluginFactory ) . toHaveBeenCalledWith (
617+ expect . objectContaining ( cdnSettings . remotePlugins [ 0 ] . settings )
618+ )
619+ } )
620+
621+ it ( 'does not load destinations when disabled via pluginName' , async ( ) => {
622+ const cdnSettings = {
623+ integrations : {
624+ oldValidName : {
625+ versionSettings : {
626+ componentTypes : [ ] ,
627+ } ,
628+ } ,
629+ } ,
630+ remotePlugins : [
631+ {
632+ name : 'valid' ,
633+ creationName : 'oldValidName' ,
634+ url : 'cdn/path/to/file.js' ,
635+ libraryName : 'testPlugin' ,
636+ settings : {
637+ subscriptions : [ ] ,
638+ versionSettings : {
639+ componentTypes : [ ] ,
640+ } ,
641+ } ,
642+ } ,
643+ ] ,
644+ }
645+
646+ await AnalyticsBrowser . load (
647+ { writeKey : '' , cdnSettings } ,
648+ {
649+ integrations : {
650+ All : true ,
651+ valid : false ,
652+ } ,
653+ }
654+ )
655+
656+ expect ( pluginFactory ) . toHaveBeenCalledTimes ( 0 )
657+ } )
658+
659+ it ( 'does not load destinations when disabled via creationName' , async ( ) => {
660+ const cdnSettings = {
661+ integrations : {
662+ oldValidName : {
663+ versionSettings : {
664+ componentTypes : [ ] ,
665+ } ,
666+ } ,
667+ } ,
668+ remotePlugins : [
669+ {
670+ name : 'valid' ,
671+ creationName : 'oldValidName' ,
672+ url : 'cdn/path/to/file.js' ,
673+ libraryName : 'testPlugin' ,
674+ settings : {
675+ subscriptions : [ ] ,
676+ versionSettings : {
677+ componentTypes : [ ] ,
678+ } ,
679+ } ,
680+ } ,
681+ ] ,
682+ }
683+
684+ await AnalyticsBrowser . load (
685+ { writeKey : '' , cdnSettings } ,
686+ {
687+ integrations : {
688+ All : true ,
689+ oldValidName : false ,
690+ } ,
691+ }
692+ )
693+
694+ expect ( pluginFactory ) . toHaveBeenCalledTimes ( 0 )
695+ } )
696+
536697 it ( 'applies remote routing rules based on creation name' , async ( ) => {
537698 const validPlugin = {
538699 name : 'valid' ,
0 commit comments