mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
fix: enable disabled strategies keeps settings (#7960)
This commit is contained in:
parent
f9eba202c7
commit
2bfa8827d0
24
package.json
24
package.json
@ -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": [
|
||||
@ -93,13 +91,7 @@
|
||||
"/frontend/",
|
||||
"/website/"
|
||||
],
|
||||
"moduleFileExtensions": [
|
||||
"ts",
|
||||
"tsx",
|
||||
"js",
|
||||
"jsx",
|
||||
"json"
|
||||
],
|
||||
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json"],
|
||||
"coveragePathIgnorePatterns": [
|
||||
"/node_modules/",
|
||||
"/dist/",
|
||||
@ -240,14 +232,8 @@
|
||||
"tough-cookie": "4.1.4"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,ts}": [
|
||||
"biome check --write --no-errors-on-unmatched"
|
||||
],
|
||||
"*.{jsx,tsx}": [
|
||||
"biome check --write --no-errors-on-unmatched"
|
||||
],
|
||||
"*.json": [
|
||||
"biome format --write --no-errors-on-unmatched"
|
||||
]
|
||||
"*.{js,ts}": ["biome check --write --no-errors-on-unmatched"],
|
||||
"*.{jsx,tsx}": ["biome check --write --no-errors-on-unmatched"],
|
||||
"*.json": ["biome format --write --no-errors-on-unmatched"]
|
||||
}
|
||||
}
|
||||
|
@ -1746,7 +1746,7 @@ class FeatureToggleService {
|
||||
strategies.map((strategy) =>
|
||||
this.updateStrategy(
|
||||
strategy.id,
|
||||
{ disabled: false },
|
||||
{ ...strategy, disabled: false },
|
||||
{
|
||||
environment,
|
||||
projectId: project,
|
||||
|
@ -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: 'test@example.com' } as User,
|
||||
shouldActivateDisabledStrategies,
|
||||
);
|
||||
|
||||
const strategy = await service.getStrategy(createdConfig.id);
|
||||
expect(strategy).toMatchObject({ ...config, disabled: false });
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user