feat: add test suite, fix pagination and completeTask bugs, add assig… - #82
Open
abhishekkamble12 wants to merge 1 commit into
Open
feat: add test suite, fix pagination and completeTask bugs, add assig…#82abhishekkamble12 wants to merge 1 commit into
abhishekkamble12 wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)
getPaginatedusedoffset = 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)
completeTaskhard-codedpriority: '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)
getByStatususes.includes()instead of===. Filtering bystatus=owould match all statuses. Documented inBUG_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