1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-04 13:48:56 +02:00

fix: should be allowed to change strategy (#10441)

## About the changes
Previous PR: https://github.com/Unleash/unleash/pull/10439 introduced a
bug not allowing to update the strategy name

This PR modifies a test to also validate the change of strategy and
fixes the problem
This commit is contained in:
Gastón Fournier 2025-07-30 17:25:17 +02:00 committed by GitHub
parent 0d0257bbdc
commit 2f1ca50bc4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View File

@ -698,8 +698,8 @@ export class FeatureToggleService {
strategyConfig: Unsaved<IStrategyConfig>,
existing?: IFeatureStrategy,
): Promise<
{ strategyName: string } & Pick<
Partial<IFeatureStrategy>,
{ name: string } & Pick<
Partial<IStrategyConfig>,
| 'title'
| 'disabled'
| 'variants'
@ -731,7 +731,7 @@ export class FeatureToggleService {
}
return {
strategyName: name,
name,
title,
disabled,
sortOrder,
@ -770,6 +770,7 @@ export class FeatureToggleService {
const newFeatureStrategy =
await this.featureStrategiesStore.createStrategyFeatureEnv({
...standardizedConfig,
strategyName: standardizedConfig.name,
constraints: standardizedConfig.constraints || [],
variants: standardizedConfig.variants || [],
parameters: standardizedConfig.parameters || {},

View File

@ -136,13 +136,18 @@ test('Should be able to update existing strategy configuration', async () => {
expect(createdConfig.name).toEqual('default');
const updatedConfig = await service.updateStrategy(
createdConfig.id,
{ parameters: { b2b: 'true' } },
{ name: 'flexibleRollout', parameters: { b2b: 'true' } },
{ projectId, featureName, environment: DEFAULT_ENV },
TEST_AUDIT_USER,
);
expect(createdConfig.id).toEqual(updatedConfig.id);
expect(updatedConfig.name).toEqual('flexibleRollout');
expect(updatedConfig.parameters).toEqual({
b2b: 'true',
// flexible rollout default parameters
rollout: '100',
groupId: featureName,
stickiness: 'default',
});
});