Some checks failed
CI / verify (push) Has been cancelled
New /provisionPhone <storeNumber> command manages the store user's wired desk phones via the same card pattern as /provisionDect: multi-select checkbox list that doubles as the display, MACs render as AA:BB:CC:DD:EE:FF, model dropdown for add (defaults to 7841), side-by-side Add / Remove-checked actions, and every removal goes through an explicit confirm card. Adds are idempotent (MACs already registered are skipped) and bulk MAC input is supported. DECT handsets are filtered out of the display so /provisionPhone and /provisionDect coexist cleanly on the same store user without overlapping responsibilities. Refactors: - Extract MAC helpers (normalize/format/display) to src/utils/mac.js so both DECT and wired-phone flows share one implementation. dect.js re-exports for backward compat with existing consumers. - Add parseEmailArg helper; migrate /userInfo to use it. Tests: pure-logic coverage for WIRED_PHONE_MODELS, isSupportedWiredModel, filterWiredPhones (DECT/model filter), and parseEmailArg. Co-authored-by: Cursor <cursoragent@cursor.com>
83 lines
3 KiB
JavaScript
83 lines
3 KiB
JavaScript
import { describe, it } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import {
|
|
WIRED_PHONE_MODELS,
|
|
filterWiredPhones,
|
|
isSupportedWiredModel,
|
|
} from '../src/webex/phones.js';
|
|
|
|
// Sanity check: the supported models list stays in sync with the two
|
|
// models AE actually deploys. Add a case below when a new model lands.
|
|
describe('WIRED_PHONE_MODELS', () => {
|
|
it('includes both Cisco 7841 and 7821', () => {
|
|
const values = WIRED_PHONE_MODELS.map((m) => m.value);
|
|
assert.ok(values.includes('Cisco 7841'), '7841 missing');
|
|
assert.ok(values.includes('Cisco 7821'), '7821 missing');
|
|
});
|
|
|
|
it('7841 is first (used as the default in the add card)', () => {
|
|
assert.equal(WIRED_PHONE_MODELS[0].value, 'Cisco 7841');
|
|
});
|
|
});
|
|
|
|
describe('isSupportedWiredModel', () => {
|
|
it('accepts the exact strings in WIRED_PHONE_MODELS', () => {
|
|
assert.equal(isSupportedWiredModel('Cisco 7841'), true);
|
|
assert.equal(isSupportedWiredModel('Cisco 7821'), true);
|
|
});
|
|
|
|
it('is case-sensitive so we always send Webex the canonical name', () => {
|
|
assert.equal(isSupportedWiredModel('cisco 7841'), false);
|
|
assert.equal(isSupportedWiredModel('CISCO 7841'), false);
|
|
});
|
|
|
|
it('rejects unknown models', () => {
|
|
assert.equal(isSupportedWiredModel('Cisco 8845'), false);
|
|
assert.equal(isSupportedWiredModel(''), false);
|
|
assert.equal(isSupportedWiredModel(undefined), false);
|
|
});
|
|
});
|
|
|
|
describe('filterWiredPhones', () => {
|
|
it('keeps 78xx MPP phones', () => {
|
|
const items = [
|
|
{ id: '1', product: 'Cisco 7841' },
|
|
{ id: '2', product: 'Cisco 7821' },
|
|
];
|
|
const kept = filterWiredPhones(items).map((d) => d.id);
|
|
assert.deepEqual(kept, ['1', '2']);
|
|
});
|
|
|
|
it('drops DECT devices by product name', () => {
|
|
const items = [
|
|
{ id: '1', product: 'Cisco 7841' },
|
|
{ id: '2', product: 'DMS Cisco DBS210' },
|
|
{ id: '3', product: 'DECT Handset' },
|
|
];
|
|
const kept = filterWiredPhones(items).map((d) => d.id);
|
|
assert.deepEqual(kept, ['1']);
|
|
});
|
|
|
|
it('is case-insensitive on the DECT marker so future firmware names still match', () => {
|
|
const items = [{ id: '1', product: 'cisco dbs-210' }];
|
|
assert.equal(filterWiredPhones(items).length, 0);
|
|
});
|
|
|
|
it('falls back to `model` when `product` is missing', () => {
|
|
// Some Webex endpoints report `model` instead of `product`; we
|
|
// accept either so filterWiredPhones works against both shapes.
|
|
const items = [{ id: '1', model: 'Cisco 7841' }];
|
|
assert.equal(filterWiredPhones(items).length, 1);
|
|
});
|
|
|
|
it("drops entries with no model info (can't classify)", () => {
|
|
const items = [{ id: '1' }, { id: '2', product: '' }];
|
|
assert.equal(filterWiredPhones(items).length, 0);
|
|
});
|
|
|
|
it('accepts an empty array', () => {
|
|
assert.deepEqual(filterWiredPhones([]), []);
|
|
assert.deepEqual(filterWiredPhones(), []);
|
|
});
|
|
});
|