Skip to content

Commit

Permalink
Make single project endpoint also return all features favorites (#2578)
Browse files Browse the repository at this point in the history
Small update, that single project endpoint would also return features
with favorites.
  • Loading branch information
sjaanus committed Dec 1, 2022
1 parent 60c9718 commit 24fee65
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/lib/routes/admin-api/project/features.ts
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/lib/services/project-health-service.ts
Expand Up @@ -72,6 +72,7 @@ export default class ProjectHealthService {
const features = await this.featureToggleService.getFeatureOverview({
projectId,
archived,
userId,
});
const members = await this.projectStore.getMembersCountByProject(
projectId,
Expand Down
18 changes: 11 additions & 7 deletions src/test/e2e/api/admin/favorites.e2e.test.ts
Expand Up @@ -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,
},
],
});
});

Expand All @@ -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,
});
Expand Down

0 comments on commit 24fee65

Please sign in to comment.