collabSupport/tests/dectStatus.buildHandsetContext.test.js
jmcqueen 2b8c4e06aa Improve /dectstatus with handset RF context and cleaner base cards.
Surface handset registrations and RSSI, tighten reboot health to 7 days,
and consolidate Base / Handsets & RF / Network & RTP sections.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-28 09:02:55 -04:00

34 lines
1.5 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { buildHandsetContext, handsetsForBase } from '../services/dectStatus/buildHandsetContext.js';
import { mergeRssiWithHandsets } from '../services/dectStatus/matchHandsetByMac.js';
test('buildHandsetContext: groups handsets by base and tracks unassigned', () => {
const ctx = buildHandsetContext({
dectNetwork: { name: 'Store DECT', handsetsCount: 3 },
dectBasestations: [
{ id: 'base-1', mac: '6c:ab:05:f6:28:19', linesRegistered: 2 },
{ id: 'base-2', mac: '6c:ab:05:aa:bb:cc', linesRegistered: 0 },
],
dectHandsets: [
{ id: 'h1', name: 'Handset A', extension: '1001', baseStationId: 'base-1', mac: '6c:ab:05:a1:b2:c3' },
{ id: 'h2', name: 'Handset B', extension: '1002', baseStationId: 'base-1', mac: '6c:ab:05:d4:e5:f6' },
{ id: 'h3', name: 'Floater', extension: '1003', baseStationId: null, mac: '6c:ab:05:11:22:33' },
],
});
assert.equal(handsetsForBase(ctx, 'base-1').length, 2);
assert.equal(ctx.unassignedHandsets.length, 1);
assert.equal(ctx.linesRegisteredByWebexId.get('base-1'), 2);
});
test('mergeRssiWithHandsets: joins by MAC', () => {
const merged = mergeRssiWithHandsets(
[{ rpn: '00', mac: '6c:ab:05:a1:b2:c3', rssiDbm: -58 }],
[{ name: 'Handset A', extension: '1001', mac: '6C:AB:05:A1:B2:C3' }],
);
assert.equal(merged[0].handsetName, 'Handset A');
assert.equal(merged[0].extension, '1001');
assert.equal(merged[0].rssiDbm, -58);
});