From 1882d0c22e6d3865f8f6571e76b0a8d4e89d5fe5 Mon Sep 17 00:00:00 2001 From: Benedikt Richter Date: Wed, 27 Sep 2023 08:15:24 +0200 Subject: [PATCH] Add feature flag We add a feature flag in order to deactivate the preferred attributions feature for a new release, as it is not yet finalized. Signed-off-by: Benedikt Richter --- .../audit-view-tests/__tests__/audit-view.test.tsx | 4 ++-- .../resource-actions/__tests__/load-actions.test.ts | 2 +- .../state/actions/resource-actions/load-actions.ts | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Frontend/integration-tests/audit-view-tests/__tests__/audit-view.test.tsx b/src/Frontend/integration-tests/audit-view-tests/__tests__/audit-view.test.tsx index fe2bfab39..62c2e2440 100644 --- a/src/Frontend/integration-tests/audit-view-tests/__tests__/audit-view.test.tsx +++ b/src/Frontend/integration-tests/audit-view-tests/__tests__/audit-view.test.tsx @@ -575,7 +575,7 @@ describe('The App in Audit View', () => { ); }); - it('preferred button is shown and sets an attribution as preferred', () => { + it.skip('preferred button is shown and sets an attribution as preferred', () => { function getExpectedSaveFileArgs( preferred: boolean, preferredOverOriginIds?: Array, @@ -673,7 +673,7 @@ describe('The App in Audit View', () => { expect(window.electronAPI.saveFile).toHaveBeenCalledTimes(2); }); - it('after setting an attribution to preferred, global save is disabled', () => { + it.skip('after setting an attribution to preferred, global save is disabled', () => { const testResources: Resources = { file: 1, other_file: 1, diff --git a/src/Frontend/state/actions/resource-actions/__tests__/load-actions.test.ts b/src/Frontend/state/actions/resource-actions/__tests__/load-actions.test.ts index eabcd0f94..a42e56e54 100644 --- a/src/Frontend/state/actions/resource-actions/__tests__/load-actions.test.ts +++ b/src/Frontend/state/actions/resource-actions/__tests__/load-actions.test.ts @@ -231,7 +231,7 @@ describe('loadFromFile', () => { expect(getExternalAttributionsToHashes(testStore.getState())).toEqual( expectedExternalAttributionsToHashes, ); - expect(getIsPreferenceFeatureEnabled(testStore.getState())).toEqual(true); + expect(getIsPreferenceFeatureEnabled(testStore.getState())).toEqual(false); }); it('disables the preference feature if no external source is relevant', () => { diff --git a/src/Frontend/state/actions/resource-actions/load-actions.ts b/src/Frontend/state/actions/resource-actions/load-actions.ts index b313818aa..a0292aafd 100644 --- a/src/Frontend/state/actions/resource-actions/load-actions.ts +++ b/src/Frontend/state/actions/resource-actions/load-actions.ts @@ -8,12 +8,12 @@ import { AppThunkAction, AppThunkDispatch } from '../../types'; import { setAttributionBreakpoints, setBaseUrlsForSources, - setIsPreferenceFeatureEnabled, setExternalAttributionSources, setExternalAttributionsToHashes, setExternalData, setFilesWithChildren, setFrequentLicenses, + setIsPreferenceFeatureEnabled, setManualData, setProjectMetadata, setResources, @@ -67,6 +67,12 @@ export function loadFromFile( setIsPreferenceFeatureEnabled(fileContainsSourcesRelevantForPreferred), ); + // Feature flag + // when removing unskip the following tests + // * after setting an attribution to preferred, global save is disabled + // * preferred button is shown and sets an attribution as preferred + dispatch(setIsPreferenceFeatureEnabled(false)); + parsedFileContent.resolvedExternalAttributions.forEach((attribution) => dispatch(addResolvedExternalAttribution(attribution)), );