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>
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
// tests/resetVmPin.reset.test.js
|
|
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { resetVoicemailPin } from '../services/voicePin/resetVoicemailPin.js';
|
|
|
|
test('resetVoicemailPin PUTs a 6-digit passcode', async () => {
|
|
const calls = [];
|
|
const webexClient = {
|
|
async request(method, endpoint, body) {
|
|
calls.push({ method, endpoint, body });
|
|
return {};
|
|
},
|
|
};
|
|
|
|
const pin = await resetVoicemailPin('PERSON123', { webexClient });
|
|
|
|
assert.match(pin, /^\d{6}$/);
|
|
assert.equal(calls.length, 1);
|
|
assert.equal(calls[0].method, 'PUT');
|
|
assert.equal(calls[0].endpoint, 'telephony/config/people/PERSON123/voicemail/passcode');
|
|
assert.equal(calls[0].body.passcode, pin);
|
|
});
|
|
|
|
test('resetVoicemailPin retries on HTTP 400', async () => {
|
|
let attempt = 0;
|
|
const webexClient = {
|
|
async request() {
|
|
attempt += 1;
|
|
if (attempt === 1) {
|
|
const err = new Error('rejected');
|
|
err.response = { status: 400 };
|
|
throw err;
|
|
}
|
|
return {};
|
|
},
|
|
};
|
|
|
|
const pin = await resetVoicemailPin('PERSON123', { webexClient });
|
|
|
|
assert.match(pin, /^\d{6}$/);
|
|
assert.equal(attempt, 2);
|
|
});
|