1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-01 01:18:10 +02:00

Make single project endpoint also return all features favorites (#2578)

Small update, that single project endpoint would also return features
with favorites.
This commit is contained in:
sjaanus 2022-12-01 08:49:49 +01:00 committed by GitHub
parent 60c9718b8d
commit 24fee65f7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 9 deletions

View File

@ -403,10 +403,8 @@ export default class ProjectFeaturesController extends Controller {
res: Response<FeaturesSchema>,
): Promise<void> {
const { projectId } = req.params;
const { user } = req;
const features = await this.featureService.getFeatureOverview({
projectId,
userId: user.id,
});
this.openApiService.respondWithValidation(
200,

View File

@ -72,6 +72,7 @@ export default class ProjectHealthService {
const features = await this.featureToggleService.getFeatureOverview({
projectId,
archived,
userId,
});
const members = await this.projectStore.getMembersCountByProject(
projectId,

View File

@ -111,16 +111,21 @@ test('should be favorited in project endpoint', async () => {
const featureName = 'test-feature';
await createFeature(featureName);
await favoriteFeature(featureName);
await favoriteProject();
const { body } = await app.request
.get(`/api/admin/projects/default/features`)
.get(`/api/admin/projects/default`)
.set('Content-Type', 'application/json')
.expect(200);
expect(body.features).toHaveLength(1);
expect(body.features[0]).toMatchObject({
name: featureName,
expect(body).toMatchObject({
favorite: true,
features: [
{
name: featureName,
favorite: true,
},
],
});
});
@ -129,12 +134,11 @@ test('feature should not be favorited by default', async () => {
await createFeature(featureName);
const { body } = await app.request
.get(`/api/admin/projects/default/features`)
.get(`/api/admin/projects/default/features/${featureName}`)
.set('Content-Type', 'application/json')
.expect(200);
expect(body.features).toHaveLength(1);
expect(body.features[0]).toMatchObject({
expect(body).toMatchObject({
name: featureName,
favorite: false,
});