File tree Expand file tree Collapse file tree 3 files changed +31
-9
lines changed
providers/feature-flag/strategies Expand file tree Collapse file tree 3 files changed +31
-9
lines changed Original file line number Diff line number Diff line change @@ -43,9 +43,9 @@ export const mockFeaturesConfigJsonComplex = {
43
43
{
44
44
or : [
45
45
{
46
- name : 'env.FORCE_ENABLE_LIVE_RECOMMENDATIONS ' ,
47
- value : 'true ' ,
48
- type : 'eq' ,
46
+ name : 'settings.testValue ' ,
47
+ value : 'test ' ,
48
+ cond : 'eq' ,
49
49
} ,
50
50
{
51
51
and : [
@@ -98,9 +98,9 @@ export const mockFeaturesConfigDataComplex = Object.assign(new FeaturesConfigDat
98
98
Object . assign ( new FeatureConfigFilterOr ( ) , {
99
99
or : [
100
100
Object . assign ( new FeatureConfigFilter ( ) , {
101
- name : 'env.FORCE_ENABLE_LIVE_RECOMMENDATIONS ' ,
102
- value : 'true ' ,
103
- type : 'eq' ,
101
+ name : 'settings.testValue ' ,
102
+ value : 'test ' ,
103
+ cond : 'eq' ,
104
104
} ) ,
105
105
Object . assign ( new FeatureConfigFilterAnd ( ) , {
106
106
and : [
Original file line number Diff line number Diff line change @@ -71,9 +71,9 @@ export class FeatureService {
71
71
actions . toDelete = featuresFromDatabase . filter ( ( feature ) => ! featuresConfig ?. data ?. features ?. [ feature . name ] ) ;
72
72
73
73
// delete features
74
- await Promise . all ( actions . toDelete . map ( this . repository . delete . bind ( this ) ) ) ;
74
+ await Promise . all ( actions . toDelete . map ( this . repository . delete . bind ( this . repository ) ) ) ;
75
75
// upsert modified features
76
- await Promise . all ( actions . toUpsert . map ( this . repository . upsert . bind ( this ) ) ) ;
76
+ await Promise . all ( actions . toUpsert . map ( this . repository . upsert . bind ( this . repository ) ) ) ;
77
77
78
78
this . logger . log (
79
79
`Features flags recalculated. Updated: ${ actions . toUpsert . length } deleted: ${ actions . toDelete . length } ` ,
Original file line number Diff line number Diff line change @@ -212,11 +212,33 @@ describe('FeatureFlagStrategy', () => {
212
212
} ) ;
213
213
214
214
describe ( 'filter (complex)' , ( ) => {
215
- it ( 'should return true for single filter by agreements (eq) ' , async ( ) => {
215
+ it ( 'should return true since 2nd or is true ' , async ( ) => {
216
216
settingsService . getAppSettings . mockResolvedValueOnce ( {
217
+ ...mockAppSettings ,
217
218
agreements : { analytics : true } ,
218
219
} ) ;
219
220
221
+ expect (
222
+ await service [ 'filter' ] ( mockFeaturesConfigDataComplex . features . get ( 'liveRecommendations' ) . filters ) ,
223
+ ) . toEqual ( true ) ;
224
+ } ) ;
225
+ it ( 'should return false since all 2 or conditions are false' , async ( ) => {
226
+ settingsService . getAppSettings . mockResolvedValueOnce ( {
227
+ ...mockAppSettings ,
228
+ agreements : { analytics : false } ,
229
+ } ) ;
230
+
231
+ expect (
232
+ await service [ 'filter' ] ( mockFeaturesConfigDataComplex . features . get ( 'liveRecommendations' ) . filters ) ,
233
+ ) . toEqual ( false ) ;
234
+ } ) ;
235
+ it ( 'should return true since all 1st or is true' , async ( ) => {
236
+ settingsService . getAppSettings . mockResolvedValueOnce ( {
237
+ ...mockAppSettings ,
238
+ testValue : 'test' ,
239
+ agreements : { analytics : false } ,
240
+ } ) ;
241
+
220
242
expect (
221
243
await service [ 'filter' ] ( mockFeaturesConfigDataComplex . features . get ( 'liveRecommendations' ) . filters ) ,
222
244
) . toEqual ( true ) ;
You can’t perform that action at this time.
0 commit comments