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.3 KiB
JavaScript
119 lines
4.3 KiB
JavaScript
const { parseStoreCommand, getCommandText } = require('../bot/handlers');
|
|
const { STORE_MODES } = require('../constants');
|
|
|
|
// The two phrase regexes registered in server.js, kept in lock-step here so
|
|
// the test suite documents the routing contract (and fails fast if either
|
|
// drifts).
|
|
const HELP_PHRASE = /^(?:\S+\s+)?help\b/i;
|
|
const ST_PHRASE = /^(?:\S+\s+)?st\b/i;
|
|
|
|
describe('parseStoreCommand', () => {
|
|
it('defaults to INFO mode for a bare st <number>', () => {
|
|
expect(parseStoreCommand('st 305')).toEqual({
|
|
storeNumber: '305',
|
|
mode: STORE_MODES.INFO,
|
|
});
|
|
});
|
|
|
|
it('recognises the network subcommand', () => {
|
|
expect(parseStoreCommand('st 305 network')).toEqual({
|
|
storeNumber: '305',
|
|
mode: STORE_MODES.NETWORK,
|
|
});
|
|
});
|
|
|
|
it('recognises the pos subcommand', () => {
|
|
expect(parseStoreCommand('st 305 pos')).toEqual({
|
|
storeNumber: '305',
|
|
mode: STORE_MODES.POS,
|
|
});
|
|
});
|
|
|
|
it('treats ios and iphone as the same mode', () => {
|
|
expect(parseStoreCommand('st 305 ios').mode).toBe(STORE_MODES.IOS);
|
|
expect(parseStoreCommand('st 305 iphone').mode).toBe(STORE_MODES.IOS);
|
|
});
|
|
|
|
it('recognises the phone and av placeholder subcommands', () => {
|
|
expect(parseStoreCommand('st 305 phone').mode).toBe(STORE_MODES.PHONE);
|
|
expect(parseStoreCommand('st 305 av').mode).toBe(STORE_MODES.AV);
|
|
});
|
|
|
|
it('does not match "phone" inside another word', () => {
|
|
// "phones" should not pick up PHONE mode — must be a whole word.
|
|
expect(parseStoreCommand('st 305 phones').mode).toBe(STORE_MODES.INFO);
|
|
});
|
|
|
|
it('returns null storeNumber when no digits are present', () => {
|
|
expect(parseStoreCommand('st')).toEqual({ storeNumber: null, mode: null });
|
|
expect(parseStoreCommand('st network')).toEqual({ storeNumber: null, mode: null });
|
|
});
|
|
});
|
|
|
|
describe('getCommandText', () => {
|
|
it('prefers trigger.command + trigger.prompt (framework-cleaned text)', () => {
|
|
// What the framework gives us in a group space after stripping the bot
|
|
// mention: command is the matched phrase, prompt is everything after.
|
|
const trigger = {
|
|
command: 'st',
|
|
prompt: ' 782 network',
|
|
message: { text: 'devStoreHealthAnalyzer st 782 network' },
|
|
};
|
|
expect(getCommandText(trigger)).toBe('st 782 network');
|
|
});
|
|
|
|
it('handles a DM message (no bot-name prefix) the same way', () => {
|
|
const trigger = {
|
|
command: 'st',
|
|
prompt: ' 782 pos',
|
|
message: { text: 'st 782 pos' },
|
|
};
|
|
expect(getCommandText(trigger)).toBe('st 782 pos');
|
|
});
|
|
|
|
it('falls back to message.text when command/prompt are absent', () => {
|
|
expect(getCommandText({ message: { text: 'st 305' } })).toBe('st 305');
|
|
});
|
|
|
|
it('returns an empty string for an empty trigger', () => {
|
|
expect(getCommandText({})).toBe('');
|
|
expect(getCommandText(null)).toBe('');
|
|
});
|
|
});
|
|
|
|
describe('route phrase regexes', () => {
|
|
// Direct-message form (no bot name).
|
|
it('matches bare DM commands', () => {
|
|
expect(ST_PHRASE.test('st 782')).toBe(true);
|
|
expect(ST_PHRASE.test('st 782 network')).toBe(true);
|
|
expect(HELP_PHRASE.test('help')).toBe(true);
|
|
expect(HELP_PHRASE.test('help st')).toBe(true);
|
|
});
|
|
|
|
// Group-mention form: Webex prepends "BotName " to mentioned messages.
|
|
it('matches group-mention commands with a leading bot-name prefix', () => {
|
|
expect(ST_PHRASE.test('devStoreHealthAnalyzer st 782')).toBe(true);
|
|
expect(ST_PHRASE.test('devStoreHealthAnalyzer st 782 ios')).toBe(true);
|
|
expect(HELP_PHRASE.test('devStoreHealthAnalyzer help')).toBe(true);
|
|
});
|
|
|
|
// Don't trigger on similar-looking words.
|
|
it('does not match unrelated words containing "st"', () => {
|
|
expect(ST_PHRASE.test('stop the build')).toBe(false);
|
|
expect(ST_PHRASE.test('start now')).toBe(false);
|
|
expect(ST_PHRASE.test('fast 305')).toBe(false);
|
|
});
|
|
|
|
// Don't trigger when the command is buried mid-sentence in a DM.
|
|
it('does not match commands buried more than one word deep', () => {
|
|
expect(ST_PHRASE.test('please run st 305')).toBe(false);
|
|
expect(HELP_PHRASE.test('I really need help')).toBe(false);
|
|
});
|
|
|
|
// Disambiguation: "BotName help st" should hit help only, not st.
|
|
it('routes "help st" to help only', () => {
|
|
const msg = 'devStoreHealthAnalyzer help st';
|
|
expect(HELP_PHRASE.test(msg)).toBe(true);
|
|
expect(ST_PHRASE.test(msg)).toBe(false);
|
|
});
|
|
});
|