KnowledgeBridge / tests /integration /test-formatting.js
fazeel007's picture
initial commit
7c012de
#!/usr/bin/env node
// Test both formatting options
async function testFormatting() {
console.log('🎨 Testing Document Analysis Formatting Options...\n');
const testContent = "This research paper introduces a new machine learning algorithm for natural language processing. The algorithm achieves state-of-the-art results on multiple benchmark datasets including GLUE and SuperGLUE. It reduces training time by 45% compared to previous methods while maintaining 98% accuracy. The approach uses a novel attention mechanism and efficient gradient optimization.";
console.log('πŸ“ Test Content:', testContent.substring(0, 100) + '...\n');
// Test 1: Markdown formatting (default)
console.log('πŸ”€ Testing MARKDOWN formatting...');
try {
const markdownResponse = await fetch('http://localhost:5000/api/analyze-document', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
content: testContent,
analysisType: 'summary',
useMarkdown: true
})
});
if (markdownResponse.ok) {
const markdownResult = await markdownResponse.json();
console.log('βœ… MARKDOWN Result:');
console.log('---');
console.log(markdownResult.analysis);
console.log('---\n');
} else {
console.log('❌ Markdown test failed');
}
} catch (error) {
console.log('❌ Markdown error:', error.message);
}
// Test 2: Plain text formatting
console.log('πŸ“„ Testing PLAIN TEXT formatting...');
try {
const plainResponse = await fetch('http://localhost:5000/api/analyze-document', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
content: testContent,
analysisType: 'summary',
useMarkdown: false
})
});
if (plainResponse.ok) {
const plainResult = await plainResponse.json();
console.log('βœ… PLAIN TEXT Result:');
console.log('---');
console.log(plainResult.analysis);
console.log('---\n');
} else {
console.log('❌ Plain text test failed');
}
} catch (error) {
console.log('❌ Plain text error:', error.message);
}
console.log('🎯 Test Complete!');
console.log('πŸ’‘ You can now choose formatting in the AI Tools β†’ Analysis tab');
}
testFormatting();