Files
panel/test-task-sets.mjs
chop 952caf10d1 feat: add task sets functionality with CRUD operations and UI integration
- Implemented NewTaskSetPage for creating task sets with templates.
- Created TaskSetsPage for listing and filtering task sets.
- Enhanced TaskTemplatesPage with navigation to task sets.
- Updated ProjectTaskForm to support task set selection.
- Modified PageHeader to support multiple action buttons.
- Initialized database with task_sets and task_set_templates tables.
- Added queries for task sets including creation, retrieval, and deletion.
- Implemented applyTaskSetToProject function for bulk task creation.
- Added test script for verifying task sets functionality.
2025-10-07 21:58:08 +02:00

71 lines
2.3 KiB
JavaScript

#!/usr/bin/env node
// Test script to verify task sets functionality
import { getAllTaskSets, createTaskSet } from './src/lib/queries/tasks.js';
import initializeDatabase from './src/lib/init-db.js';
async function testTaskSets() {
console.log('Testing Task Sets Database Functions...\n');
try {
// Initialize database
initializeDatabase();
// Test 1: Get all task sets
console.log('1. Getting all task sets...');
const taskSets = getAllTaskSets();
console.log(`Found ${taskSets.length} task sets:`);
taskSets.forEach(set => {
console.log(` - ${set.name} (${set.task_category}):`, JSON.stringify(set));
});
// Test 2: Create a new task set (design)
console.log('\n2. Creating design task set...');
const designSetId = createTaskSet({
name: 'Test Design Set',
description: 'Test task set for design tasks',
task_category: 'design',
templates: []
});
console.log(`Created task set with ID: ${designSetId}`);
// Test 3: Create a construction task set
console.log('\n3. Creating construction task set...');
const constructionSetId = createTaskSet({
name: 'Test Construction Set',
description: 'Test task set for construction tasks',
task_category: 'construction',
templates: []
});
console.log(`Created task set with ID: ${constructionSetId}`);
// Test 4: Try to create invalid task set (should fail)
console.log('\n4. Testing invalid task category (should fail)...');
try {
const invalidSetId = createTaskSet({
name: 'Invalid Set',
description: 'This should fail',
task_category: 'design+construction',
templates: []
});
console.log('✗ Should have failed to create invalid task set');
} catch (error) {
console.log('✓ Correctly rejected invalid task category:', error.message);
}
// Test 5: Get all task sets again
console.log('\n5. Getting all task sets after creation...');
const updatedTaskSets = getAllTaskSets();
console.log(`Found ${updatedTaskSets.length} task sets:`);
updatedTaskSets.forEach(set => {
console.log(` - ${set.name} (${set.task_category})`);
});
console.log('\n✅ All tests passed! Task sets functionality is working correctly.');
} catch (error) {
console.error('Test failed:', error.message);
}
}
testTaskSets();