mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
fix: don't include archived feature strategies (#955)
This commit is contained in:
parent
0e82ab28f8
commit
e42e0f620a
@ -11,6 +11,7 @@ import {
|
||||
TAG_IMPORT,
|
||||
PROJECT_IMPORT,
|
||||
} from '../types/events';
|
||||
import { GLOBAL_ENV } from '../types/environment';
|
||||
|
||||
const oldExportExample = require('./state-service-export-v1.json');
|
||||
|
||||
@ -216,6 +217,57 @@ test('should export featureToggles', async () => {
|
||||
expect(data.features[0].name).toBe('a-feature');
|
||||
});
|
||||
|
||||
test('archived feature toggles should not be included', async () => {
|
||||
const { stateService, stores } = getSetup();
|
||||
|
||||
await stores.featureToggleStore.create('default', {
|
||||
name: 'a-feature',
|
||||
archived: true,
|
||||
});
|
||||
const data = await stateService.export({ includeFeatureToggles: true });
|
||||
|
||||
expect(data.features).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('featureStrategy connected to an archived feature toggle should not be included', async () => {
|
||||
const { stateService, stores } = getSetup();
|
||||
const featureName = 'fstrat-archived-feature';
|
||||
await stores.featureToggleStore.create('default', {
|
||||
name: featureName,
|
||||
archived: true,
|
||||
});
|
||||
|
||||
await stores.featureStrategiesStore.createStrategyFeatureEnv({
|
||||
featureName,
|
||||
strategyName: 'fstrat-archived-strat',
|
||||
environment: GLOBAL_ENV,
|
||||
constraints: [],
|
||||
parameters: {},
|
||||
projectId: 'default',
|
||||
});
|
||||
const data = await stateService.export({ includeFeatureToggles: true });
|
||||
expect(data.featureStrategies).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('featureStrategy connected to a feature should be included', async () => {
|
||||
const { stateService, stores } = getSetup();
|
||||
const featureName = 'fstrat-feature';
|
||||
await stores.featureToggleStore.create('default', {
|
||||
name: featureName,
|
||||
});
|
||||
|
||||
await stores.featureStrategiesStore.createStrategyFeatureEnv({
|
||||
featureName,
|
||||
strategyName: 'fstrat-strat',
|
||||
environment: GLOBAL_ENV,
|
||||
constraints: [],
|
||||
parameters: {},
|
||||
projectId: 'default',
|
||||
});
|
||||
const data = await stateService.export({ includeFeatureToggles: true });
|
||||
expect(data.featureStrategies).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('should export strategies', async () => {
|
||||
const { stateService, stores } = getSetup();
|
||||
|
||||
|
@ -542,7 +542,7 @@ export default class StateService {
|
||||
}> {
|
||||
return Promise.all([
|
||||
includeFeatureToggles
|
||||
? this.toggleStore.getAll()
|
||||
? this.toggleStore.getAll({ archived: false })
|
||||
: Promise.resolve([]),
|
||||
includeStrategies
|
||||
? this.strategyStore.getEditableStrategies()
|
||||
@ -583,9 +583,13 @@ export default class StateService {
|
||||
tagTypes,
|
||||
tags,
|
||||
featureTags,
|
||||
featureStrategies,
|
||||
featureStrategies: featureStrategies.filter((fS) =>
|
||||
features.some((f) => fS.featureName === f.name),
|
||||
),
|
||||
environments,
|
||||
featureEnvironments,
|
||||
featureEnvironments: featureEnvironments.filter((fE) =>
|
||||
features.some((f) => fE.featureName === f.name),
|
||||
),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user