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>
81 lines
3.3 KiB
JavaScript
81 lines
3.3 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
import { fileURLToPath } from 'node:url';
|
|
import path from 'node:path';
|
|
|
|
import { parseStatusXml } from '../integrations/cisco-dect/statusXml.js';
|
|
import { inventoryStatusXml, summarizeInventory } from '../integrations/cisco-dect/statusXmlInventory.js';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const FIXTURE_DIR = path.join(__dirname, 'fixtures/dect');
|
|
|
|
const SYNTHETIC = readFileSync(path.join(FIXTURE_DIR, 'status-with-handsets.xml'), 'utf8');
|
|
const STORE933_PRIMARY = readFileSync(path.join(FIXTURE_DIR, 'status-933-f635de.xml'), 'utf8');
|
|
const STORE933_SECONDARY = readFileSync(path.join(FIXTURE_DIR, 'status-933-f63642.xml'), 'utf8');
|
|
|
|
test('parseStatusXml: synthetic fixture parses RSSI rows', () => {
|
|
const s = parseStatusXml(SYNTHETIC);
|
|
assert.equal(s.rssi.length, 2);
|
|
assert.equal(s.rssi[0].mac, '6c:ab:05:a1:b2:c3');
|
|
assert.equal(s.rssi[0].rssiDbm, -58);
|
|
});
|
|
|
|
test('parseStatusXml: store 933 primary parses RSSI_Line format', () => {
|
|
const s = parseStatusXml(STORE933_PRIMARY);
|
|
assert.equal(s.rssi.length, 1);
|
|
assert.equal(s.rssi[0].rpn, '4');
|
|
assert.equal(s.rssi[0].rssiDbm, -47);
|
|
});
|
|
|
|
test('parseStatusXml: store 933 primary parses device presence and handsets', () => {
|
|
const s = parseStatusXml(STORE933_PRIMARY);
|
|
assert.equal(s.devicePresence.length, 2);
|
|
assert.equal(s.devicePresence[0].extension, '1');
|
|
assert.equal(s.devicePresence[0].deviceType, '6825');
|
|
assert.equal(s.devices.length, 2);
|
|
assert.equal(s.devices[0].displayName, '1-50933');
|
|
assert.equal(s.devices[0].rssiDbm, -76);
|
|
assert.equal(s.devices[0].batteryPercent, 81);
|
|
assert.match(s.devices[1].lockedRpn || '', /RPN:04/);
|
|
});
|
|
|
|
test('parseStatusXml: store 933 primary parses SIP identity blocks', () => {
|
|
const s = parseStatusXml(STORE933_PRIMARY);
|
|
assert.equal(s.sipIdentityStatus.length, 2);
|
|
assert.equal(s.sipIdentityStatus[0].status, 'OK');
|
|
assert.match(s.sipIdentityStatus[1].status || '', /Registering/i);
|
|
});
|
|
|
|
test('parseStatusXml: store 933 parses Value_Line statistics with MAC', () => {
|
|
const s = parseStatusXml(STORE933_PRIMARY);
|
|
assert.ok(s.perRpnStats.length >= 2);
|
|
assert.equal(s.perRpnStats[0].mac, '6c:ab:05:f6:35:de');
|
|
assert.ok(s.perRpnStats[0].opSeconds > 0);
|
|
});
|
|
|
|
test('parseStatusXml: store 933 uptime includes days component', () => {
|
|
const s = parseStatusXml(STORE933_PRIMARY);
|
|
assert.ok(s.time.operatingTimeSeconds > 86400);
|
|
});
|
|
|
|
test('parseStatusXml: store 933 primary parses multi-cell role', () => {
|
|
const s = parseStatusXml(STORE933_PRIMARY);
|
|
assert.equal(s.multiCell.role, 'primary');
|
|
assert.equal(s.multiCell.state, 'ready');
|
|
});
|
|
|
|
test('parseStatusXml: store 933 secondary has RSSI but no registered handsets', () => {
|
|
const s = parseStatusXml(STORE933_SECONDARY);
|
|
assert.equal(s.rssi[0].rssiDbm, -49);
|
|
assert.equal(s.devices.length, 0);
|
|
assert.equal(s.multiCell.role, 'secondary');
|
|
assert.equal(s.multiCell.state, 'ready');
|
|
});
|
|
|
|
test('inventoryStatusXml: store 933 finds handset-related paths', () => {
|
|
const inv = inventoryStatusXml(STORE933_PRIMARY);
|
|
const summary = summarizeInventory(inv);
|
|
assert.ok(summary.handsetRelated > 0);
|
|
assert.ok(summary.paths.some((p) => /Device_Information/i.test(p)));
|
|
});
|