Skip to content

SolutionTake-home assignment: tests, bug fix, and task assignment feature by gaurav singh rawat - #84

Open
Gaurav-Rawat28437 wants to merge 21 commits into
rohit-ups:mainfrom
Gaurav-Rawat28437:solution
Open

SolutionTake-home assignment: tests, bug fix, and task assignment feature by gaurav singh rawat#84
Gaurav-Rawat28437 wants to merge 21 commits into
rohit-ups:mainfrom
Gaurav-Rawat28437:solution

Conversation

@Gaurav-Rawat28437

Copy link
Copy Markdown

Take-Home Assignment# Take-Home Assignment — The Untested API

Summary

This PR completes the take-home assignment by adding comprehensive test coverage, identifying and fixing a pagination bug, and implementing the requested task assignment feature.

What I Completed

1. Unit Tests

Added unit tests for the task service covering:

  • Task creation
  • Get all tasks
  • Find task by ID
  • Get tasks by status
  • Pagination
  • Task statistics
  • Overdue tasks
  • Task update
  • Task deletion
  • Task completion
  • Task assignment
  • Assignment validation
  • Priority filtering
  • Assignee filtering
  • Task title search
  • Multiple filters together

2. API Integration Tests

Added Supertest integration tests covering:

  • GET /tasks
  • GET /tasks?status=todo
  • GET /tasks?page=1&limit=10
  • GET /tasks?page=2&limit=10
  • GET /tasks/:id
  • POST /tasks
  • PUT /tasks/:id
  • DELETE /tasks/:id
  • PATCH /tasks/:id/complete
  • PATCH /tasks/:id/assign
  • GET /tasks/stats
  • Priority filtering
  • Assignee filtering
  • Search filtering
  • Combined priority and assignee filtering
  • Validation errors
  • Non-existing task handling
  • Already assigned task handling

3. Validator Unit Tests

Added tests for:

  • Valid task creation data
  • Missing title
  • Empty title
  • Whitespace title
  • Invalid status
  • Invalid priority
  • Invalid due date
  • Valid update data
  • Invalid update data
  • Valid assignee
  • Empty assignee
  • Whitespace assignee
  • Non-string assignee

Bug Found and Fixed

BUG-001 — Pagination Offset Calculation

The tests identified a pagination bug in:

src/services/taskService.js

The original implementation used:

const offset = page * limit;


by : Gaurav Singh Rawat
(mail-to-gr28437@gmail.com)

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