test(dashboard): expect inspector activity and act follow-up metrics
This commit is contained in:
@@ -2,22 +2,22 @@ import { strict as assert } from 'node:assert';
|
|||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
import { DashboardService } from '../../src/dashboard/dashboard.service';
|
import { DashboardService } from '../../src/dashboard/dashboard.service';
|
||||||
|
|
||||||
test('DashboardService returns F4 operational counts and recent activity consistently', async () => {
|
test('DashboardService returns F5 operational counts and inspector activity consistently', async () => {
|
||||||
const recent = [{
|
const recent = [{
|
||||||
id: 'event-id',
|
id: 'event-id',
|
||||||
occurredAt: new Date('2026-08-13T12:00:00.000Z'),
|
occurredAt: new Date('2026-09-08T12:00:00.000Z'),
|
||||||
actorUsername: 'admin',
|
actorUsername: 'inspector1',
|
||||||
action: 'AUTH_LOGIN_SUCCESS',
|
action: 'INSPECTION_STARTED',
|
||||||
entityType: 'auth_session',
|
entityType: 'inspection_visit',
|
||||||
entityId: 'session-id',
|
entityId: 'visit-id',
|
||||||
}];
|
}];
|
||||||
const manager = {
|
const manager = {
|
||||||
query: async (sql: string) => {
|
query: async (sql: string) => {
|
||||||
if (sql.includes('COUNT(*) FROM users')) {
|
if (sql.includes('COUNT(*) FROM users')) {
|
||||||
return [{
|
return [{
|
||||||
activeUsers: '4', inactiveUsers: '2', activeSessions: '3',
|
activeUsers: '4', inactiveUsers: '2', activeSessions: '3',
|
||||||
totalAssets: '12', assetsNeedValidation: '4', assetsWithoutGeometry: '6', plannedInspections: '2',
|
totalAssets: '0', assetsNeedValidation: '0', assetsWithoutGeometry: '0', plannedInspections: '2',
|
||||||
openFindings: '8', findingsWithoutControlDate: '5', overdueControls: '2', controlsNext30Days: '3',
|
openFindings: '8', actsInFollowUp: '6', findingsWithoutControlDate: '5', overdueControls: '2', controlsNext30Days: '3',
|
||||||
reportsWorking: '1', reportsOfficialized: '2', sealedActsWithoutReport: '4',
|
reportsWorking: '1', reportsOfficialized: '2', sealedActsWithoutReport: '4',
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@@ -31,14 +31,15 @@ test('DashboardService returns F4 operational counts and recent activity consist
|
|||||||
|
|
||||||
const result = await new DashboardService(dataSource as never).summary();
|
const result = await new DashboardService(dataSource as never).summary();
|
||||||
assert.deepEqual(result.counts, {
|
assert.deepEqual(result.counts, {
|
||||||
totalAssets: 12,
|
totalAssets: 0,
|
||||||
assetsNeedValidation: 4,
|
assetsNeedValidation: 0,
|
||||||
assetsWithoutGeometry: 6,
|
assetsWithoutGeometry: 0,
|
||||||
plannedInspections: 2,
|
plannedInspections: 2,
|
||||||
activeUsers: 4,
|
activeUsers: 4,
|
||||||
inactiveUsers: 2,
|
inactiveUsers: 2,
|
||||||
activeSessions: 3,
|
activeSessions: 3,
|
||||||
openFindings: 8,
|
openFindings: 8,
|
||||||
|
actsInFollowUp: 6,
|
||||||
findingsWithoutControlDate: 5,
|
findingsWithoutControlDate: 5,
|
||||||
overdueControls: 2,
|
overdueControls: 2,
|
||||||
controlsNext30Days: 3,
|
controlsNext30Days: 3,
|
||||||
@@ -46,7 +47,8 @@ test('DashboardService returns F4 operational counts and recent activity consist
|
|||||||
reportsOfficialized: 2,
|
reportsOfficialized: 2,
|
||||||
sealedActsWithoutReport: 4,
|
sealedActsWithoutReport: 4,
|
||||||
});
|
});
|
||||||
assert.equal(result.recentAudit, recent);
|
assert.deepEqual(result.recentInspectorActivity, recent);
|
||||||
|
assert.equal('recentAudit' in result, false);
|
||||||
assert.deepEqual(result.upcomingControls, []);
|
assert.deepEqual(result.upcomingControls, []);
|
||||||
assert.equal(typeof result.generatedAt, 'string');
|
assert.equal(typeof result.generatedAt, 'string');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user