#!/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();