Skip to content

feat: add test suite, fix pagination and completeTask bugs, add assig… - #82

Open
abhishekkamble12 wants to merge 1 commit into
rohit-ups:mainfrom
abhishekkamble12:main
Open

feat: add test suite, fix pagination and completeTask bugs, add assig…#82
abhishekkamble12 wants to merge 1 commit into
rohit-ups:mainfrom
abhishekkamble12:main

Conversation

@abhishekkamble12

@abhishekkamble12 abhishekkamble12 commented Aug 16, 2026

Copy link
Copy Markdown

What this PR does

Completes the take-home assignment end to end — tests, bug fixes, and the new assign endpoint.


Tests added

Three new test files under task-api/tests/:

  • validators.test.js — unit tests for all validation rules (valid inputs, missing fields, wrong types, boundary cases)
  • taskService.test.js — unit tests for all service functions directly (CRUD, pagination, stats, state isolation)
  • tasks.routes.test.js — Supertest integration tests for every route (happy paths, 400/404 cases, edge cases)

113 tests total, all passing. Coverage: 97.3% statements / 96.4% branches.


Bugs found and fixed

Bug 1 — Pagination skips the first page (fixed)

getPaginated used offset = page * limit. With page=1, limit=10 that's offset 10 — the first page returns nothing. Fixed to (page - 1) * limit.

Bug 2 — Completing a task silently resets priority (fixed)

completeTask hard-coded priority: 'medium' in the object spread, overwriting whatever priority the task had. Removed that line — priority is now preserved on completion.

Bug 3 — Status filter uses substring match (documented, not fixed)

getByStatus uses .includes() instead of ===. Filtering by status=o would match all statuses. Documented in BUG_REPORT.md. Didn't fix because it causes no visible failures with current status values, but it should be fixed before adding new statuses.


New feature — PATCH /tasks/:id/assign

…n endpoint

- Fix getPaginated offset formula (page * limit → (page-1) * limit)
- Fix completeTask silently resetting priority to medium
- Add PATCH /tasks/:id/assign endpoint with validation
- Add 113 Jest/Supertest tests across routes, service, and validators (97% coverage)
- Add BUG_REPORT.md documenting all 3 bugs found
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