Skip to content

Commit

Permalink
fix: enable disabled strategies keeps settings (#7955)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Aug 21, 2024
1 parent 23c7fc1 commit 8ebebd7
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 20 deletions.
24 changes: 5 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@
"testTimeout": 10000,
"globalSetup": "./scripts/jest-setup.js",
"transform": {
"^.+\\.tsx?$": [
"@swc/jest"
]
"^.+\\.tsx?$": ["@swc/jest"]
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"testPathIgnorePatterns": [
Expand All @@ -93,13 +91,7 @@
"/frontend/",
"/website/"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json"
],
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json"],
"coveragePathIgnorePatterns": [
"/node_modules/",
"/dist/",
Expand Down Expand Up @@ -237,14 +229,8 @@
"tough-cookie": "4.1.3"
},
"lint-staged": {
"*.{js,ts}": [
"biome check --apply --no-errors-on-unmatched"
],
"*.{jsx,tsx}": [
"biome check --apply --no-errors-on-unmatched"
],
"*.json": [
"biome format --write --no-errors-on-unmatched"
]
"*.{js,ts}": ["biome check --apply --no-errors-on-unmatched"],
"*.{jsx,tsx}": ["biome check --apply --no-errors-on-unmatched"],
"*.json": ["biome format --write --no-errors-on-unmatched"]
}
}
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 @@ -1783,7 +1783,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 @@ -734,3 +734,51 @@ test('Should return last seen at per environment', async () => {
);
expect(featureToggle.lastSeenAt).toEqual(new Date(lastSeenAtStoreDate));
});

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 8ebebd7

Please sign in to comment.