Take-home: add full test coverage, fix core API bugs, and implement task assignment endpoint#27
Open
nikkkhil2935 wants to merge 4 commits into
Open
Take-home: add full test coverage, fix core API bugs, and implement task assignment endpoint#27nikkkhil2935 wants to merge 4 commits into
nikkkhil2935 wants to merge 4 commits into
Conversation
- Updated README to reflect new query parameters for task listing and added examples for task assignment. - Introduced a new endpoint PATCH /tasks/:id/assign to assign tasks to users, with validation and conflict handling. - Enhanced task shape to include assignee field and updated status values for consistency. - Implemented validation for task assignment and list query parameters to ensure robust input handling. - Added unit and integration tests for new features, including task assignment and query validation. - Fixed bugs related to pagination, status filtering, and task completion logic. - Improved error handling for unknown routes and internal server errors. - Added a bug report document detailing identified issues and their resolutions.
… logic - Added detailed JSDoc comments throughout taskService.js to clarify purpose and behavior of functions. - Implemented in-memory task management with functions for creating, updating, retrieving, and deleting tasks. - Introduced pagination and filtering capabilities for task retrieval. - Added a completion function to standardize task completion behavior. - Enhanced assignment functionality to handle conflicts and idempotent assignments. - Created a stats function to aggregate task status counts and overdue tasks. - Developed a validators module to centralize input validation for task creation, updates, and queries. - Implemented unit tests for taskService and validators to ensure contract adherence and functionality. - Established integration tests for task routes to validate HTTP behavior and response consistency.
…nsitive filtering
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.
Submission Notes
Summary
PATCH /tasks/:id/assignwith payload validation, conflict handling, and idempotent repeat behaviorGET /tasks/:idfor direct single-task retrieval?assignee=filtering onGET /taskstask-api/BUG_REPORT.mdwith root-cause analysis and fix rationaleBugs Fixed
taskService.js→getPaginatedpage * limitskipped the first page entirelytaskService.js→getByStatustaskService.js→completeTaskprioritytomediumtaskService.js→updateidandcreatedAtto be overwrittenroutes/tasks.js+validators.jsstatus,page, orlimitquery paramsDesign Decisions
PATCH /tasks/:id/assignreturns409 Conflicton reassignmentThe request payload is valid, but it conflicts with current ownership state.
409is semantically correct here — it signals a state conflict, not a client input error, which distinguishes it from400 Bad Request.Idempotent repeat assignment returns
200 OKRepeating the same assignee is treated as a no-op success. This keeps the operation retry-safe and consistent with REST idempotency principles — the resource state does not change, so
201would be misleading.Assignee filtering is case-insensitive
Clients may send
Alice,alice, orALICEdepending on their input layer. Case-insensitive matching at the service boundary prevents silent filter misses without requiring callers to normalize strings.Update uses a mutable-field allow-list
Rather than blocking specific immutable fields, the update flow only accepts an explicit set of mutable fields:
title,description,status,priority,dueDate,assignee. Unknown or immutable keys (includingidandcreatedAt) are silently ignored, protecting data integrity without throwing errors on extra fields.Test Results
Test Suites: 4 passed, 4 total
Tests: 47 passed, 47 total
Coverage: 100% statements | 100% branches | 100% functions | 100% lines