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>
117 lines
3.5 KiB
JavaScript
117 lines
3.5 KiB
JavaScript
// tests/jiraPoller.enrichmentRules.test.js
|
|
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import {
|
|
resolveEnrichmentPlan,
|
|
extractStoreFromSummary,
|
|
CHECK_IDS,
|
|
COMM_SERVICES_COMPONENT,
|
|
} from '../services/jiraPoller/enrichmentRules.js';
|
|
|
|
const comm = [{ name: COMM_SERVICES_COMPONENT }];
|
|
const mobility = [{ name: 'Mobility' }];
|
|
|
|
test('extractStoreFromSummary parses Store NNNN', () => {
|
|
assert.equal(extractStoreFromSummary('Store 2477 - garbled calls'), '2477');
|
|
assert.equal(extractStoreFromSummary('no store here'), null);
|
|
});
|
|
|
|
test('comm call quality runs phonestatus and callreport', () => {
|
|
const plan = resolveEnrichmentPlan(
|
|
{
|
|
summary: 'Store 2477 - garbled voice on inbound calls',
|
|
description: '',
|
|
components: comm,
|
|
},
|
|
{ kind: 'phone', storeNum: '2477', reason: 'desk phone issue' },
|
|
);
|
|
assert.equal(plan.skip, false);
|
|
assert.deepEqual(plan.checks, [CHECK_IDS.phonestatus, CHECK_IDS.callreport]);
|
|
assert.ok(plan.matchedRules.includes('comm-call-quality'));
|
|
});
|
|
|
|
test('comm spam runs callreport only', () => {
|
|
const plan = resolveEnrichmentPlan(
|
|
{
|
|
summary: 'Store 782 - spam robocalls to main number',
|
|
description: '',
|
|
components: comm,
|
|
},
|
|
{ kind: 'phone', storeNum: '782', reason: 'spam calls' },
|
|
);
|
|
assert.deepEqual(plan.checks, [CHECK_IDS.callreport]);
|
|
assert.ok(plan.matchedRules.includes('comm-spam'));
|
|
});
|
|
|
|
test('comm spam with both symptoms runs phonestatus and callreport', () => {
|
|
const plan = resolveEnrichmentPlan(
|
|
{
|
|
summary: 'Store 100 - spam and garbled audio',
|
|
components: comm,
|
|
},
|
|
{ kind: 'phone', storeNum: '100', reason: 'x' },
|
|
);
|
|
assert.deepEqual(plan.checks, [CHECK_IDS.phonestatus, CHECK_IDS.callreport]);
|
|
});
|
|
|
|
test('mobility spam does not trigger comm spam rule', () => {
|
|
const plan = resolveEnrichmentPlan(
|
|
{
|
|
summary: 'Store 500 - spam calls',
|
|
components: mobility,
|
|
},
|
|
{ kind: 'phone', storeNum: '500', reason: 'phone' },
|
|
);
|
|
assert.deepEqual(plan.checks, [CHECK_IDS.phonestatus]);
|
|
assert.deepEqual(plan.matchedRules, ['default-phone']);
|
|
});
|
|
|
|
test('default phone kind runs phonestatus only', () => {
|
|
const plan = resolveEnrichmentPlan(
|
|
{
|
|
summary: 'Store 300 - phone not registering',
|
|
components: comm,
|
|
},
|
|
{ kind: 'phone', storeNum: '300', reason: 'registration' },
|
|
);
|
|
assert.deepEqual(plan.checks, [CHECK_IDS.phonestatus]);
|
|
assert.deepEqual(plan.matchedRules, ['default-phone']);
|
|
});
|
|
|
|
test('default av kind runs avstatus', () => {
|
|
const plan = resolveEnrichmentPlan(
|
|
{
|
|
summary: 'Store 400 - signage offline',
|
|
components: [{ name: 'Audio Visual' }],
|
|
},
|
|
{ kind: 'av', storeNum: '400', reason: 'signage' },
|
|
);
|
|
assert.deepEqual(plan.checks, [CHECK_IDS.avstatus]);
|
|
});
|
|
|
|
test('comm symptom with store from summary when AI has no store', () => {
|
|
const plan = resolveEnrichmentPlan(
|
|
{
|
|
summary: 'Store 2477 - static on all calls',
|
|
components: comm,
|
|
},
|
|
{ kind: 'skip', storeNum: null, reason: 'unclear' },
|
|
);
|
|
assert.equal(plan.storeNum, '2477');
|
|
assert.equal(plan.skip, false);
|
|
assert.ok(plan.checks.includes(CHECK_IDS.callreport));
|
|
});
|
|
|
|
test('comm symptom without store skips', () => {
|
|
const plan = resolveEnrichmentPlan(
|
|
{
|
|
summary: 'Garbled calls - no store listed',
|
|
components: comm,
|
|
},
|
|
{ kind: 'skip', storeNum: null, reason: 'no store' },
|
|
);
|
|
assert.equal(plan.skip, true);
|
|
assert.equal(plan.checks.length, 0);
|
|
});
|