collabSupport/tests/voiceDiag.relay.test.js
jmcqueen 7dc326c404 Split voice commands into status vs diag and redesign MPP phone output.
Replace /phonestatus follow-ups with /voicestatus, /wanstatus, /phonediag, and /dectdiag; extend /voicediag with relay probes and section-based MPP diagnostics.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 13:55:41 -04:00

68 lines
2.5 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { mppDeskPhoneRelayCheck } from '../services/voiceDiag/checks/mppDeskPhoneRelay.js';
import { dectBaseRelayCheck } from '../services/voiceDiag/checks/dectBaseRelay.js';
const origToken = process.env.DECT_RELAY_AGENT_TOKEN;
test('mppDeskPhoneRelayCheck: skipped when relay token unset', async () => {
delete process.env.DECT_RELAY_AGENT_TOKEN;
const result = await mppDeskPhoneRelayCheck.run({ phoneStatus: {} });
assert.equal(result.status, 'skipped');
assert.match(result.message, /Relay not configured/i);
});
test('mppDeskPhoneRelayCheck: error when phone has registration issues', async () => {
process.env.DECT_RELAY_AGENT_TOKEN = 'test-token';
const result = await mppDeskPhoneRelayCheck.run({
phoneStatus: {},
mppRelayResults: [{
ok: true,
phone: { name: 'Store CP-7841', ip: '10.1.1.1' },
mpp: {
parsed: {
lines: [{ index: 1, registrationState: 'Not Registered' }],
},
},
}],
});
assert.equal(result.status, 'error');
assert.match(result.message, /need attention/i);
if (origToken === undefined) delete process.env.DECT_RELAY_AGENT_TOKEN;
else process.env.DECT_RELAY_AGENT_TOKEN = origToken;
});
test('dectBaseRelayCheck: ok when all bases healthy', async () => {
process.env.DECT_RELAY_AGENT_TOKEN = 'test-token';
const result = await dectBaseRelayCheck.run({
phoneStatus: {},
dectRelayResults: [{
ok: true,
base: { name: 'Base A', ip: '10.2.2.2' },
data: { time: { operatingTime: '1d' }, rebootLog: [], rtp: { current: 0 } },
verdict: { healthy: true, warnings: [] },
}],
});
assert.equal(result.status, 'ok');
assert.match(result.message, /All bases healthy/i);
if (origToken === undefined) delete process.env.DECT_RELAY_AGENT_TOKEN;
else process.env.DECT_RELAY_AGENT_TOKEN = origToken;
});
test('dectBaseRelayCheck: error when base unhealthy', async () => {
process.env.DECT_RELAY_AGENT_TOKEN = 'test-token';
const result = await dectBaseRelayCheck.run({
phoneStatus: {},
dectRelayResults: [{
ok: true,
base: { name: 'Base A', ip: '10.2.2.2' },
data: { time: { operatingTime: '1d' }, rebootLog: [], rtp: { current: 0 } },
verdict: { healthy: false, warnings: ['Rx errors'] },
}],
});
assert.equal(result.status, 'error');
assert.match(result.message, /need attention/i);
if (origToken === undefined) delete process.env.DECT_RELAY_AGENT_TOKEN;
else process.env.DECT_RELAY_AGENT_TOKEN = origToken;
});