tdm-calculator
tdm-calculator copied to clipboard
Engineer tests and validation for 'Project' Web API requests
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/
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.
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 message me on slack with any queries you have or if we need to pair on anything!
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:
This looks great! If it has ballooned we can split up into smaller PRs if you prefer
Yes, that would be great!
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);