diff --git a/src/lib/features/feature-toggle/feature-toggle-service.ts b/src/lib/features/feature-toggle/feature-toggle-service.ts index af76a4dac7ed..dc6d4988ba0a 100644 --- a/src/lib/features/feature-toggle/feature-toggle-service.ts +++ b/src/lib/features/feature-toggle/feature-toggle-service.ts @@ -1896,7 +1896,7 @@ class FeatureToggleService { strategies.map((strategy) => this.updateStrategy( strategy.id, - { disabled: false }, + { ...strategy, disabled: false }, { environment, projectId: project, diff --git a/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts b/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts index 6662fe568cd3..5fd0b835b2a0 100644 --- a/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts +++ b/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts @@ -814,3 +814,51 @@ test('Should not allow to revive flags to archived projects', async () => { ), ); }); + +test('Should enable disabled strategies on feature environment enabled', async () => { + const flagName = 'enableThisFlag'; + const project = 'default'; + const environment = 'default'; + const shouldActivateDisabledStrategies = true; + await service.createFeatureToggle( + project, + { + name: flagName, + }, + TEST_AUDIT_USER, + ); + const config: Omit = { + name: 'default', + constraints: [ + { contextName: 'userId', operator: 'IN', values: ['1', '1'] }, + ], + parameters: { param: 'a' }, + variants: [ + { + name: 'a', + weight: 100, + weightType: 'variable', + stickiness: 'random', + }, + ], + disabled: true, + }; + const createdConfig = await service.createStrategy( + config, + { projectId: project, featureName: flagName, environment }, + TEST_AUDIT_USER, + ); + + await service.updateEnabled( + project, + flagName, + environment, + true, + TEST_AUDIT_USER, + { email: 'test@example.com' } as User, + shouldActivateDisabledStrategies, + ); + + const strategy = await service.getStrategy(createdConfig.id); + expect(strategy).toMatchObject({ ...config, disabled: false }); +});