Real-Dev-Squad / website-backend

The backend code for all our website-related apps
https://api.realdevsquad.com/
MIT License
52 stars 252 forks source link

Added test and controller for extension request in /request #2032

Closed sahsisunny closed 5 months ago

sahsisunny commented 5 months ago

Issue Ticket Number

This PR completes the migration of extension requests to the /request API endpoint with a feature flag. Additionally, it adds the necessary controller and integration tests for handling extension requests uniformly through the /request API endpoint.

Dependent PRs

  1. REFACTOR: request controller and model functions #2017 (PR Link): This PR refactors the request controller and model functions to support the migration of extension requests to the /request API endpoint.
  2. Added middleware for extension request for /request route #2028 (PR Link): This PR adds middleware for handling extension requests specifically for the /request route.

Documentation Updated?

Under Feature Flag

Database Changes

Breaking Changes

Development Tested?

Screenshots

Screenshots ### Successful create ER ![image](https://github.com/Real-Dev-Squad/website-backend/assets/70854507/50b99b33-0b3d-42c5-828d-e9c85df7fbcc) ### When the old ETA is not matched to the original task old ETA ![image](https://github.com/Real-Dev-Squad/website-backend/assets/70854507/dcf54063-6227-4681-86f0-048de1da6edd) ### When task id is invalid ![image](https://github.com/Real-Dev-Squad/website-backend/assets/70854507/d48dcaac-0f17-4081-9af9-f722e6b19a46) ### When pending ER already exists image

Test Coverage

Test Coverage | File | Lines | Lines Covered | % Lines Covered | Details | |---------------|----------|---------------|-----------------|------------------------------------------------------------| | requests.ts | 85.07 | 67.74 | 100 | 44,109,113-114,124-130,133-139,149-150 | ##### Tests /requests Extension POST /requests ✔ should return 401(Unauthorized) if user is not logged in ✔ should create a new extension request (76ms) ✔ should create a new extension request by super user (98ms) ✔ should not create a new extension request by another user (68ms) ✔ should not create a new extension request if task is not exist (66ms) ✔ should not create a new extension request if assignee is not present (58ms) ✔ should not create a new extension request if old ETA does not match the task's ETA (50ms) ✔ should not create a new extension request if an extension request for this task already exists (151ms)

Additional Notes