Files
kidsai/test-emotional.js
root 500bd192d5 Initial commit: KidsAI Explorer with complete functionality
- Complete KidsAI Explorer application
- Multi-language support (English/German)
- AI-powered educational guidance using OpenAI
- Interactive chat interface for children
- Proper placeholder translation fixes
- Mobile-responsive design
- Educational framework for critical thinking
2025-07-13 16:59:42 +02:00

82 lines
3.6 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Test script for handling child's emotional frustration
const fetch = require('node-fetch');
const BASE_URL = 'http://localhost:3002';
async function testEmotionalFrustration() {
console.log('🧪 Testing emotional frustration handling...\n');
try {
// Step 1: Child expresses initial frustration
console.log('1⃣ Child says "Keiner versteht mich zu Hause!"...');
const step1 = await fetch(`${BASE_URL}/api/respond-to-answer`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
answer: "Keiner versteht mich zu Hause!",
question: "Was denkst du über Kommunikation?",
originalTopic: "Wie funktioniert Kommunikation?",
language: "de",
sessionId: "test-emotional-123"
})
});
const step1Data = await step1.json();
console.log('🤖 AI Response 1:', step1Data.response || 'No response');
// Step 2: Child escalates with blame
console.log('\n2⃣ Child escalates: "Ich drücke mich sehr gewählt aus. Das Problem sind die anderen!!!"...');
const step2 = await fetch(`${BASE_URL}/api/respond-to-answer`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
answer: "Ich drücke mich sehr gewählt aus. Das Problem sind die anderen!!!",
question: "Was denkst du, warum es manchmal schwer ist, sich auszudrücken?",
originalTopic: "Wie funktioniert Kommunikation?",
language: "de",
sessionId: "test-emotional-123"
})
});
const step2Data = await step2.json();
console.log('🤖 AI Response 2:', step2Data.response || 'No response');
// Analyze the responses
const response1 = step1Data.response || '';
const response2 = step2Data.response || '';
const handlesEmotionWell1 = response1.includes('frustrierend') ||
response1.includes('verstehen') ||
response1.includes('schwer') ||
response1.includes('fühlen');
const handlesEmotionWell2 = response2.includes('verstehen') ||
response2.includes('frustriert') ||
response2.includes('ärgerlich') ||
response2.includes('anders angehen') ||
!response2.includes('interessanter Punkt');
console.log('\n📊 ANALYSIS:');
console.log('Response 1 acknowledges emotion:', handlesEmotionWell1 ? '✅' : '❌');
console.log('Response 2 handles escalation well:', handlesEmotionWell2 ? '✅' : '❌');
if (handlesEmotionWell1 && handlesEmotionWell2) {
console.log('\n🎉 EXCELLENT: AI handles emotional frustration well!');
} else {
console.log('\n⚠ NEEDS IMPROVEMENT: AI should better handle emotional states');
if (!handlesEmotionWell1) {
console.log(' - First response should acknowledge frustration more clearly');
}
if (!handlesEmotionWell2) {
console.log(' - Second response should avoid analytical questions when child is escalating');
}
}
} catch (error) {
console.error('❌ Test failed:', error.message);
}
}
// Run the test
testEmotionalFrustration();