Skip to content

changes#31

Open
Parthmudgal15105 wants to merge 2 commits into
rohit-ups:mainfrom
Parthmudgal15105:submission-branch
Open

changes#31
Parthmudgal15105 wants to merge 2 commits into
rohit-ups:mainfrom
Parthmudgal15105:submission-branch

Conversation

@Parthmudgal15105
Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings April 14, 2026 20:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a Jest/Supertest test suite for the Task API, fixes multiple bugs discovered via testing, and implements the new PATCH /tasks/:id/assign feature with validation and documentation notes.

Changes:

  • Added unit tests for taskService and integration tests for /tasks endpoints (including the new assign endpoint).
  • Fixed status filtering to match exact statuses and prevented completeTask from overwriting priority.
  • Added PATCH /tasks/:id/assign with request validation, and adjusted pagination parsing to allow page=0.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
task-api/tests/tasks.api.test.js Adds API integration coverage for stats/list/create/update/delete/complete/assign.
task-api/tests/taskService.test.js Adds unit coverage and regression tests for previously buggy service behaviors.
task-api/src/utils/validators.js Adds validateAssignTask and exports it for route usage.
task-api/src/services/taskService.js Fixes getByStatus exact matching, removes priority override in completeTask, adds assignTask.
task-api/src/routes/tasks.js Fixes page=0 parsing issue and adds the /assign route handler.
SUBMISSION.md Adds coverage summary, bug fix summary, and design notes for the assign endpoint.
BUG_REPORT.md Documents the three discovered bugs and their fixes.
.claude/settings.json Adds Claude tooling permission configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +36 to +40
const validateAssignTask = (body) => {
if (!body.assignee || typeof body.assignee !== 'string' || body.assignee.trim() === '') {
return 'assignee is required and must be a non-empty string';
}
return null;
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validateAssignTask assumes body is a non-null object and will throw if it’s called with undefined/null (e.g., when the request has no JSON body or a non-JSON Content-Type, req.body can be undefined). Consider defensively handling a falsy body (treat as {}) and returning a 400 validation message instead of letting the request fall into the 500 error handler.

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +23
const parsedPage = parseInt(page);
const pageNum = isNaN(parsedPage) ? 1 : parsedPage;
const parsedLimit = parseInt(limit);
const limitNum = isNaN(parsedLimit) ? 10 : parsedLimit;
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pagination defaults look inconsistent with the (now-supported) page=0 / zero-based paging model: when limit is provided without page (e.g. /tasks?limit=2), parsedPage becomes NaN and pageNum defaults to 1, which skips the first page (offset = page * limit). Consider defaulting pageNum to 0 when page is missing, or (if the API is intended to be 1-based) adjusting the service call to use (pageNum - 1) when computing the offset. Also consider rejecting negative page/limit values to avoid Array.slice's surprising behavior with negatives.

Suggested change
const parsedPage = parseInt(page);
const pageNum = isNaN(parsedPage) ? 1 : parsedPage;
const parsedLimit = parseInt(limit);
const limitNum = isNaN(parsedLimit) ? 10 : parsedLimit;
const parsedPage = page === undefined ? 0 : parseInt(page, 10);
const parsedLimit = limit === undefined ? 10 : parseInt(limit, 10);
if (Number.isNaN(parsedPage) || parsedPage < 0) {
return res.status(400).json({ error: 'page must be a non-negative integer' });
}
if (Number.isNaN(parsedLimit) || parsedLimit < 0) {
return res.status(400).json({ error: 'limit must be a non-negative integer' });
}
const pageNum = parsedPage;
const limitNum = parsedLimit;

Copilot uses AI. Check for mistakes.
Comment thread SUBMISSION.md
Comment on lines +15 to +17
tasks.js | 100.00 | 91.66 | 100.00 | 100.00 | 21-23
src/services | 100.00 | 94.73 | 100.00 | 100.00 |
taskService.js | 100.00 | 94.73 | 100.00 | 100.00 | 22
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pasted coverage table appears internally inconsistent: it reports tasks.js (and taskService.js) at 100% lines/statements while also listing uncovered line numbers (e.g. tasks.js | ... | 21-23). If these line numbers are truly uncovered, the percentages should be <100; otherwise the uncovered-line column should be empty. Please re-run npm run coverage and update this snippet so the numbers match the actual output.

Suggested change
tasks.js | 100.00 | 91.66 | 100.00 | 100.00 | 21-23
src/services | 100.00 | 94.73 | 100.00 | 100.00 |
taskService.js | 100.00 | 94.73 | 100.00 | 100.00 | 22
tasks.js | 100.00 | 91.66 | 100.00 | 100.00 |
src/services | 100.00 | 94.73 | 100.00 | 100.00 |
taskService.js | 100.00 | 94.73 | 100.00 | 100.00 |

Copilot uses AI. Check for mistakes.
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.

2 participants