
const axios = require('axios');

async function testCrisis() {
    try {
        // 1. Login
        console.log('Logging in...');
        const loginRes = await axios.post('http://localhost:5001/api/auth/login', {
            email: 'admin@infoseclabs.io', 
            password: 'Konyali82@' 
        });
        const token = loginRes.data.token;
        console.log('Got Token:', token.substring(0, 20) + '...');

        // 2. Start Crisis
        console.log('Starting Crisis...');
        const crisisRes = await axios.post('http://localhost:5001/api/mobile/crisis/start', {}, {
            headers: { Authorization: `Bearer ${token}` }
        });
        
        console.log('Crisis Started Successfully!');
        console.log('Operation:', crisisRes.data.operation.title);
        console.log('Alerts Count:', crisisRes.data.alerts.length);
        console.log('First Alert:', crisisRes.data.alerts[0].title);

    } catch (error) {
        console.error('Test Failed:', error.response ? error.response.data : error.message);
    }
}

testCrisis();
