collabSupport/tests/ciscoMppPhone.statusJson.test.js
jmcqueen f7953b8eb5 Add MPP desk phone diagnostics follow-up to /phonestatus via relay.
Wire CP-78xx probe discovery, relay phone-probe commands, and a chat follow-up message so store desk phones get registration, switch, and provisioning detail alongside DECT and WAN diagnostics.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-28 18:01:01 -04:00

31 lines
1.3 KiB
JavaScript

// Parser tests for MPP Status.json (live store 782 fixture from HAR)
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { parseStatusJson, summarizePhoneHealthFromJson } from '../integrations/cisco-mpp-phone/statusJson.js';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const LIVE = fs.readFileSync(path.join(__dirname, 'fixtures/mpp/status-782-live.json'), 'utf8');
test('parseStatusJson: live 782 fixture extracts registration + product', () => {
const parsed = parseStatusJson(LIVE);
assert.equal(parsed.device.product, 'CP-7841-3PCC');
assert.equal(parsed.device.mac, 'cc:98:91:4f:67:99');
assert.match(parsed.device.firmware, /sip78xx/);
assert.equal(parsed.network.ipv4, '10.43.206.157');
assert.equal(parsed.lines[0].registrationState, 'Registered');
assert.equal(parsed.registration, 'Registered');
assert.ok(parsed.rebootHistory.length >= 1);
assert.ok(Object.keys(parsed.fields).length > 20);
});
test('summarizePhoneHealthFromJson: registered phone is healthy', () => {
const parsed = parseStatusJson(LIVE);
const verdict = summarizePhoneHealthFromJson(parsed);
assert.equal(verdict.healthy, true);
assert.equal(verdict.warnings.length, 0);
});