From c6d2eed9ed3f087adf6711ab886f6d26b1c8b50c Mon Sep 17 00:00:00 2001 From: Catalin Oancea Date: Wed, 18 Dec 2024 12:59:13 +0200 Subject: [PATCH] Remove projectScorecard endpoint and return all info on existing one --- .../modules/projects/projects.controller.ts | 11 -------- .../integration/projects/projects.spec.ts | 26 +++---------------- shared/contracts/projects.contract.ts | 15 ++--------- 3 files changed, 6 insertions(+), 46 deletions(-) diff --git a/api/src/modules/projects/projects.controller.ts b/api/src/modules/projects/projects.controller.ts index bca8cb3b..2f48dc13 100644 --- a/api/src/modules/projects/projects.controller.ts +++ b/api/src/modules/projects/projects.controller.ts @@ -84,17 +84,6 @@ export class ProjectsController { async getProject(): ControllerResponse { return tsRestHandler( projectsContract.getProject, - async ({ params: { id }, query }) => { - const data = await this.projectsService.getById(id, query); - return { body: { data }, status: HttpStatus.OK }; - }, - ); - } - - @TsRestHandler(projectsContract.getProjectWithScorecard) - async getProjectWithScorecard(): ControllerResponse { - return tsRestHandler( - projectsContract.getProjectWithScorecard, async ({ params: { id }, query }) => { const data = await this.projectsScorecardService.getById(id, query); return { body: { data }, status: HttpStatus.OK }; diff --git a/api/test/integration/projects/projects.spec.ts b/api/test/integration/projects/projects.spec.ts index 6da9b7cf..20db1682 100644 --- a/api/test/integration/projects/projects.spec.ts +++ b/api/test/integration/projects/projects.spec.ts @@ -352,8 +352,8 @@ describe('Projects', () => { expect(response.status).toBe(HttpStatus.OK); expect(response.body.data).toHaveLength(2); expect(response.body.maximums).toEqual({ - maxAbatementPotential: 20, - maxTotalCost: 300, + maxAbatementPotential: 30, + maxTotalCost: 200, }); }); @@ -387,6 +387,8 @@ describe('Projects', () => { expect(response.status).toBe(HttpStatus.OK); expect(response.body.data.projectName).toBe(project.projectName); + expect(response.body.data.feasibilityAnalysisNPV).toBeDefined(); + expect(response.body.data.socialFeasibility).toBeDefined(); }); test('Should return a 400 if project does not exist', async () => { @@ -396,25 +398,5 @@ describe('Projects', () => { expect(response.status).toBe(HttpStatus.BAD_REQUEST); }); - - test('Should return a project with scorecard', async () => { - const project = await testManager.mocks().createProject(); - await testManager.mocks().createProjectScorecard({ - id: project.id, - }); - - const response = await testManager - .request() - .get( - projectsContract.getProjectWithScorecard.path.replace( - ':id', - project.id, - ), - ); - - expect(response.status).toBe(HttpStatus.OK); - expect(response.body.data.feasibilityAnalysisNPV).toBeDefined(); - expect(response.body.data.socialFeasibility).toBeDefined(); - }); }); }); diff --git a/shared/contracts/projects.contract.ts b/shared/contracts/projects.contract.ts index a7173900..bdda416d 100644 --- a/shared/contracts/projects.contract.ts +++ b/shared/contracts/projects.contract.ts @@ -52,17 +52,6 @@ export const projectsContract = contract.router({ }, query: getProjectScorecardQuerySchema, }, - getProjectWithScorecard: { - method: "GET", - path: "/projects/:id/scorecard", - pathParams: z.object({ - id: z.coerce.string().uuid(), - }), - responses: { - 200: contract.type>(), - }, - query: projectScorecardQuerySchema, - }, getProject: { method: "GET", path: "/projects/:id", @@ -70,9 +59,9 @@ export const projectsContract = contract.router({ id: z.coerce.string().uuid(), }), responses: { - 200: contract.type>(), + 200: contract.type>(), }, - query: projectsQuerySchema, + query: projectScorecardQuerySchema, }, getProjectCountries: { method: "GET",