feat: Add user tracking to project tasks and notes

- Implemented user tracking columns in project_tasks and notes tables.
- Added created_by and assigned_to fields to project_tasks.
- Introduced created_by field and is_system flag in notes.
- Updated API endpoints to handle user tracking during task and note creation.
- Enhanced database initialization to include new columns and indexes.
- Created utility functions to fetch users for task assignment.
- Updated front-end components to display user information for tasks and notes.
- Added tests for project-tasks API endpoints to verify functionality.
This commit is contained in:
Chop
2025-06-26 00:17:51 +02:00
parent 294d8343d3
commit 90875db28b
19 changed files with 785 additions and 147 deletions

44
test-task-api.mjs Normal file
View File

@@ -0,0 +1,44 @@
// Test the project-tasks API endpoints
async function testAPI() {
const baseURL = "http://localhost:3000";
console.log("Testing project-tasks API endpoints...\n");
try {
// Test 1: Check if users endpoint exists
console.log("1. Testing /api/project-tasks/users:");
const usersResponse = await fetch(`${baseURL}/api/project-tasks/users`);
console.log("Status:", usersResponse.status);
if (usersResponse.ok) {
const users = await usersResponse.json();
console.log("Users found:", users.length);
console.log("First user:", users[0]);
} else {
const error = await usersResponse.text();
console.log("Error:", error);
}
// Test 2: Try to create a task (this will fail without auth, but let's see the response)
console.log("\n2. Testing POST /api/project-tasks:");
const taskData = {
project_id: 1,
task_template_id: 1,
priority: "normal",
};
const createResponse = await fetch(`${baseURL}/api/project-tasks`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(taskData),
});
console.log("Status:", createResponse.status);
const responseText = await createResponse.text();
console.log("Response:", responseText);
} catch (error) {
console.error("Error testing API:", error.message);
}
}
testAPI();