#!/usr/bin/env node /** * Test script to verify notifications are working */ async function testNotifications() { try { console.log("Testing notifications system..."); // Test unread count endpoint (this should work without auth for now) console.log("1. Testing unread count endpoint..."); const unreadResponse = await fetch('http://localhost:3001/api/notifications/unread-count'); if (unreadResponse.status === 401) { console.log("✅ Unread count endpoint requires auth (expected)"); } else if (unreadResponse.ok) { const data = await unreadResponse.json(); console.log("✅ Unread count:", data.unreadCount); } else { console.log("❌ Unread count endpoint failed:", unreadResponse.status); } // Test notifications endpoint console.log("2. Testing notifications endpoint..."); const notificationsResponse = await fetch('http://localhost:3001/api/notifications'); if (notificationsResponse.status === 401) { console.log("✅ Notifications endpoint requires auth (expected)"); } else if (notificationsResponse.ok) { const data = await notificationsResponse.json(); console.log("✅ Notifications fetched:", data.notifications?.length || 0); } else { console.log("❌ Notifications endpoint failed:", notificationsResponse.status); } console.log("\n🎉 Notification system test completed!"); console.log("Note: API endpoints require authentication, so 401 responses are expected."); console.log("Test the UI by logging into the application and checking the notification dropdown."); } catch (error) { console.error("❌ Error testing notifications:", error); } } testNotifications();