// Test script to verify humorous answers handling const fetch = require('node-fetch'); const BASE_URL = 'http://localhost:3002'; async function testHumorousAnswers() { console.log('🧪 Testing KidsAI humorous answers handling...\n'); try { // Step 1: Start conversation about hormones console.log('1️⃣ Starting conversation about hormones...'); const step1 = await fetch(`${BASE_URL}/api/ask`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ question: "Warum wächst Männern ein Bart?", language: "de" }) }); const step1Data = await step1.json(); console.log('🤖 AI Response:', step1Data.guidance?.steps?.[0]?.text || 'No response'); // Step 2: Child gives humorous answer "per fax" console.log('\n2️⃣ Child gives humorous answer "per fax"...'); const step2 = await fetch(`${BASE_URL}/api/respond-to-answer`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ answer: "per fax", question: "Weißt du, was Hormone sind und wie sie in unserem Körper wirken?", originalTopic: "Warum wächst Männern ein Bart?", language: "de", sessionId: "test-humor-123" }) }); const step2Data = await step2.json(); console.log('🤖 AI Response:', step2Data.response || 'No response'); // Check if the response acknowledges creativity const response = step2Data.response || ''; const isAppropriate = response.includes('kreativ') || response.includes('witzig') || response.includes('Humor') || response.includes('lächeln') || response.includes('lustig'); console.log('\n📊 RESULT ANALYSIS:'); console.log('✅ Response acknowledges humor/creativity:', isAppropriate); console.log('🎉 FEATURE STATUS:', isAppropriate ? 'SUCCESS! ✅' : 'NEEDS IMPROVEMENT ❌'); if (isAppropriate) { console.log('\n🎊 EXCELLENT! The AI now acknowledges humorous or creative answers!'); } else { console.log('\n❌ The feature needs improvement. AI should acknowledge the child\'s creativity.'); } } catch (error) { console.error('❌ Test failed:', error.message); } } // Run the test testHumorousAnswers();