Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable disabled strategies keeps settings #7950

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestion: can we be clearer about what we're checking here? Something like

Suggested change
test('Should enable disabled strategies on feature environment enabled', async () => {
test('Should not remove constraints or strategy variants on feature environment enabled', async () => {
Suggested change
test('Should enable disabled strategies on feature environment enabled', async () => {
test('Strategy configurations should not change on feature environment enabled', async () => {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I was late 🤷🏼

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 });
});
Loading