diff --git a/src/lib/features/feature-toggle/deep-diff.ts b/src/lib/features/feature-toggle/deep-diff.ts deleted file mode 100644 index f49414a644de..000000000000 --- a/src/lib/features/feature-toggle/deep-diff.ts +++ /dev/null @@ -1,66 +0,0 @@ -interface Difference { - index: (string | number)[]; - reason: string; - valueA: any; - valueB: any; -} - -export function deepDiff(arr1: any[], arr2: any[]): Difference[] | null { - const diff: Difference[] = []; - - function compare(a: any, b: any, parentIndex: (string | number)[]): void { - if (Array.isArray(a) && Array.isArray(b)) { - if (a.length !== b.length) { - diff.push({ - index: parentIndex, - reason: 'Different lengths', - valueA: a, - valueB: b, - }); - } else { - for (let i = 0; i < a.length; i++) { - compare(a[i], b[i], parentIndex.concat(i)); - } - } - } else if ( - typeof a === 'object' && - a !== null && - typeof b === 'object' && - b !== null - ) { - const keysA = Object.keys(a); - const keysB = Object.keys(b); - - if (!arraysEqual(keysA, keysB)) { - diff.push({ - index: parentIndex, - reason: 'Different keys', - valueA: a, - valueB: b, - }); - } else { - for (const key of keysA) { - compare(a[key], b[key], parentIndex.concat(key)); - } - } - } else if (a !== b) { - diff.push({ - index: parentIndex, - reason: 'Different values', - valueA: a, - valueB: b, - }); - } - } - - function arraysEqual(a: any[], b: any[]): boolean { - return ( - a.length === b.length && - a.sort().every((val, index) => val === b.sort()[index]) - ); - } - - compare(arr1, arr2, []); - - return diff.length > 0 ? diff : null; -} diff --git a/src/lib/features/feature-toggle/feature-toggle-service.ts b/src/lib/features/feature-toggle/feature-toggle-service.ts index 5ef25b2cb003..c22df608716b 100644 --- a/src/lib/features/feature-toggle/feature-toggle-service.ts +++ b/src/lib/features/feature-toggle/feature-toggle-service.ts @@ -102,8 +102,6 @@ import { IPrivateProjectChecker } from '../private-project/privateProjectChecker import { IDependentFeaturesReadModel } from '../dependent-features/dependent-features-read-model-type'; import EventService from '../../services/event-service'; import { DependentFeaturesService } from '../dependent-features/dependent-features-service'; -import isEqual from 'lodash.isequal'; -import { deepDiff } from './deep-diff'; interface IFeatureContext { featureName: string; @@ -1062,22 +1060,6 @@ class FeatureToggleService { ), ]); - const equal = isEqual( - featuresFromClientStore, - featuresFromFeatureToggleStore, - ); - - if (!equal) { - const difference = deepDiff( - featuresFromClientStore, - featuresFromFeatureToggleStore, - ); - this.logger.warn( - 'getPlaygroundFeatures: features from client-feature-toggle-store is not equal to features from feature-toggle-store', - difference, - ); - } - const features = this.flagResolver.isEnabled('separateAdminClientApi') ? featuresFromFeatureToggleStore : featuresFromClientStore; @@ -1113,22 +1095,6 @@ class FeatureToggleService { ), ]); - const equal = isEqual( - featuresFromClientStore, - featuresFromFeatureToggleStore, - ); - - if (!equal) { - const difference = deepDiff( - featuresFromClientStore, - featuresFromFeatureToggleStore, - ); - this.logger.warn( - 'getFeatureToggles: features from client-feature-toggle-store is not equal to features from feature-toggle-store diff', - difference, - ); - } - const features = this.flagResolver.isEnabled('separateAdminClientApi') ? featuresFromFeatureToggleStore : featuresFromClientStore; diff --git a/src/lib/features/feature-toggle/tests/deep-diff.test.ts b/src/lib/features/feature-toggle/tests/deep-diff.test.ts deleted file mode 100644 index 8c53f57661ad..000000000000 --- a/src/lib/features/feature-toggle/tests/deep-diff.test.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { deepDiff } from '../deep-diff'; // Import the deepDiff function - -describe('deepDiff', () => { - it('should return null for equal arrays', () => { - const arr1 = [1, 2, 3]; - const arr2 = [1, 2, 3]; - expect(deepDiff(arr1, arr2)).toBe(null); - }); - - it('should find differences in arrays with different lengths', () => { - const arr1 = [1, 2, 3]; - const arr2 = [1, 2, 3, 4]; - expect(deepDiff(arr1, arr2)).toEqual([ - { - index: [], - reason: 'Different lengths', - valueA: arr1, - valueB: arr2, - }, - ]); - }); - - it('should find differences in arrays with different values', () => { - const arr1 = [1, 2, 3]; - const arr2 = [1, 4, 3]; - expect(deepDiff(arr1, arr2)).toEqual([ - { - index: [1], - reason: 'Different values', - valueA: 2, - valueB: 4, - }, - ]); - }); - - it('should find differences in arrays with different keys in objects', () => { - const arr1 = [{ a: 1 }, { b: 2 }]; - const arr2 = [{ a: 1 }, { c: 2 }]; - expect(deepDiff(arr1, arr2)).toEqual([ - { - index: [1], - reason: 'Different keys', - valueA: { b: 2 }, - valueB: { c: 2 }, - }, - ]); - }); - - it('should handle nested differences in objects', () => { - const arr1 = [{ a: { b: 1 } }, { c: { d: 2 } }]; - const arr2 = [{ a: { b: 1 } }, { c: { d: 3 } }]; - expect(deepDiff(arr1, arr2)).toEqual([ - { - index: [1, 'c', 'd'], - reason: 'Different values', - valueA: 2, - valueB: 3, - }, - ]); - }); -});