Rebrand NetAnalyzer -> StoreHealthAnalyzer and consolidate the store
reporting surface into a single `st [number]` command with focused
sub-modes.
Commands
- st [number] - general info (SIW + brands + Meraki net link)
- st [number] network - switches, APs, store server
- st [number] pos - registers, payment terminals, customer display
- st [number] ios - MDM-tracked iOS hardware
- st [number] phone - wired 78xx + DECT basestations/handsets with
registration state, extensions and main DID
- st [number] av - Atlas AMPs + MDM-tracked Apple TVs, video
walls, music players, LED displays
- Removed `analyze` in favor of the unified `st` surface
Integrations
- integrations/webex: Service App OAuth with rotating refresh tokens,
seed + cleanup scripts, tokens/ storage (git-ignored)
- integrations/atlas: Xyte client + cached device discovery keyed on
zero-padded 6-digit store numbers, cold-cache failure -> unavailable
banner instead of a misleading empty result
- services/webexPhone, services/webexService, services/avService: shape
raw upstream data into the report layer's contract
- utils/merakiMatcher: FQDN hostname extraction so payment terminals
match Meraki descriptions; case-insensitive lookup
- utils/chunkReport: split long markdown replies at 7000-char boundaries
Reliability / ops
- server.js: awaited framework.stop() + 8s hard-kill timer so nodemon /
Docker restarts don't leak WDM device registrations ("excessive device
registrations")
- nodemon.json: SIGINT so the graceful path always runs
- scripts/cleanupWebexDevices.js: one-shot WDM cleanup utility
- Group-space routing: hears() regexes tolerate the leading @BotName
prefix Webex prepends to mentions
- Replaced HTML-unsafe <number> placeholders with [number] in all help
strings
Remote agent containerization
- docker/remote-agent/: multi-stage node:22-alpine image, non-root user,
tini for signal handling, minimal deps (ws/axios/dotenv)
- docker/remote-agent/package.sh: docker buildx build defaulting to
linux/amd64 (with override), saves image + assembles deploy/ + writes
SHA256 + zips for offline transfer
- docker/remote-agent/deploy/: runtime docker-compose.yml, install.sh
with platform sanity check, remote-host README
- .dockerignore + .gitignore updates for build artifacts and dist bundles
- npm run agent:package convenience script
Cleanup
- Dropped storeHealth.js / HealthReport.js and their tests/mocks in favor
of the shared storeDetail pipeline
- Store model handles null SIW records gracefully; toSummary always
ends with a newline so the Meraki link sits on its own line
Tests
- 144 tests across 14 suites passing; new coverage for atlasClient,
atlasDevices, avService, avCategory classification, webexPhone,
webexServiceAppAuth, storeDetail integration, siw, chunkReport and
the updated meraki matcher
Co-authored-by: Cursor <cursoragent@cursor.com>
119 lines
4 KiB
JavaScript
119 lines
4 KiB
JavaScript
jest.mock('../config', () => ({ logLevel: 'error' }));
|
|
|
|
jest.mock('../integrations/atlas/atlasDevices', () => ({
|
|
getAtlasDevicesForStore: jest.fn(),
|
|
}));
|
|
|
|
const { getAtlasDevicesForStore } = require('../integrations/atlas/atlasDevices');
|
|
const { collectAvStatus, shapeAtlasDevice, deriveOnline } = require('../services/avService');
|
|
|
|
describe('deriveOnline', () => {
|
|
it('returns true for common "online" keywords', () => {
|
|
expect(deriveOnline({ connection_status: 'online' })).toBe(true);
|
|
expect(deriveOnline({ connection_status: 'CONNECTED' })).toBe(true);
|
|
expect(deriveOnline({ state: { connection_status: 'active' } })).toBe(true);
|
|
expect(deriveOnline({ status: 'up' })).toBe(true);
|
|
});
|
|
|
|
it('returns false for common "offline" keywords', () => {
|
|
expect(deriveOnline({ connection_status: 'offline' })).toBe(false);
|
|
expect(deriveOnline({ connection_status: 'Disconnected' })).toBe(false);
|
|
expect(deriveOnline({ status: 'inactive' })).toBe(false);
|
|
});
|
|
|
|
it('returns null when no recognisable status field is present', () => {
|
|
expect(deriveOnline({})).toBeNull();
|
|
expect(deriveOnline({ status: 'idk' })).toBeNull();
|
|
expect(deriveOnline({ status: '' })).toBeNull();
|
|
});
|
|
|
|
it('honors explicit booleans', () => {
|
|
expect(deriveOnline({ connection_status: true })).toBe(true);
|
|
expect(deriveOnline({ connection_status: false })).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('shapeAtlasDevice', () => {
|
|
it('promotes state.IpAddress / state.MacAddress to top-level ip / mac', () => {
|
|
const shaped = shapeAtlasDevice({
|
|
id: 'd1',
|
|
name: 'US000782AMP',
|
|
state: { IpAddress: '10.0.0.5', MacAddress: 'AA:BB:CC:DD:EE:FF' },
|
|
status: 'online',
|
|
});
|
|
expect(shaped.ip).toBe('10.0.0.5');
|
|
expect(shaped.mac).toBe('AA:BB:CC:DD:EE:FF');
|
|
expect(shaped.online).toBe(true);
|
|
});
|
|
|
|
it('handles model as a string OR an object with .name', () => {
|
|
expect(shapeAtlasDevice({ model: 'Cisco AMP' }).model).toBe('Cisco AMP');
|
|
expect(shapeAtlasDevice({ model: { name: 'Cisco AMP' } }).model).toBe('Cisco AMP');
|
|
});
|
|
|
|
it('falls back to a placeholder name when none is present', () => {
|
|
expect(shapeAtlasDevice({}).name).toBe('Unknown AV Device');
|
|
});
|
|
});
|
|
|
|
describe('collectAvStatus', () => {
|
|
beforeEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
it('shapes each Atlas device returned by the integration', async () => {
|
|
getAtlasDevicesForStore.mockResolvedValue({
|
|
devices: [
|
|
{
|
|
id: 'd1',
|
|
name: 'US000782AMP',
|
|
model: 'Cisco AMP',
|
|
state: { IpAddress: '10.0.0.5', MacAddress: 'aa:bb:cc:dd:ee:ff' },
|
|
status: 'online',
|
|
},
|
|
],
|
|
});
|
|
|
|
const result = await collectAvStatus('782');
|
|
expect(result.unavailable).toBeFalsy();
|
|
expect(result.devices).toHaveLength(1);
|
|
expect(result.devices[0]).toEqual(
|
|
expect.objectContaining({
|
|
id: 'd1',
|
|
name: 'US000782AMP',
|
|
model: 'Cisco AMP',
|
|
ip: '10.0.0.5',
|
|
mac: 'aa:bb:cc:dd:ee:ff',
|
|
online: true,
|
|
})
|
|
);
|
|
});
|
|
|
|
it('propagates an unavailable payload from the integration layer', async () => {
|
|
getAtlasDevicesForStore.mockResolvedValue({
|
|
devices: [],
|
|
unavailable: true,
|
|
reason: 'ATLAS_AUTH_KEY is not set',
|
|
});
|
|
|
|
const result = await collectAvStatus('782');
|
|
expect(result.unavailable).toBe(true);
|
|
expect(result.reason).toMatch(/ATLAS_AUTH_KEY/);
|
|
expect(result.devices).toEqual([]);
|
|
});
|
|
|
|
it('catches unexpected throws and returns the banner contract', async () => {
|
|
getAtlasDevicesForStore.mockRejectedValue(new Error('boom'));
|
|
const result = await collectAvStatus('782');
|
|
expect(result.unavailable).toBe(true);
|
|
expect(result.reason).toBe('boom');
|
|
expect(result.devices).toEqual([]);
|
|
});
|
|
|
|
it('returns an empty list when the store has no Atlas devices', async () => {
|
|
getAtlasDevicesForStore.mockResolvedValue({ devices: [] });
|
|
const result = await collectAvStatus('782');
|
|
expect(result.unavailable).toBeFalsy();
|
|
expect(result.devices).toEqual([]);
|
|
});
|
|
});
|