From 76a2ec53f19b15c6f6ccf058767b2f5e30c7b8cb Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Tue, 26 Sep 2023 14:31:13 +0200 Subject: [PATCH] feat: Enforce one dependency (#4835) --- .../dependent-features/dependent-features-store.ts | 5 +++++ src/test/e2e/api/client/feature.e2e.test.ts | 9 --------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/lib/features/dependent-features/dependent-features-store.ts b/src/lib/features/dependent-features/dependent-features-store.ts index f01f11d5d13d..e7768a1dcff7 100644 --- a/src/lib/features/dependent-features/dependent-features-store.ts +++ b/src/lib/features/dependent-features/dependent-features-store.ts @@ -23,6 +23,11 @@ export class DependentFeaturesStore implements IDependentFeaturesStore { featureDependency.variants, ); } + // TODO: remove when we support multiple parents + await this.db('dependent_features') + .where('child', featureDependency.child) + .del(); + await this.db('dependent_features') .insert(serializableFeatureDependency) .onConflict(['parent', 'child']) diff --git a/src/test/e2e/api/client/feature.e2e.test.ts b/src/test/e2e/api/client/feature.e2e.test.ts index 58912e866478..57c9194fa205 100644 --- a/src/test/e2e/api/client/feature.e2e.test.ts +++ b/src/test/e2e/api/client/feature.e2e.test.ts @@ -60,11 +60,6 @@ beforeAll(async () => { 'featureY', { feature: 'featureX', variants: ['featureXVariant'] }, ); - // depend on parent being disabled - await app.services.dependentFeaturesService.upsertFeatureDependency( - 'featureY', - { feature: 'featureZ', enabled: false }, - ); await app.services.featureToggleServiceV2.archiveToggle( 'featureArchivedX', @@ -154,10 +149,6 @@ test('returns dependencies', async () => { enabled: true, variants: ['featureXVariant'], }, - { - feature: 'featureZ', - enabled: false, - }, ], }); expect(res.body.features[1].dependencies).toBe(undefined);