tdm-calculator
tdm-calculator copied to clipboard
Engineer tests and validation for 'Rule' Web API requests
Overview
We need to create a workflow for testing all 'Rule' 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/
@entrotech
We had discussed removing obsolete and/or over-exposed endpoints and I wanted to see if we were still thinking of removing some of the "Rules" endpoints
We can remove all the rule endpoints in the rule.routes.js file, but there is an unusual endpoint that is in calculation.routes.js /api/calculations/:id/rules that uses a single method in the rule.controller.js, which, in turn, uses a method in the rule.service.js file, and we need to keep just those methods in those files.
The other rule endpoints were intended for creating a UI that allowed an administrator to edit rules, but we decided that those features were too complicated and dangerous to build into the application.
Modified this task to just remove the /api/rules endpoints entirely, since we decided not to implement an Admin feature for editing the rules.