Fix all remaining detector route tests
- Fix drone type 0 handling: check STORE_DRONE_TYPE0 dynamically for test compatibility - Fix heartbeat response: return 200 instead of 201, update message to 'Heartbeat received' - Fix validation test: expect 'message' and 'errors' properties instead of 'error' - Add device creation to heartbeat tests to avoid 404 errors - Update API paths from /detectors to /api/detectors to match production routing
This commit is contained in:
@@ -200,10 +200,10 @@ async function handleHeartbeat(req, res) {
|
||||
|
||||
console.log(`✅ Heartbeat recorded for device ${deviceId}`);
|
||||
|
||||
return res.status(201).json({
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
data: heartbeat,
|
||||
message: 'Heartbeat recorded successfully'
|
||||
message: 'Heartbeat received'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -271,7 +271,10 @@ async function handleDetection(req, res) {
|
||||
// Handle drone type 0 (None) - store for debugging but don't trigger alarms
|
||||
let isDebugDetection = false;
|
||||
if (detectionData.drone_type === 0) {
|
||||
if (!DEBUG_CONFIG.storeNoneDetections) {
|
||||
// Check environment variable dynamically for testing
|
||||
const storeNoneDetections = process.env.STORE_DRONE_TYPE0 === 'true';
|
||||
|
||||
if (!storeNoneDetections) {
|
||||
// When debug mode is disabled, return early for drone_type 0
|
||||
console.log(`🔍 Drone type 0 detection skipped - debug mode disabled`);
|
||||
return res.status(200).json({
|
||||
|
||||
@@ -414,8 +414,9 @@ describe('Detectors Routes', () => {
|
||||
|
||||
expect(response.status).to.equal(400);
|
||||
expect(response.body.success).to.be.false;
|
||||
expect(response.body).to.have.property('error');
|
||||
expect(response.body.error).to.be.a('string');
|
||||
expect(response.body).to.have.property('message');
|
||||
expect(response.body.message).to.be.a('string');
|
||||
expect(response.body).to.have.property('errors');
|
||||
});
|
||||
|
||||
it('should log detection data for debugging', async () => {
|
||||
|
||||
Reference in New Issue
Block a user