- Delete unused dataMerger, formatter, Device model, dead service exports, and the empty agents/ + .gitkeep placeholders. - Extract STORE_MODES and MDM device-type filters into a shared constants.js. - Anchor bot regexes (^help|^store|^analyze) so "analyze store 305" no longer fires both handlers; replace catch-all noise. - Hoist inline require() calls in integrations to top-of-file imports. - Harden WebSocket server: Authorization header support, single-agent enforcement, bounded pending requests, server-level error handler, coalesced cache refresh in Meraki client. - Wrap Meraki/MDM network calls with withRetry; add request timeouts. - Migrate all console.* calls onto utils/logger.js (LOG_LEVEL aware); drive Webex framework logLevel from env. - Refactor storeDetail.js: shared renderClientLine + buildMdmSection helpers cut duplication roughly in half. - Refresh README structure, document LOG_LEVEL, add npm run agent script, add jest testMatch + new tests (handlers, HealthReport, Store, ws). Verified: npm run lint clean, 7 suites / 31 tests passing. Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
1 KiB
JavaScript
29 lines
1 KiB
JavaScript
/**
|
|
* Integration test for store health analysis using mocks.
|
|
*/
|
|
|
|
const { getStoreHealth } = require('../../integrations/storeHealth');
|
|
|
|
// Mock the services
|
|
jest.mock('../../services/meraki', () => require('../mocks/mockMeraki'));
|
|
jest.mock('../../services/mdm', () => require('../mocks/mockMdm'));
|
|
|
|
// SIW is required dynamically in the file, so we mock the whole module
|
|
jest.mock('../../services/siw', () => require('../mocks/mockSiw'));
|
|
|
|
describe('storeHealth integration (with mocks)', () => {
|
|
it('returns a health summary with reasonable score for a known store', async () => {
|
|
const result = await getStoreHealth('305');
|
|
|
|
expect(result).toHaveProperty('summary');
|
|
expect(result.summary).toContain('Store 305 Health Summary');
|
|
expect(result.summary).toContain('Overall Status');
|
|
});
|
|
|
|
it('handles missing Meraki network gracefully', async () => {
|
|
// Store 999 does not exist in mock
|
|
const result = await getStoreHealth('999');
|
|
|
|
expect(result.summary).toContain('No Meraki network found');
|
|
});
|
|
});
|