feat: comprehensive tests, bug fixes, and PATCH /tasks/:id/assign implementation - #52
Open
KrutagyaKaneria wants to merge 1 commit into
Open
Conversation
Tests (102 passing, 97% coverage): - Unit tests for taskService.js (28 tests) - Unit tests for validators.js (24 tests) - Integration tests for all API routes via Supertest (50 tests) Bug fixes: - Fix completeTask overwriting priority to 'medium' (taskService.js:69) - Fix getPaginated offset formula: page*limit -> (page-1)*limit (taskService.js:12) - Fix update() allowing overwrites of immutable fields id/createdAt (taskService.js:50) New feature — PATCH /tasks/:id/assign: - Validates assignee is a non-empty string, trims whitespace - Stores assignee + assignedAt on the task object - Returns 404 for missing tasks, 400 for invalid body - Reassignment allowed (overwrites previous assignee) - Full test coverage for the new endpoint Bug report included in BUGS.md with 5 identified bugs.
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.
Summary
Adds a full test suite (102 tests, 97% coverage), fixes 3 bugs discovered through testing, and implements the new
PATCH /tasks/:id/assignendpoint with validation and tests.Tests
taskService.test.jsvalidators.test.jsapi.test.jsCoverage: 97.43% statements · 91.66% branches · 93.33% functions · 97.18% lines
Bug Fixes
1.
completeTaskoverwrites priority (taskService.js:69) — FixedCompleting a task silently reset
priorityto'medium', destroying the original value. Removed the hardcodedpriority: 'medium'line so the spread preserves the task's existing priority.2.
getPaginatedwrong offset (taskService.js:12) — FixedOffset was calculated as
page * limitinstead of(page - 1) * limit. Page 1 skipped the firstlimititems entirely, making pagination unusable.3.
updateallows overwriting immutable fields (taskService.js:50) — FixedPUT /tasks/:idspread the raw request body over the task, allowing clients to overwriteidandcreatedAt. Now only whitelisted fields (title,description,status,priority,dueDate) are applied.New Feature:
PATCH /tasks/:id/assignPATCH /tasks/:id/assign
Body: { "assignee": "Alice" }
Design decisions:
assigneemust be a non-empty string — empty/whitespace-only returns400assignedAttimestamp recorded for audit trail404if task doesn't existAdditional Bugs Documented (not fixed)
Two more bugs were identified and documented in
BUGS.md:getByStatususes.includes()instead of===— partial string matching causes?status=doto match bothtodoanddonepending/in-progress/completedbut code usestodo/in_progress/done