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>,
|
strategyConfig: Unsaved<IStrategyConfig>,
|
||||||
existing?: IFeatureStrategy,
|
existing?: IFeatureStrategy,
|
||||||
): Promise<
|
): Promise<
|
||||||
{ strategyName: string } & Pick<
|
{ name: string } & Pick<
|
||||||
Partial<IFeatureStrategy>,
|
Partial<IStrategyConfig>,
|
||||||
| 'title'
|
| 'title'
|
||||||
| 'disabled'
|
| 'disabled'
|
||||||
| 'variants'
|
| 'variants'
|
||||||
@ -731,7 +731,7 @@ export class FeatureToggleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
strategyName: name,
|
name,
|
||||||
title,
|
title,
|
||||||
disabled,
|
disabled,
|
||||||
sortOrder,
|
sortOrder,
|
||||||
@ -770,6 +770,7 @@ export class FeatureToggleService {
|
|||||||
const newFeatureStrategy =
|
const newFeatureStrategy =
|
||||||
await this.featureStrategiesStore.createStrategyFeatureEnv({
|
await this.featureStrategiesStore.createStrategyFeatureEnv({
|
||||||
...standardizedConfig,
|
...standardizedConfig,
|
||||||
|
strategyName: standardizedConfig.name,
|
||||||
constraints: standardizedConfig.constraints || [],
|
constraints: standardizedConfig.constraints || [],
|
||||||
variants: standardizedConfig.variants || [],
|
variants: standardizedConfig.variants || [],
|
||||||
parameters: standardizedConfig.parameters || {},
|
parameters: standardizedConfig.parameters || {},
|
||||||
@ -898,12 +899,18 @@ export class FeatureToggleService {
|
|||||||
const existingSegments = await this.segmentService.getByStrategy(id);
|
const existingSegments = await this.segmentService.getByStrategy(id);
|
||||||
|
|
||||||
if (existingStrategy.id === id) {
|
if (existingStrategy.id === id) {
|
||||||
|
console.log(
|
||||||
|
`Updating strategy ${id} for feature ${featureName} in environment ${environment}: ${JSON.stringify(updates)}`,
|
||||||
|
);
|
||||||
const standardizedUpdates = await this.standardizeStrategyConfig(
|
const standardizedUpdates = await this.standardizeStrategyConfig(
|
||||||
projectId,
|
projectId,
|
||||||
featureName,
|
featureName,
|
||||||
{ ...updates, name: updates.name! },
|
{ ...updates, name: updates.name! },
|
||||||
existingStrategy,
|
existingStrategy,
|
||||||
);
|
);
|
||||||
|
console.log(
|
||||||
|
`Standardized updates: ${JSON.stringify(standardizedUpdates)}`,
|
||||||
|
);
|
||||||
const strategy = await this.featureStrategiesStore.updateStrategy(
|
const strategy = await this.featureStrategiesStore.updateStrategy(
|
||||||
id,
|
id,
|
||||||
standardizedUpdates,
|
standardizedUpdates,
|
||||||
|
@ -136,13 +136,18 @@ test('Should be able to update existing strategy configuration', async () => {
|
|||||||
expect(createdConfig.name).toEqual('default');
|
expect(createdConfig.name).toEqual('default');
|
||||||
const updatedConfig = await service.updateStrategy(
|
const updatedConfig = await service.updateStrategy(
|
||||||
createdConfig.id,
|
createdConfig.id,
|
||||||
{ parameters: { b2b: 'true' } },
|
{ name: 'flexibleRollout', parameters: { b2b: 'true' } },
|
||||||
{ projectId, featureName, environment: DEFAULT_ENV },
|
{ projectId, featureName, environment: DEFAULT_ENV },
|
||||||
TEST_AUDIT_USER,
|
TEST_AUDIT_USER,
|
||||||
);
|
);
|
||||||
expect(createdConfig.id).toEqual(updatedConfig.id);
|
expect(createdConfig.id).toEqual(updatedConfig.id);
|
||||||
|
expect(updatedConfig.name).toEqual('flexibleRollout');
|
||||||
expect(updatedConfig.parameters).toEqual({
|
expect(updatedConfig.parameters).toEqual({
|
||||||
b2b: 'true',
|
b2b: 'true',
|
||||||
|
// flexible rollout default parameters
|
||||||
|
rollout: '100',
|
||||||
|
groupId: featureName,
|
||||||
|
stickiness: 'default',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user