collabSupport/tests/callReport.collapseDisplayCalls.test.js
jmcqueen a25fc08fe2 Rename /voicereport to /callreport with scoped user and phone targets.
Add store/email/phone filtering, richer call-line formatting, CDR feed pagination and queueing, and split Jira poller enrichment into testable modules.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 10:10:03 -04:00

61 lines
2.1 KiB
JavaScript

// tests/callReport.collapseDisplayCalls.test.js
import test from 'node:test';
import assert from 'node:assert/strict';
import { collapseAaBursts } from '../services/callReport/collapseDisplayCalls.js';
import { formatCallBlock } from '../services/callReport/formatCallLine.js';
test('collapseAaBursts groups 3+ same-caller AA calls', () => {
const mk = (i) => ({
start: `2026-07-23T14:${String(10 + i).padStart(2, '0')}:00.000Z`,
callingLineId: 'CLASE AVA',
callingNumber: '+17188408304',
storeMainNumber: '+12122194600',
calledNumber: '+12122194600',
aaKeyPress: '1',
reachedAttendant: true,
reachedPhone: false,
direction: 'inbound',
duration: 12,
disposition: 'Success',
});
const collapsed = collapseAaBursts([mk(0), mk(1), mk(2), mk(3)], { timeZone: 'America/New_York' });
assert.equal(collapsed.length, 1);
assert.equal(collapsed[0].kind, 'burst');
assert.match(collapsed[0].summary, /4 calls stopped at auto-attendant/);
});
test('formatCallBlock outbound short dial shows dialed', () => {
const call = {
direction: 'outbound',
start: '2026-07-23T16:27:00.000Z',
duration: 22,
endpointUser: 'Store 02477',
leftParty: { user: 'Store 02477', number: '52477' },
calledNumber: '7',
disposition: 'Refusal / UnassignedNumber',
abnormal: true,
normalOutcome: false,
};
const { line1 } = formatCallBlock(call, { timeZone: 'America/New_York', includeWan: false });
assert.match(line1, /→ dialed 7/);
});
test('formatCallBlock outbound connected shows device model', () => {
const call = {
direction: 'outbound',
start: '2026-07-24T14:17:00.000Z',
duration: 312,
endpointUser: 'Store 00482',
leftParty: { user: 'Store 00482', number: '50482', model: 'DBS-210-3PC' },
model: 'DBS-210-3PC',
calledNumber: '+17247795678',
disposition: 'Success',
normalOutcome: true,
abnormal: false,
};
const { line1 } = formatCallBlock(call, { timeZone: 'America/New_York', includeWan: false });
assert.match(line1, /Store 00482 \(50482, DBS-210-3PC\) → \+17247795678/);
assert.match(line1, /^✅ /);
});