diff --git a/server/routes/detections.js b/server/routes/detections.js index e543818..275c382 100644 --- a/server/routes/detections.js +++ b/server/routes/detections.js @@ -19,6 +19,11 @@ router.get('/', authenticateToken, async (req, res) => { // Get tenant from authenticated user context const tenantId = req.tenantId; console.log('🔍 Detections - Tenant ID from request:', tenantId); + + // Debug: Check what tenants exist + const allTenants = await Tenant.findAll({ attributes: ['id', 'slug'] }); + console.log('🔍 Detections - All tenants in database:', allTenants.map(t => ({ id: t.id, slug: t.slug }))); + if (!tenantId) { return res.status(400).json({ success: false, diff --git a/server/tests/routes/detections.test.js b/server/tests/routes/detections.test.js index 6e8291c..bbe4d51 100644 --- a/server/tests/routes/detections.test.js +++ b/server/tests/routes/detections.test.js @@ -37,6 +37,7 @@ describe('Detections Routes', () => { describe('GET /detections', () => { it('should return detections for user tenant', async () => { const tenant = await createTestTenant({ slug: 'test-tenant' }); + console.log('🔍 Test - Created tenant:', { id: tenant.id, slug: tenant.slug }); const user = await createTestUser({ tenant_id: tenant.id }); const device = await createTestDevice({ tenant_id: tenant.id }); const detection = await createTestDetection({ device_id: device.id });