-
-
Notifications
You must be signed in to change notification settings - Fork 727
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: enable disabled strategies keeps settings (#7955)
- Loading branch information
Showing
3 changed files
with
54 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -734,3 +734,51 @@ test('Should return last seen at per environment', async () => { | |
); | ||
expect(featureToggle.lastSeenAt).toEqual(new Date(lastSeenAtStoreDate)); | ||
}); | ||
|
||
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<FeatureStrategySchema, 'id'> = { | ||
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: '[email protected]' } as User, | ||
shouldActivateDisabledStrategies, | ||
); | ||
|
||
const strategy = await service.getStrategy(createdConfig.id); | ||
expect(strategy).toMatchObject({ ...config, disabled: false }); | ||
}); |