Skip to content

assigment completed - #49

Open
hello674583 wants to merge 2 commits into
rohit-ups:mainfrom
hello674583:main
Open

assigment completed#49
hello674583 wants to merge 2 commits into
rohit-ups:mainfrom
hello674583:main

Conversation

@hello674583

Copy link
Copy Markdown

Pull Request: Add Comprehensive Test Coverage, Bug Fixes, and Task Assignment Feature

Summary

This pull request improves the reliability and maintainability of the Task Manager API by adding comprehensive automated tests, fixing identified bugs, and implementing a new task assignment feature.

Changes Made

✅ Added Unit Tests

Implemented unit tests for the taskService covering:

  • Task creation

  • Retrieving all tasks

  • Finding tasks by ID

  • Filtering tasks by status

  • Updating tasks

  • Deleting tasks

  • Completing tasks

  • Pagination

  • Statistics

  • Task assignment

✅ Added Integration Tests

Implemented API integration tests using Supertest for all existing endpoints:

  • GET /tasks

  • GET /tasks?status=

  • GET /tasks?page=&limit=

  • POST /tasks

  • PUT /tasks/:id

  • DELETE /tasks/:id

  • PATCH /tasks/:id/complete

  • GET /tasks/stats

The tests cover both successful requests and common error scenarios such as invalid input and missing resources.

✅ Bug Fixes

Pagination Bug

  • Fixed incorrect pagination offset calculation.

  • Updated the offset formula from page * limit to (page - 1) * limit so the first page returns the correct records.

Task Completion Bug

  • Fixed an issue where completing a task unintentionally reset its priority to "medium".

  • Task completion now updates only the task status and completion timestamp while preserving the existing priority.

✅ New Feature

Implemented a new endpoint:

PATCH /tasks/:id/assign

Features include:

  • Assigns an assignee to an existing task.

  • Returns the updated task.

  • Returns 404 Not Found if the task does not exist.

  • Returns 400 Bad Request for invalid or empty assignee values.

  • Added both unit and integration tests for the new endpoint.

Test Coverage

Coverage results:

Metric | Coverage -- | -- Statements | 92.1% Branches | 77.9% Functions | 93.1% Lines | 91.36%

A total of 35 automated tests have been added, all of which are passing.

Testing

Executed:

npm test
npm run coverage

Result:

  • ✅ 35/35 tests passing

  • ✅ All endpoints verified

  • ✅ New feature fully tested

  • ✅ Existing bugs identified and resolved

Notes

If more time were available, I would add additional branch coverage for validation edge cases, performance tests, and concurrency scenarios to further improve the robustness of the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant