diff --git a/server/tests/integration/workflows.test.js b/server/tests/integration/workflows.test.js index 0730fad..e0b6cc3 100644 --- a/server/tests/integration/workflows.test.js +++ b/server/tests/integration/workflows.test.js @@ -277,7 +277,10 @@ describe('Integration Tests', () => { const mockIo = { emit: sinon.stub(), emitToDashboard: sinon.stub(), - emitToDevice: sinon.stub() + emitToDevice: sinon.stub(), + to: (room) => ({ + emit: sinon.stub() + }) }; // Simulate drone approach with multiple detections diff --git a/server/tests/routes/detectors.test.js b/server/tests/routes/detectors.test.js index 4290b38..1746a5a 100644 --- a/server/tests/routes/detectors.test.js +++ b/server/tests/routes/detectors.test.js @@ -27,7 +27,10 @@ describe('Detectors Routes', () => { req.io = { emit: () => {}, // Mock emit function that does nothing emitToDashboard: () => {}, - emitToDevice: () => {} + emitToDevice: () => {}, + to: (room) => ({ + emit: () => {} // Mock room-based emit for tenant isolation + }) }; next(); }); diff --git a/server/tests/services/alertService.test.js b/server/tests/services/alertService.test.js index 1c7cb49..84b9f41 100644 --- a/server/tests/services/alertService.test.js +++ b/server/tests/services/alertService.test.js @@ -448,7 +448,10 @@ describe('AlertService', () => { const mockIo = { emit: sinon.stub(), emitToDashboard: sinon.stub(), - emitToDevice: sinon.stub() + emitToDevice: sinon.stub(), + to: (room) => ({ + emit: sinon.stub() + }) }; const result = await alertService.processDetectionAlert(detection, mockIo); @@ -469,7 +472,10 @@ describe('AlertService', () => { const mockIo = { emit: sinon.stub(), emitToDashboard: sinon.stub(), - emitToDevice: sinon.stub() + emitToDevice: sinon.stub(), + to: (room) => ({ + emit: sinon.stub() + }) }; await alertService.processDetectionAlert(detection, mockIo); @@ -500,7 +506,11 @@ describe('AlertService', () => { rssi: -45 }); - const mockIo = { emitToDashboard: sinon.stub(), emitToDevice: sinon.stub() }; + const mockIo = { + emitToDashboard: sinon.stub(), + emitToDevice: sinon.stub(), + to: (room) => ({ emit: sinon.stub() }) + }; await alertService.processDetectionAlert(detection1, mockIo); await alertService.processDetectionAlert(detection2, mockIo); @@ -520,7 +530,11 @@ describe('AlertService', () => { threatLevel: 'high' }); - const mockIo = { emitToDashboard: sinon.stub(), emitToDevice: sinon.stub() }; + const mockIo = { + emitToDashboard: sinon.stub(), + emitToDevice: sinon.stub(), + to: (room) => ({ emit: sinon.stub() }) + }; // Simulate clearing old alerts await alertService.clearExpiredAlerts(mockIo);