From 68558fc77418a605ea504526b62205d7d563f88a Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Wed, 22 Nov 2023 14:08:52 +0200 Subject: [PATCH] feat: able to search by description (#5392) --- .../feature-search/feature.search.e2e.test.ts | 13 +++++++++++++ .../feature-toggle-strategies-store.ts | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/src/lib/features/feature-search/feature.search.e2e.test.ts b/src/lib/features/feature-search/feature.search.e2e.test.ts index c39deaabb6..2097c89f97 100644 --- a/src/lib/features/feature-search/feature.search.e2e.test.ts +++ b/src/lib/features/feature-search/feature.search.e2e.test.ts @@ -487,3 +487,16 @@ test('should not return duplicate entries when sorting by last seen', async () = total: 3, }); }); + +test('should search features by description', async () => { + const description = 'secretdescription'; + await app.createFeature('my_feature_a'); + await app.createFeature({ name: 'my_feature_b', description }); + + const { body } = await searchFeatures({ + query: 'descr', + }); + expect(body).toMatchObject({ + features: [{ name: 'my_feature_b', description }], + }); +}); diff --git a/src/lib/features/feature-toggle/feature-toggle-strategies-store.ts b/src/lib/features/feature-toggle/feature-toggle-strategies-store.ts index 08737ba26c..e234d0e2a2 100644 --- a/src/lib/features/feature-toggle/feature-toggle-strategies-store.ts +++ b/src/lib/features/feature-toggle/feature-toggle-strategies-store.ts @@ -590,6 +590,10 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore { query.where((builder) => { builder .whereILike('features.name', `%${queryString}%`) + .orWhereILike( + 'features.description', + `%${queryString}%`, + ) .orWhereIn('features.name', tagQuery); }); }