@@ -72,6 +72,36 @@ describe("feature manager", () => {
7272 ] ) ;
7373 } ) ;
7474
75+ it ( "should let the last feature flag win" , ( ) => {
76+ const jsonObject = {
77+ "feature_management" : {
78+ "feature_flags" : [
79+ { "id" : "Alpha" , "description" : "" , "enabled" : false , "conditions" : { "client_filters" : [ ] } } ,
80+ { "id" : "Alpha" , "description" : "" , "enabled" : true , "conditions" : { "client_filters" : [ ] } }
81+ ]
82+ }
83+ } ;
84+
85+ const provider1 = new ConfigurationObjectFeatureFlagProvider ( jsonObject ) ;
86+ const featureManager1 = new FeatureManager ( provider1 ) ;
87+
88+ const dataSource = new Map ( ) ;
89+ dataSource . set ( "feature_management" , {
90+ feature_flags : [
91+ { "id" : "Alpha" , "description" : "" , "enabled" : false , "conditions" : { "client_filters" : [ ] } } ,
92+ { "id" : "Alpha" , "description" : "" , "enabled" : true , "conditions" : { "client_filters" : [ ] } }
93+ ] ,
94+ } ) ;
95+
96+ const provider2 = new ConfigurationMapFeatureFlagProvider ( dataSource ) ;
97+ const featureManager2 = new FeatureManager ( provider2 ) ;
98+
99+ return Promise . all ( [
100+ expect ( featureManager1 . isEnabled ( "Alpha" ) ) . eventually . eq ( true ) ,
101+ expect ( featureManager2 . isEnabled ( "Alpha" ) ) . eventually . eq ( true )
102+ ] ) ;
103+ } ) ;
104+
75105 it ( "should evaluate features with conditions" ) ;
76106 it ( "should override default filters with custom filters" ) ;
77107} ) ;
0 commit comments