35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Test script to verify notifications API
|
|
*/
|
|
|
|
async function testNotificationsAPI() {
|
|
try {
|
|
console.log("Testing notifications API...");
|
|
|
|
// Test unread count endpoint
|
|
const unreadResponse = await fetch('http://localhost:3001/api/notifications/unread-count');
|
|
if (unreadResponse.ok) {
|
|
const unreadData = await unreadResponse.json();
|
|
console.log("✅ Unread count:", unreadData.unreadCount);
|
|
} else {
|
|
console.log("❌ Unread count endpoint failed:", unreadResponse.status);
|
|
}
|
|
|
|
// Test notifications list endpoint
|
|
const notificationsResponse = await fetch('http://localhost:3001/api/notifications');
|
|
if (notificationsResponse.ok) {
|
|
const notificationsData = await notificationsResponse.json();
|
|
console.log("✅ Notifications fetched:", notificationsData.notifications.length);
|
|
console.log("Sample notification:", notificationsData.notifications[0]);
|
|
} else {
|
|
console.log("❌ Notifications endpoint failed:", notificationsResponse.status);
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error("Error testing API:", error);
|
|
}
|
|
}
|
|
|
|
testNotificationsAPI(); |