From 5afee747462761bb72ac6e723fa8c103935bca59 Mon Sep 17 00:00:00 2001 From: sjaanus Date: Wed, 30 Oct 2024 12:16:03 +0200 Subject: [PATCH] feat: search endpoint should return archived at date --- .../features/feature-search/feature-search-store.ts | 2 ++ .../feature-search/feature.search.e2e.test.ts | 10 ++++++++++ .../openapi/spec/feature-search-response-schema.ts | 5 ----- src/lib/types/model.ts | 1 + src/test/e2e/helpers/test-helper.ts | 13 ------------- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/lib/features/feature-search/feature-search-store.ts b/src/lib/features/feature-search/feature-search-store.ts index bf3fd577c1a7..f08eb624f8cc 100644 --- a/src/lib/features/feature-search/feature-search-store.ts +++ b/src/lib/features/feature-search/feature-search-store.ts @@ -121,6 +121,7 @@ class FeatureSearchStore implements IFeatureSearchStore { 'features.name as feature_name', 'features.description as description', 'features.type as type', + 'features.archived_at as archived_at', 'features.project as project', 'features.created_at as created_at', 'features.stale as stale', @@ -475,6 +476,7 @@ class FeatureSearchStore implements IFeatureSearchStore { name: row.feature_name, createdAt: row.created_at, stale: row.stale, + archivedAt: row.archived_at, impressionData: row.impression_data, lastSeenAt: row.last_seen_at, dependencyType: row.dependency, 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 396010cc2278..41d52ad5896e 100644 --- a/src/lib/features/feature-search/feature.search.e2e.test.ts +++ b/src/lib/features/feature-search/feature.search.e2e.test.ts @@ -179,6 +179,11 @@ const filterFeaturesByEnvironmentStatus = async ( const searchFeaturesWithoutQueryParams = async (expectedCode = 200) => { return app.request.get(`/api/admin/search/features`).expect(expectedCode); }; +const getProjectArchive = async (projectId = 'default', expectedCode = 200) => { + return app.request + .get(`/api/admin/archive/features/${projectId}`) + .expect(expectedCode); +}; test('should search matching features by name', async () => { await app.createFeature('my_feature_a'); @@ -1154,6 +1159,7 @@ test('should return archived when query param set', async () => { features: [ { name: 'my_feature_a', + archivedAt: null, }, ], }); @@ -1162,10 +1168,14 @@ test('should return archived when query param set', async () => { query: 'my_feature', archived: 'IS:true', }); + + const { body: archive } = await getProjectArchive(); + expect(archivedFeatures).toMatchObject({ features: [ { name: 'my_feature_b', + archivedAt: archive.features[0].archivedAt, }, ], }); diff --git a/src/lib/openapi/spec/feature-search-response-schema.ts b/src/lib/openapi/spec/feature-search-response-schema.ts index 3bb5e64f6da1..5085116acc73 100644 --- a/src/lib/openapi/spec/feature-search-response-schema.ts +++ b/src/lib/openapi/spec/feature-search-response-schema.ts @@ -54,11 +54,6 @@ export const featureSearchResponseSchema = { description: "The type of dependency. 'parent' means that the feature is a parent feature, 'child' means that the feature is a child feature.", }, - archived: { - type: 'boolean', - example: true, - description: '`true` if the feature is archived', - }, project: { type: 'string', example: 'dx-squad', diff --git a/src/lib/types/model.ts b/src/lib/types/model.ts index 46da47981400..9300b58dadec 100644 --- a/src/lib/types/model.ts +++ b/src/lib/types/model.ts @@ -261,6 +261,7 @@ export type IFeatureSearchOverview = Exclude< > & { dependencyType: 'parent' | 'child' | null; environments: FeatureSearchEnvironmentSchema[]; + archivedAt: string; createdBy: { id: number; name: string; diff --git a/src/test/e2e/helpers/test-helper.ts b/src/test/e2e/helpers/test-helper.ts index bc4f81491b63..068d88708b76 100644 --- a/src/test/e2e/helpers/test-helper.ts +++ b/src/test/e2e/helpers/test-helper.ts @@ -73,8 +73,6 @@ export interface IUnleashHttpAPI { expectedResponseCode?: number, ): supertest.Test; - getFeatures(name?: string, expectedResponseCode?: number): supertest.Test; - getProjectFeatures( project: string, name?: string, @@ -154,17 +152,6 @@ function httpApis( .expect(expectedResponseCode); }, - getFeatures( - name?: string, - expectedResponseCode: number = 200, - ): supertest.Test { - const featuresUrl = `/api/admin/features${name ? `/${name}` : ''}`; - return request - .get(featuresUrl) - .set('Content-Type', 'application/json') - .expect(expectedResponseCode); - }, - getProjectFeatures( project: string = DEFAULT_PROJECT, name?: string,