From 607014e6f1b39180d193d093549c216e0b1fc6d0 Mon Sep 17 00:00:00 2001 From: Khanjan Dalwadi <80506682+KD1712@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:45:42 +0530 Subject: [PATCH] Changed response to only the ff object (#1652) * Changed response to only the ff object * make same change for frontend --------- Co-authored-by: danoswaltCL <97542869+danoswaltCL@users.noreply.github.com> Co-authored-by: danoswaltCL --- .../Upgrade/src/api/repositories/FeatureFlagRepository.ts | 2 +- .../test/unit/repositories/FeatureFlagRepository.test.ts | 2 +- .../src/app/core/feature-flags/store/feature-flags.reducer.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/packages/Upgrade/src/api/repositories/FeatureFlagRepository.ts b/backend/packages/Upgrade/src/api/repositories/FeatureFlagRepository.ts index 30b25dbff6..0176b73884 100644 --- a/backend/packages/Upgrade/src/api/repositories/FeatureFlagRepository.ts +++ b/backend/packages/Upgrade/src/api/repositories/FeatureFlagRepository.ts @@ -48,7 +48,7 @@ export class FeatureFlagRepository extends Repository { throw errorMsgString; }); - return result.raw; + return result.raw[0]; } public async updateFeatureFlag(flagDoc: Partial, entityManager: EntityManager): Promise { diff --git a/backend/packages/Upgrade/test/unit/repositories/FeatureFlagRepository.test.ts b/backend/packages/Upgrade/test/unit/repositories/FeatureFlagRepository.test.ts index 214b536164..9c26118b4a 100644 --- a/backend/packages/Upgrade/test/unit/repositories/FeatureFlagRepository.test.ts +++ b/backend/packages/Upgrade/test/unit/repositories/FeatureFlagRepository.test.ts @@ -173,7 +173,7 @@ describe('FeatureFlagRepository Testing', () => { sinon.assert.calledOnce(createQueryBuilderStub); updateMock.verify(); - expect(res).toEqual([flag]); + expect(res).toEqual(flag); }); it('should throw an error when update flag fails', async () => { diff --git a/frontend/projects/upgrade/src/app/core/feature-flags/store/feature-flags.reducer.ts b/frontend/projects/upgrade/src/app/core/feature-flags/store/feature-flags.reducer.ts index ed725f702c..6ab86bbb4b 100644 --- a/frontend/projects/upgrade/src/app/core/feature-flags/store/feature-flags.reducer.ts +++ b/frontend/projects/upgrade/src/app/core/feature-flags/store/feature-flags.reducer.ts @@ -86,7 +86,7 @@ const reducer = createReducer( isLoadingUpdateFeatureFlagStatus: true, })), on(FeatureFlagsActions.actionEnableFeatureFlagSuccess, (state, { response }) => { - const flag = response[0]; + const flag = response; return adapter.updateOne( { id: flag?.id, changes: { status: flag?.status } }, { ...state, isLoadingUpdateFeatureFlagStatus: false }