Fix jwt-token

This commit is contained in:
2025-09-15 15:37:33 +02:00
parent bfb4b05aed
commit caf7e878f7
3 changed files with 25 additions and 11 deletions

View File

@@ -85,11 +85,11 @@ module.exports = (sequelize) => {
},
created_at: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW
defaultValue: sequelize.Sequelize.NOW
},
updated_at: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW
defaultValue: sequelize.Sequelize.NOW
}
}, {
tableName: 'alert_logs',

View File

@@ -57,7 +57,7 @@ module.exports = (sequelize) => {
},
server_timestamp: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
defaultValue: sequelize.Sequelize.NOW,
comment: 'When the detection was received by server'
},
confidence_level: {
@@ -100,7 +100,7 @@ module.exports = (sequelize) => {
},
created_at: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW
defaultValue: sequelize.Sequelize.NOW
}
}, {
tableName: 'drone_detections',

View File

@@ -554,9 +554,16 @@ describe('Models', () => {
describe('Heartbeat Model', () => {
it('should create heartbeat with valid data', async () => {
const tenant = await createTestTenant();
const device = await models.Device.create({
id: 123,
name: 'Test Device',
tenant_id: tenant.id
});
const heartbeatData = {
key: 'device_123_key',
device_id: 123,
device_id: device.id,
signal_strength: -50,
battery_level: 85,
temperature: 22.5
@@ -566,18 +573,25 @@ describe('Models', () => {
expect(heartbeat.id).to.exist;
expect(heartbeat.key).to.equal('device_123_key');
expect(heartbeat.device_id).to.equal(123);
expect(heartbeat.device_id).to.equal(device.id);
expect(heartbeat.battery_level).to.equal(85);
});
it('should auto-set timestamp', async () => {
const heartbeat = await models.Heartbeat.create({
key: 'device_123_key',
device_id: 123
const tenant = await createTestTenant();
const device = await models.Device.create({
id: 124,
name: 'Test Device 2',
tenant_id: tenant.id
});
expect(heartbeat.timestamp).to.exist;
expect(heartbeat.timestamp).to.be.a('date');
const heartbeat = await models.Heartbeat.create({
key: 'device_124_key',
device_id: device.id
});
expect(heartbeat.created_at).to.exist;
expect(heartbeat.created_at).to.be.a('date');
});
it('should validate battery level range', async () => {