tdm-calculator icon indicating copy to clipboard operation
tdm-calculator copied to clipboard

Engineer tests and validation for 'Project' Web API requests

Open agosmou opened this issue 1 year ago • 7 comments

Overview

We need to create a workflow for testing all 'Project' endpoints. We will need to set up tests and web API request validation for the endpoints.

Details | Scope of Work

We need to test the API endpoints using 'jest'

Action Items

  • [ ] write all tests for endpoints
  • [ ] set up server side validation schema (this should be done for the POST requests that contain a body - we validate the body data)

Resources/Instructions

TDM Testing

  • Testing Wiki
  • Check existing tests and build your tests to match what is in the codebase

Server Side Validation

  • https://www.npmjs.com/package/express-json-validator-middleware
  • https://simonplend.com/how-to-handle-request-validation-in-your-express-api/

Testing

  • https://jestjs.io/
  • https://testcontainers.com/

agosmou avatar Feb 15 '24 04:02 agosmou

Update: This week I worked on the get requests for project.

As the projects api has multiple requests(get, post, put, delete), it is taking more time for me to implement test cases.

neyaadeez avatar Feb 25 '24 09:02 neyaadeez

Update: Last week and this week, I had my midterms, so I wasn't able to focus on this issue. I will begin working on it now, and I estimate completion by the end of next week. Availability: Friday, Monday - Wednesday

neyaadeez avatar Mar 06 '24 23:03 neyaadeez

@neyaadeez message me on slack with any queries you have or if we need to pair on anything!

agosmou avatar Mar 06 '24 23:03 agosmou

Update: I've been working on the post request and the schema for the post request. Initially, I anticipated completing it by this week. However, upon delving into the code analysis, I've found numerous API endpoints such as trash, delete, update, snapshot, and others. Understanding these is taking some time, so I'm tackling them one by one.

Tests screenshot: Screenshot from 2024-03-20 20-11-38

neyaadeez avatar Mar 21 '24 03:03 neyaadeez

This looks great! If it has ballooned we can split up into smaller PRs if you prefer

agosmou avatar Mar 21 '24 03:03 agosmou

Yes, that would be great!

neyaadeez avatar Mar 21 '24 09:03 neyaadeez

We can use this checklist to track what's complete so far so can make it into smaller chunks.

Can you mark the endpoints you have tested? I can make a quick GH issue for tracking and then you can submit a PR for what you have

  • [ ] router.get("/archivedprojects",jwtSession.validateUser,projectController.getAllArchivedProjects);
  • [x] router.get("/", jwtSession.validateUser, projectController.getAll);
  • [x] router.get("/:id", jwtSession.validateUser, projectController.getById);
  • [x] router.post("/", jwtSession.validateUser, projectController.post);
  • [ ] router.put("/hide", jwtSession.validateUser, projectController.hide);
  • [ ] router.put("/trash", jwtSession.validateUser, projectController.trash);
  • [ ] router.put("/snapshot", jwtSession.validateUser, projectController.snapshot);
  • [ ] router.put("/renameSnapshot",jwtSession.validateUser,projectController.renameSnapshot);
  • [ ] router.put("/:id", jwtSession.validateUser, projectController.put);
  • [ ] router.delete("/:id", jwtSession.validateUser, projectController.del);

agosmou avatar Apr 02 '24 22:04 agosmou