const axios = require('axios');

async function test() {
  console.log('Sending login requests to running server...');
  
  // 1. Principal login
  try {
    console.log('\n1. Testing principal login...');
    const res = await axios.post('http://127.0.0.1:3001/api/auth/login', {
      email: 'principal@school.com',
      password: 'principal123'
    });
    console.log('Response status:', res.status);
    console.log('User role:', res.data.user?.role);
  } catch (err) {
    console.log('Principal failed. Response status:', err.response?.status);
    console.log('Response data:', err.response?.data);
  }

  // 2. Bursar login
  try {
    console.log('\n2. Testing bursar login...');
    const res = await axios.post('http://127.0.0.1:3001/api/auth/login', {
      email: 'bursar@school.com',
      password: 'bursar123'
    });
    console.log('Response status:', res.status);
    console.log('User role:', res.data.user?.role);
  } catch (err) {
    console.log('Bursar failed. Response status:', err.response?.status);
    console.log('Response data:', err.response?.data);
  }
}

test();
