![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/scripts/ |
const fetch = require('node-fetch');
async function testChatAPI() {
console.log('๐งช Testing Chat API Endpoints...\n');
const baseUrl = 'http://localhost:3000';
try {
// Test 1: Chat rooms endpoint (should return 401 without auth)
console.log('1. Testing GET /api/chat/rooms (should return 401 without auth)...');
const roomsResponse = await fetch(`${baseUrl}/api/chat/rooms`);
console.log(`Status: ${roomsResponse.status}`);
if (roomsResponse.status === 401) {
console.log('โ
Correctly returns 401 Unauthorized without authentication');
} else {
console.log('โ Unexpected response:', roomsResponse.status);
}
// Test 2: Group messages endpoint (should return 401 without auth)
console.log('\n2. Testing GET /api/chat/group/messages (should return 401 without auth)...');
const messagesResponse = await fetch(`${baseUrl}/api/chat/group/messages?chatRoomId=test`);
console.log(`Status: ${messagesResponse.status}`);
if (messagesResponse.status === 401) {
console.log('โ
Correctly returns 401 Unauthorized without authentication');
} else {
console.log('โ Unexpected response:', messagesResponse.status);
}
// Test 3: Check if server is running
console.log('\n3. Testing server availability...');
const healthResponse = await fetch(`${baseUrl}/`);
console.log(`Status: ${healthResponse.status}`);
if (healthResponse.status === 200) {
console.log('โ
Server is running and responding');
} else {
console.log('โ Server not responding properly');
}
console.log('\n๐ Chat API tests completed!');
console.log('\n๐ To test with authentication:');
console.log(' 1. Open browser: http://localhost:3000');
console.log(' 2. Login with: admin@example.com / password123');
console.log(' 3. Navigate to: /group-chat');
console.log(' 4. Test sending messages and creating rooms');
} catch (error) {
console.error('โ Error testing chat API:', error.message);
console.log('\n๐ก Make sure the server is running with: npm run dev');
}
}
testChatAPI();