Skip to content

Commit

Permalink
fix: enable disabled strategies keeps settings (#7950)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Aug 21, 2024
1 parent 2a13139 commit 48423fa
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/features/feature-toggle/feature-toggle-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,7 @@ class FeatureToggleService {
strategies.map((strategy) =>
this.updateStrategy(
strategy.id,
{ disabled: false },
{ ...strategy, disabled: false },
{
environment,
projectId: project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<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 });
});

0 comments on commit 48423fa

Please sign in to comment.