Skip to main content
Glama
auto-fix-validation.js3.81 kB
#!/usr/bin/env node /** * Auto-Fix Validation Test * Tests the auto-fix functionality to prevent Claude from abandoning the MCP workflow */ import { createLessonDataValidator } from '../src/tools/validate-lesson-data.js'; // Test data with minor validation issues that should be auto-fixed const testDataWithMinorIssues = { metadata: { topic: "Test Auto-Fix", subject: "Matemática", gradeLevel: "6º ano", // Missing duration - should be auto-fixed to 50 }, widgets: [ { type: "head-1", content: { // Missing category - should be auto-fixed to "Educação Geral" author_name: "Test Author" } }, { type: "text-1", content: { text: "This is test content with sufficient length to pass validation requirements." } }, { type: "quiz-1", content: { questions: [ { question: "Test question?", options: ["A", "B", "C"], correct_option: 1 } ] // Missing max_attempts - should be auto-fixed to 2 } } ] }; // Test data with serious errors that cannot be auto-fixed const testDataWithSeriousErrors = { metadata: { topic: "Bad", // Too short - serious error subject: "Matemática" }, widgets: [ { type: "head-1", content: { category: "Test Category" } }, { type: "text-1", content: { text: "Short" // Too short - serious error } } ] }; async function testAutoFixFunctionality() { console.error('🔧 Testing Auto-Fix Validation Functionality\n'); const validator = createLessonDataValidator(); // Test 1: Minor issues should be auto-fixed console.error('📋 Test 1: Minor Issues Auto-Fix'); const result1 = await validator.validateLessonData(testDataWithMinorIssues); if (result1.success) { console.error('✅ Auto-fix successful: Minor issues were automatically resolved'); console.error(` Fixed data duration: ${result1.data.validatedLessonData.metadata.duration}`); console.error(` Auto-fixes applied: ${result1.debug.autoFixesApplied?.length || 0}`); } else { console.error('❌ Auto-fix failed: Should have fixed minor issues'); console.error(' Errors:', result1.error.details?.slice(0, 2)); } console.error('\n📋 Test 2: Serious Errors Should Not Be Auto-Fixed'); const result2 = await validator.validateLessonData(testDataWithSeriousErrors); if (!result2.success) { console.error('✅ Serious errors properly rejected (not auto-fixed)'); console.error(` Error count: ${result2.error.details?.length || 0}`); console.error(` Error summary: ${result2.error.message}`); } else { console.error('❌ Serious errors were incorrectly auto-fixed'); } console.error('\n📋 Test 3: Verify Auto-Fix Methods Work'); // Test individual auto-fix methods const autoFixable1 = validator.isAutoFixable({ type: 'MISSING_FIELD', field: 'duration', severity: 'ERROR' }); const autoFixable2 = validator.isAutoFixable({ type: 'CONTENT_ERROR', field: 'topic', severity: 'ERROR' }); console.error(` Duration missing field auto-fixable: ${autoFixable1 ? '✅' : '❌'}`); console.error(` Topic content error auto-fixable: ${autoFixable2 ? '❌ (correct)' : '✅'}`); console.error('\n🎯 Auto-Fix Test Summary:'); console.error(' Minor issues: Auto-fixed to prevent Claude abandoning workflow'); console.error(' Serious errors: Properly rejected with helpful guidance'); console.error(' Field classification: Working correctly'); console.error('\n✅ Auto-fix functionality verified - should prevent workflow abandonment'); } testAutoFixFunctionality().catch(console.error);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rkm097git/euconquisto-composer-mcp-poc'

If you have feedback or need assistance with the MCP directory API, please join our Discord server