- Added user tracking features to the projects module, including: - Database schema updates to track project creator and assignee. - API enhancements for user management and project filtering by user. - UI components for user assignment in project forms and listings. - New query functions for retrieving users and filtering projects. - Security integration with role-based access and authentication requirements. chore: Create utility scripts for database checks and project testing - Added scripts to check the structure of the projects table. - Created tests for project creation and user tracking functionality. - Implemented API tests to verify project retrieval and user assignment. fix: Update project creation and update functions to include user tracking - Modified createProject and updateProject functions to handle user IDs for creator and assignee. - Ensured that project updates reflect the correct user assignments and timestamps.
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
// Test project creation
|
|
const BASE_URL = "http://localhost:3001";
|
|
|
|
async function testProjectCreation() {
|
|
console.log("🧪 Testing project creation...\n");
|
|
|
|
try {
|
|
// First, login to get session
|
|
console.log("1. Logging in...");
|
|
const loginResponse = await fetch(
|
|
`${BASE_URL}/api/auth/signin/credentials`,
|
|
{
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
email: "admin@localhost.com",
|
|
password: "admin123456",
|
|
}),
|
|
}
|
|
);
|
|
|
|
console.log("Login response status:", loginResponse.status);
|
|
const loginResult = await loginResponse.text();
|
|
console.log("Login result:", loginResult.substring(0, 200));
|
|
|
|
// Try a simple API call to see the auth system
|
|
console.log("\n2. Testing projects API...");
|
|
const projectsResponse = await fetch(`${BASE_URL}/api/projects`);
|
|
console.log("Projects API status:", projectsResponse.status);
|
|
|
|
if (projectsResponse.status === 401) {
|
|
console.log("❌ Authentication required (expected for this test)");
|
|
} else {
|
|
const projectsData = await projectsResponse.json();
|
|
console.log("✅ Projects API accessible");
|
|
console.log("Number of projects:", projectsData.length);
|
|
}
|
|
} catch (error) {
|
|
console.error("❌ Test failed:", error.message);
|
|
}
|
|
}
|
|
|
|
testProjectCreation();
|