Chat-only commands reset voicemail mailbox and voice portal passcodes via telephony_config_write, with extension lookup and unit tests. Co-authored-by: Cursor <cursoragent@cursor.com>
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
// tests/resetVmPin.extensionIndex.test.js
|
|
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import {
|
|
resolveRecordsByExtension,
|
|
_clearLocationCacheForTests,
|
|
_setNumbersCacheForTests,
|
|
} from '../services/callTest/locationResolver.js';
|
|
|
|
test('resolveRecordsByExtension returns records from byExtension index', async () => {
|
|
_clearLocationCacheForTests();
|
|
const record = {
|
|
locationId: 'LOC1',
|
|
locationName: 'Store 0782',
|
|
phoneNumber: '+17247795574',
|
|
extension: '50782',
|
|
owner: { id: 'PERSON1', name: 'Store 0782' },
|
|
};
|
|
_setNumbersCacheForTests({
|
|
byPhoneDigits: new Map(),
|
|
byPersonId: new Map([['PERSON1', [record]]]),
|
|
byExtension: new Map([['50782', [record]]]),
|
|
records: [record],
|
|
});
|
|
|
|
const matches = await resolveRecordsByExtension('50782');
|
|
assert.equal(matches.length, 1);
|
|
assert.equal(matches[0].owner.id, 'PERSON1');
|
|
|
|
_clearLocationCacheForTests();
|
|
});
|
|
|
|
test('resolveRecordsByExtension returns empty for unknown extension', async () => {
|
|
_clearLocationCacheForTests();
|
|
_setNumbersCacheForTests({
|
|
byPhoneDigits: new Map(),
|
|
byPersonId: new Map(),
|
|
byExtension: new Map(),
|
|
records: [],
|
|
});
|
|
|
|
const matches = await resolveRecordsByExtension('99999');
|
|
assert.deepEqual(matches, []);
|
|
|
|
_clearLocationCacheForTests();
|
|
});
|