Skip to content

Commit ca85515

Browse files
author
Artem
committed
#RI-4489 fix bind issue + UTests
1 parent 105c91d commit ca85515

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

redisinsight/api/src/__mocks__/feature.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export const mockFeaturesConfigJsonComplex = {
4343
{
4444
or: [
4545
{
46-
name: 'env.FORCE_ENABLE_LIVE_RECOMMENDATIONS',
47-
value: 'true',
48-
type: 'eq',
46+
name: 'settings.testValue',
47+
value: 'test',
48+
cond: 'eq',
4949
},
5050
{
5151
and: [
@@ -98,9 +98,9 @@ export const mockFeaturesConfigDataComplex = Object.assign(new FeaturesConfigDat
9898
Object.assign(new FeatureConfigFilterOr(), {
9999
or: [
100100
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',
104104
}),
105105
Object.assign(new FeatureConfigFilterAnd(), {
106106
and: [

redisinsight/api/src/modules/feature/feature.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ export class FeatureService {
7171
actions.toDelete = featuresFromDatabase.filter((feature) => !featuresConfig?.data?.features?.[feature.name]);
7272

7373
// 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)));
7575
// 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)));
7777

7878
this.logger.log(
7979
`Features flags recalculated. Updated: ${actions.toUpsert.length} deleted: ${actions.toDelete.length}`,

redisinsight/api/src/modules/feature/providers/feature-flag/strategies/feature.flag.strategy.spec.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,33 @@ describe('FeatureFlagStrategy', () => {
212212
});
213213

214214
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 () => {
216216
settingsService.getAppSettings.mockResolvedValueOnce({
217+
...mockAppSettings,
217218
agreements: { analytics: true },
218219
});
219220

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+
220242
expect(
221243
await service['filter'](mockFeaturesConfigDataComplex.features.get('liveRecommendations').filters),
222244
).toEqual(true);

0 commit comments

Comments
 (0)