collabSupport/tests/atlasResolveStoreDevice.test.js
jmcqueen 5e54ea6f57 Add /atlasdiag live AZM diagnostic with source alerts and monitor auto-off.
Ports Atlas /check as /atlasdiag: Hub resolve, UI tunnel, WebSocket report
for sources/zones/accessories, low source dB warnings, and auto-disable of
the monitor speaker when left on after troubleshooting.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 17:59:17 -04:00

40 lines
1.2 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {
padStoreNumber,
resolveStoreDevice,
} from '../integrations/atlas/resolveStoreDevice.js';
const DEVICES = [
{ id: '1', name: 'US002547AMP', status: 'online' },
{ id: '2', name: 'US002548AMP', status: 'online' },
{ id: '3', name: 'US000305XYZ', status: 'online' },
];
test('padStoreNumber: pads to 6 digits', () => {
assert.equal(padStoreNumber('2547'), '002547');
assert.equal(padStoreNumber('305'), '000305');
assert.equal(padStoreNumber(''), null);
});
test('resolveStoreDevice: strict AMP regex by store number', () => {
const hit = resolveStoreDevice(DEVICES, '2547');
assert.equal(hit.device?.name, 'US002547AMP');
assert.equal(hit.storePadded, '002547');
const miss = resolveStoreDevice(DEVICES, '305');
assert.equal(miss.code, 'NOT_FOUND');
assert.equal(miss.device, null);
});
test('resolveStoreDevice: resolves by full device name', () => {
const hit = resolveStoreDevice(DEVICES, 'US002548AMP');
assert.equal(hit.device?.id, '2');
assert.equal(hit.storePadded, '002548');
});
test('resolveStoreDevice: missing store returns MISSING', () => {
const miss = resolveStoreDevice(DEVICES, '');
assert.equal(miss.code, 'MISSING');
});