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 ()

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
src
lib
routes/admin-api/project
services
test/e2e/api/admin

View File

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

View File

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

View File

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