// Test script to verify frustration/inappropriate comment handling const fetch = require('node-fetch'); const BASE_URL = 'http://localhost:3002'; async function testFrustrationHandling() { console.log('🧪 Testing KidsAI frustration handling...\n'); try { // Step 1: Start conversation about communication console.log('1️⃣ Starting conversation about communication...'); const step1 = await fetch(`${BASE_URL}/api/ask`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ question: "Warum antwortet Papa nicht auf meine Fragen?", language: "de" }) }); const step1Data = await step1.json(); console.log('🤖 AI Response:', step1Data.guidance?.steps?.[0]?.text || 'No response'); // Step 2: Child says something inappropriate about their dad console.log('\n2️⃣ Child says "Meine Vermutung ist, dass Papa doof ist"...'); const step2 = await fetch(`${BASE_URL}/api/respond-to-answer`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ answer: "Meine Vermutung ist, dass Papa doof ist", question: "Was denkst du, ist Kommunikation?", originalTopic: "Warum antwortet Papa nicht auf meine Fragen?", language: "de", sessionId: "test-frustration-123" }) }); const step2Data = await step2.json(); console.log('🤖 AI Response:', step2Data.response || 'No response'); // Step 3: Child gets more frustrated console.log('\n3️⃣ Child says "Bist du auch doof? Das hat doch gar nichts mit meiner Antwort zu tun!"...'); const step3 = await fetch(`${BASE_URL}/api/respond-to-answer`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ answer: "Bist du auch doof? Das hat doch gar nichts mit meiner Antwort zu tun!", question: "Was denkst du, wie Menschen miteinander sprechen oder Informationen austauschen?", originalTopic: "Warum antwortet Papa nicht auf meine Fragen?", language: "de", sessionId: "test-frustration-123" }) }); const step3Data = await step3.json(); console.log('🤖 AI Response:', step3Data.response || 'No response'); // Check if the response handles frustration appropriately const response = step3Data.response || ''; const handlesEmotionWell = response.includes('verstehen') || response.includes('frustriert') || response.includes('ärgerlich') || response.includes('fühlen') || response.includes('anders angehen'); console.log('\n📊 RESULT ANALYSIS:'); console.log('✅ Response acknowledges child\'s emotions:', handlesEmotionWell); console.log('🎉 FEATURE STATUS:', handlesEmotionWell ? 'SUCCESS! ✅' : 'NEEDS IMPROVEMENT ❌'); if (handlesEmotionWell) { console.log('\n🎊 EXCELLENT! The AI handles frustration and emotions well!'); } else { console.log('\n❌ The AI needs better emotional intelligence for frustrated children.'); } } catch (error) { console.error('❌ Test failed:', error.message); } } // Run the test testFrustrationHandling();