Use topology/links and anynetlinks filters with eq/in operators so store WAN follow-ups return real peer tunnels instead of unscoped dumps. Co-authored-by: Cursor <cursoragent@cursor.com>
60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
// tests/voicePathAttribution.test.js
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import {
|
|
pickUniqueWorst,
|
|
annotateWanWithPath,
|
|
attributeVoicePathToEndpoint,
|
|
} from '../services/callReport/voicePathAttribution.js';
|
|
|
|
function series(max, avg = max) {
|
|
return { max, avg, min: avg, validSamples: 3, samples: 3 };
|
|
}
|
|
|
|
test('pickUniqueWorst: picks clearly worse path_type', () => {
|
|
const pick = pickUniqueWorst({
|
|
VPN: { loss: series(12), jitter: series(40) },
|
|
DirectInternet: { loss: series(0.5), jitter: series(5) },
|
|
});
|
|
assert.equal(pick.key, 'VPN');
|
|
assert.ok(pick.margin >= 0.5);
|
|
});
|
|
|
|
test('pickUniqueWorst: returns null on close tie', () => {
|
|
const pick = pickUniqueWorst({
|
|
VPN: { loss: series(1.0) },
|
|
DirectInternet: { loss: series(1.1) },
|
|
});
|
|
assert.equal(pick, null);
|
|
});
|
|
|
|
test('annotateWanWithPath: path confidence when byPath unique', () => {
|
|
const wan = { siteLevelApprox: true, mos: 3.2, loss: 10, jitter: 40 };
|
|
const annotated = annotateWanWithPath(wan, {
|
|
byPath: {
|
|
'wi-bad': { loss: series(20), jitter: series(50) },
|
|
'wi-ok': { loss: series(0.1), jitter: series(2) },
|
|
},
|
|
});
|
|
assert.equal(annotated.confidence, 'path');
|
|
assert.equal(annotated.pathId, 'wi-bad');
|
|
assert.equal(annotated.siteLevelApprox, false);
|
|
});
|
|
|
|
test('annotateWanWithPath: path_type confidence from byPathType', () => {
|
|
const wan = { siteLevelApprox: true, mos: 4.0, loss: 1, jitter: 10 };
|
|
const annotated = annotateWanWithPath(wan, {
|
|
byPathType: {
|
|
VPN: { loss: series(15), jitter: series(40) },
|
|
DirectInternet: { loss: series(0.2), jitter: series(3) },
|
|
},
|
|
});
|
|
assert.equal(annotated.confidence, 'path_type');
|
|
assert.equal(annotated.pathType, 'VPN');
|
|
assert.equal(annotated.siteLevelApprox, true);
|
|
});
|
|
|
|
test('attributeVoicePathToEndpoint: stub returns null (no join key)', () => {
|
|
assert.equal(attributeVoicePathToEndpoint({}, {}), null);
|
|
});
|