Groups cdr_feed legs by Correlation ID for call-level summaries, fixes report-column field parsing and Docker proxy routing, and adds /calltest post-call Twilio and CDR enrichment. Co-authored-by: Cursor <cursoragent@cursor.com>
70 lines
2.1 KiB
JavaScript
70 lines
2.1 KiB
JavaScript
// tests/voiceReport.renderer.test.js
|
|
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { renderVoiceReportMarkdown } from '../services/renderers/voiceReportRenderer.js';
|
|
|
|
test('renderVoiceReportMarkdown summary', () => {
|
|
const md = renderVoiceReportMarkdown({
|
|
ok: true,
|
|
store: { storeNum: '782', locationName: 'Store 0782', dialNumber: '+17247795574' },
|
|
window: {
|
|
label: '2026-07-23',
|
|
mode: 'fullDay',
|
|
timeZone: 'America/New_York',
|
|
startTime: '2026-07-23T13:00:00.000Z',
|
|
endTime: '2026-07-24T01:00:00.000Z',
|
|
},
|
|
cdr: { available: true, rawCount: 10 },
|
|
mediaQuality: { available: false, reason: 'skipped in test' },
|
|
prisma: { available: false, reason: 'not configured' },
|
|
joined: {
|
|
summary: {
|
|
total: 5,
|
|
inbound: 3,
|
|
outbound: 2,
|
|
inboundReachedPhone: 2,
|
|
outboundConnected: 2,
|
|
abnormal: 1,
|
|
outcomes: { 'Success / Normal': 4, 'Failed / Busy': 1 },
|
|
},
|
|
calls: [],
|
|
},
|
|
elapsedMs: 42,
|
|
});
|
|
assert.match(md, /Voice report/);
|
|
assert.match(md, /Store 0782/);
|
|
assert.match(md, /Total calls.*5/);
|
|
assert.match(md, /Inbound reached a phone/);
|
|
});
|
|
|
|
test('renderVoiceReportMarkdown detail truncates', () => {
|
|
const calls = Array.from({ length: 30 }, (_, i) => ({
|
|
start: `2026-07-23T14:${String(i).padStart(2, '0')}:00.000Z`,
|
|
direction: 'inbound',
|
|
duration: 30,
|
|
outcome: 'Success',
|
|
outcomeReason: 'Normal',
|
|
callingNumber: '+1',
|
|
calledNumber: '+2',
|
|
legCount: 2,
|
|
reachedPhone: true,
|
|
normalOutcome: true,
|
|
}));
|
|
const md = renderVoiceReportMarkdown({
|
|
ok: true,
|
|
store: { storeNum: '782', locationName: 'Store 0782' },
|
|
window: { label: '2026-07-23', mode: 'fullDay', timeZone: 'America/New_York', startTime: 'x', endTime: 'y' },
|
|
cdr: { available: true },
|
|
mediaQuality: { available: false },
|
|
prisma: { available: false },
|
|
joined: {
|
|
summary: { total: 30, inbound: 30, outbound: 0, outcomes: {} },
|
|
calls,
|
|
},
|
|
elapsedMs: 1,
|
|
}, { detail: true });
|
|
assert.match(md, /Call detail/);
|
|
assert.match(md, /more calls/);
|
|
});
|