Files
Atlas/test-ki-features.js
2025-11-12 20:21:32 +01:00

101 lines
3.7 KiB
JavaScript
Raw 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.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const fetch = require('node-fetch');
async function testKIFeatures() {
const baseUrl = 'http://localhost:3002';
console.log('🧪 Test Suite: KI-Features & API-Endpunkte\n');
console.log('='.repeat(60));
// Test 1: Server erreichbar?
console.log('\n1⃣ Server-Status prüfen...');
try {
const response = await fetch(baseUrl);
console.log(` ✅ Server erreichbar (Status: ${response.status})`);
} catch (error) {
console.log(` ❌ Server nicht erreichbar: ${error.message}`);
return;
}
// Test 2: API Health Check
console.log('\n2⃣ API Health Check...');
try {
const response = await fetch(`${baseUrl}/api/health`);
if (response.status === 404) {
console.log(' ⚠️ Health-Endpunkt nicht implementiert (erwartet)');
} else {
const data = await response.json();
console.log(` ✅ Health Check: ${JSON.stringify(data)}`);
}
} catch (error) {
console.log(` ⚠️ Health Check übersprungen: ${error.message}`);
}
// Test 3: Environment Variables
console.log('\n3⃣ Environment Variables Check...');
const envVars = [
'OPENAI_API_KEY',
'LEXOFFICE_API_KEY',
'GOOGLE_MAPS_API_KEY',
'DATABASE_URL',
'NEXTAUTH_SECRET'
];
// Wir können die Env-Variablen nicht direkt testen, aber wir können
// prüfen, ob die Services initialisiert werden können
console.log(' Env-Variablen werden vom Server geladen');
console.log(' Direkte Prüfung nicht möglich (Server-Kontext)');
// Test 4: Wichtige API-Endpunkte dokumentieren
console.log('\n4⃣ Implementierte API-Endpunkte:');
const endpoints = [
{ method: 'POST', path: '/api/bookings/[id]/ai-analyze', desc: 'KI-E-Mail-Analyse' },
{ method: 'POST', path: '/api/bookings/[id]/release-to-drivers', desc: 'Freigabe an Fahrer' },
{ method: 'GET', path: '/api/bookings/[id]/availability', desc: 'Fahrer-Verfügbarkeiten abrufen' },
{ method: 'POST', path: '/api/bookings/[id]/availability', desc: 'Fahrer-Verfügbarkeit melden' },
{ method: 'POST', path: '/api/bookings/[id]/assign-driver', desc: 'Fahrer zuweisen' },
{ method: 'GET', path: '/api/cron/check-contracts', desc: 'Vertragsprüfung Cron-Job' },
{ method: 'POST', path: '/api/tours/[id]/optimize-route', desc: 'Routenoptimierung' },
];
endpoints.forEach((ep, i) => {
console.log(` ${i + 1}. ${ep.method.padEnd(6)} ${ep.path}`);
console.log(`${ep.desc}`);
});
// Test 5: File-System-Check
console.log('\n5⃣ Kritische Dateien prüfen...');
const fs = require('fs');
const path = require('path');
const criticalFiles = [
'lib/ai-service.ts',
'lib/lexoffice.ts',
'lib/route-optimization.ts',
'prisma/schema.prisma',
'.env'
];
criticalFiles.forEach(file => {
const filePath = path.join(__dirname, file);
const exists = fs.existsSync(filePath);
console.log(` ${exists ? '✅' : '❌'} ${file}`);
});
console.log('\n' + '='.repeat(60));
console.log('✅ Test Suite abgeschlossen!\n');
console.log('📋 Nächste Schritte:');
console.log(' 1. Dashboard öffnen: http://localhost:3002/dashboard');
console.log(' 2. Testbuchung erstellen über UI');
console.log(' 3. KI-Analyse-Button testen (Admin-Dashboard)');
console.log(' 4. LexOffice-Integration testen (API-Keys prüfen)');
console.log(' 5. Routenoptimierung mit echten Adressen testen\n');
console.log('⚠️ WICHTIGE ERINNERUNG:');
console.log(' 🔐 Google Maps API Key einschränken bei Live-Gang!');
console.log(' → https://console.cloud.google.com/apis/credentials');
console.log(' → IP/Domain-Einschränkung + nur 3 APIs aktivieren\n');
}
testKIFeatures().catch(console.error);