mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-03 01:18:43 +02:00
fix: should not import archived child and parent (#5912)
This commit is contained in:
parent
9989688d36
commit
af4c3a86d1
@ -305,9 +305,14 @@ export default class ExportImportService
|
|||||||
private async importDependencies(dto: ImportTogglesSchema, user: IUser) {
|
private async importDependencies(dto: ImportTogglesSchema, user: IUser) {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
(dto.data.dependencies || []).flatMap((dependency) => {
|
(dto.data.dependencies || []).flatMap((dependency) => {
|
||||||
const projectId = dto.data.features.find(
|
const feature = dto.data.features.find(
|
||||||
(feature) => feature.name === dependency.feature,
|
(feature) => feature.name === dependency.feature,
|
||||||
)!.project!;
|
);
|
||||||
|
if (!feature || !feature.project) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const projectId = feature!.project!;
|
||||||
return dependency.dependencies.map((parentDependency) =>
|
return dependency.dependencies.map((parentDependency) =>
|
||||||
this.dependentFeaturesService.upsertFeatureDependency(
|
this.dependentFeaturesService.upsertFeatureDependency(
|
||||||
{
|
{
|
||||||
|
@ -1179,6 +1179,68 @@ test('should not import archived features tags', async () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not import archived parent', async () => {
|
||||||
|
await createProjects();
|
||||||
|
await app.createFeature('parent');
|
||||||
|
await app.archiveFeature('parent');
|
||||||
|
await app.importToggles({
|
||||||
|
data: {
|
||||||
|
features: [{ name: 'child' }, { name: 'parent' }],
|
||||||
|
dependencies: [
|
||||||
|
{
|
||||||
|
feature: 'child',
|
||||||
|
dependencies: [
|
||||||
|
{
|
||||||
|
feature: 'parent',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
featureStrategies: [],
|
||||||
|
featureEnvironments: [],
|
||||||
|
featureTags: [],
|
||||||
|
tagTypes: [],
|
||||||
|
contextFields: [],
|
||||||
|
segments: [],
|
||||||
|
},
|
||||||
|
project: DEFAULT_PROJECT,
|
||||||
|
environment: DEFAULT_ENV,
|
||||||
|
});
|
||||||
|
const { body } = await app.getProjectFeatures(DEFAULT_PROJECT);
|
||||||
|
expect(body).toMatchObject({ features: [{ name: 'child' }] });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not import archived child', async () => {
|
||||||
|
await createProjects();
|
||||||
|
await app.createFeature('child');
|
||||||
|
await app.archiveFeature('child');
|
||||||
|
await app.importToggles({
|
||||||
|
data: {
|
||||||
|
features: [{ name: 'child' }, { name: 'parent' }],
|
||||||
|
dependencies: [
|
||||||
|
{
|
||||||
|
feature: 'child',
|
||||||
|
dependencies: [
|
||||||
|
{
|
||||||
|
feature: 'parent',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
featureStrategies: [],
|
||||||
|
featureEnvironments: [],
|
||||||
|
featureTags: [],
|
||||||
|
tagTypes: [],
|
||||||
|
contextFields: [],
|
||||||
|
segments: [],
|
||||||
|
},
|
||||||
|
project: DEFAULT_PROJECT,
|
||||||
|
environment: DEFAULT_ENV,
|
||||||
|
});
|
||||||
|
const { body } = await app.getProjectFeatures(DEFAULT_PROJECT);
|
||||||
|
expect(body).toMatchObject({ features: [{ name: 'parent' }] });
|
||||||
|
});
|
||||||
|
|
||||||
test(`should give errors with flag names if the flags don't match the project pattern`, async () => {
|
test(`should give errors with flag names if the flags don't match the project pattern`, async () => {
|
||||||
await db.stores.environmentStore.create({
|
await db.stores.environmentStore.create({
|
||||||
name: DEFAULT_ENV,
|
name: DEFAULT_ENV,
|
||||||
|
Loading…
Reference in New Issue
Block a user