mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-13 13:48:59 +02:00
fix: should be allowed to change strategy
This commit is contained in:
parent
9eb19618bf
commit
6e940ab9bd
@ -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 || {},
|
||||
@ -898,12 +899,18 @@ export class FeatureToggleService {
|
||||
const existingSegments = await this.segmentService.getByStrategy(id);
|
||||
|
||||
if (existingStrategy.id === id) {
|
||||
console.log(
|
||||
`Updating strategy ${id} for feature ${featureName} in environment ${environment}: ${JSON.stringify(updates)}`,
|
||||
);
|
||||
const standardizedUpdates = await this.standardizeStrategyConfig(
|
||||
projectId,
|
||||
featureName,
|
||||
{ ...updates, name: updates.name! },
|
||||
existingStrategy,
|
||||
);
|
||||
console.log(
|
||||
`Standardized updates: ${JSON.stringify(standardizedUpdates)}`,
|
||||
);
|
||||
const strategy = await this.featureStrategiesStore.updateStrategy(
|
||||
id,
|
||||
standardizedUpdates,
|
||||
|
@ -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',
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user