Skip to content

Commit

Permalink
feat: search endpoint should return archived at date
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaanus committed Oct 30, 2024
1 parent 65c7f77 commit 5afee74
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/lib/features/feature-search/feature-search-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions src/lib/features/feature-search/feature.search.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -1154,6 +1159,7 @@ test('should return archived when query param set', async () => {
features: [
{
name: 'my_feature_a',
archivedAt: null,
},
],
});
Expand All @@ -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,
},
],
});
Expand Down
5 changes: 0 additions & 5 deletions src/lib/openapi/spec/feature-search-response-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions src/lib/types/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export type IFeatureSearchOverview = Exclude<
> & {
dependencyType: 'parent' | 'child' | null;
environments: FeatureSearchEnvironmentSchema[];
archivedAt: string;
createdBy: {
id: number;
name: string;
Expand Down
13 changes: 0 additions & 13 deletions src/test/e2e/helpers/test-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ export interface IUnleashHttpAPI {
expectedResponseCode?: number,
): supertest.Test;

getFeatures(name?: string, expectedResponseCode?: number): supertest.Test;

getProjectFeatures(
project: string,
name?: string,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5afee74

Please sign in to comment.