Fix jwt-token
This commit is contained in:
@@ -139,7 +139,7 @@ describe('Detections Routes', () => {
|
||||
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.body.data.detections).to.have.length(1);
|
||||
expect(response.body.data.detections[0].device_id).to.equal(device1.id);
|
||||
expect(response.body.data.detections[0].device_id).to.equal(String(device1.id));
|
||||
});
|
||||
|
||||
it('should support filtering by drone type', async () => {
|
||||
|
||||
@@ -65,7 +65,7 @@ describe('Device Routes', () => {
|
||||
expect(response.body.data).to.have.length(2);
|
||||
|
||||
const deviceIds = response.body.data.map(d => d.id);
|
||||
expect(deviceIds).to.include.members([123, 124]);
|
||||
expect(deviceIds).to.include.members(['123', '124']);
|
||||
});
|
||||
|
||||
it('should only return devices for user tenant', async () => {
|
||||
@@ -85,7 +85,7 @@ describe('Device Routes', () => {
|
||||
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.body.data).to.have.length(1);
|
||||
expect(response.body.data[0].id).to.equal(111);
|
||||
expect(response.body.data[0].id).to.equal('111');
|
||||
});
|
||||
|
||||
it('should require authentication', async () => {
|
||||
@@ -155,7 +155,7 @@ describe('Device Routes', () => {
|
||||
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.body.success).to.be.true;
|
||||
expect(response.body.data.id).to.equal(12345);
|
||||
expect(response.body.data.id).to.equal('12345');
|
||||
expect(response.body.data.name).to.equal('Specific Device');
|
||||
expect(response.body.data.location_description).to.equal('Test Location');
|
||||
});
|
||||
@@ -570,18 +570,20 @@ describe('Device Routes', () => {
|
||||
});
|
||||
|
||||
const response = await request(app)
|
||||
.get('/devices')
|
||||
.get('/devices?include_stats=true')
|
||||
.set('Authorization', `Bearer ${token}`);
|
||||
|
||||
expect(response.status).to.equal(200);
|
||||
const devices = response.body.data;
|
||||
|
||||
const online = devices.find(d => d.id === onlineDevice.id);
|
||||
const offline = devices.find(d => d.id === offlineDevice.id);
|
||||
const online = devices.find(d => d.id === String(onlineDevice.id));
|
||||
const offline = devices.find(d => d.id === String(offlineDevice.id));
|
||||
|
||||
// These assertions depend on your business logic for determining online status
|
||||
expect(online).to.exist;
|
||||
expect(online.stats).to.exist;
|
||||
expect(offline).to.exist;
|
||||
expect(offline.stats).to.exist;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -244,7 +244,7 @@ describe('Healthcheck Routes', () => {
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.body.devices).to.be.an('array');
|
||||
|
||||
const deviceStatus = response.body.devices.find(d => d.id === device.id);
|
||||
const deviceStatus = response.body.devices.find(d => d.id === String(device.id));
|
||||
expect(deviceStatus).to.exist;
|
||||
expect(deviceStatus.status).to.equal('online');
|
||||
expect(deviceStatus.metrics).to.exist;
|
||||
@@ -288,8 +288,8 @@ describe('Healthcheck Routes', () => {
|
||||
.set('Authorization', `Bearer ${token}`);
|
||||
|
||||
expect(response.status).to.equal(200);
|
||||
const deviceStatus = response.body.devices.find(d => d.id === device.id);
|
||||
expect(deviceStatus.uptime_hours).to.be.a('number');
|
||||
const deviceStatus = response.body.devices.find(d => d.id === String(device.id));
|
||||
expect(deviceStatus.uptime).to.be.a('number');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -504,9 +504,9 @@ describe('Healthcheck Routes', () => {
|
||||
const token = generateTestToken(admin, tenant);
|
||||
|
||||
// Generate some database activity
|
||||
await createTestDevice({ tenant_id: tenant.id });
|
||||
const device = await createTestDevice({ tenant_id: tenant.id });
|
||||
await models.DroneDetection.create({
|
||||
device_id: 123,
|
||||
device_id: device.id,
|
||||
tenant_id: tenant.id,
|
||||
geo_lat: 59.3293,
|
||||
geo_lon: 18.0686,
|
||||
@@ -566,7 +566,7 @@ describe('Healthcheck Routes', () => {
|
||||
.set('Authorization', `Bearer ${token}`);
|
||||
|
||||
expect(response.status).to.equal(200);
|
||||
const deviceStatus = response.body.devices.find(d => d.id === device.id);
|
||||
const deviceStatus = response.body.devices.find(d => d.id === String(device.id));
|
||||
expect(deviceStatus.status).to.be.oneOf(['offline', 'stale', 'unknown']);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user