// 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); });