wulf-pulse/lib/services/rmm/worker.test.ts
lorentz 1112a06afe feat: RMM Overshell, IT Glue audit/write-back, LogLift, link-aware bundles, dashboard overhaul
- RMM Overshell (migration 077): admin page, dispatch UI, executor/worker, target
  resolver, script registry (AD/DHCP/DNS/event-log/services/software/network/loglift)
- LogLift evidence pipeline (migration 078): upload webhook, B2 storage client,
  receiver/matcher, EventLogCollector PowerShell script
- IT Glue audit + write-back (migrations 075, 076): asset-audit runner, ticket
  xrefs, applications/configurations browse pages + apply/revert/audit endpoints
- Link-aware analyzer bundles (migration 073) + provider toggle (migration 074):
  link-discovery service, OpenRouter LLM provider, related-tickets/itglue-suggestion
  panels, analyze-bundle endpoint
- Endpoint data model + device-link reconciliation (migrations 079, 080): conflicts
  admin page, reconciler service, resolve endpoints
- Dashboard overhaul: integration-health service + alerts, overview/health endpoints
- Permissions: add itglue + rmm scopes; middleware: public /api/rmm/loglift route

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 07:13:18 -04:00

59 lines
1.7 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { _RMM_WORKER_INTERNALS } from './worker';
describe('extractResult', () => {
const { extractResult } = _RMM_WORKER_INTERNALS;
const deviceUid = 'dev-1';
it('returns done=false while jobStatus is running', () => {
const r = extractResult({ jobStatus: 'running', stdOut: null }, deviceUid);
expect(r.done).toBe(false);
expect(r.exitCode).toBeNull();
});
it('returns done=true with exitCode 0 on succeeded', () => {
const r = extractResult(
{ jobStatus: 'succeeded', stdOut: '{"ok":true}', stdErr: '', errorCode: 0 },
deviceUid
);
expect(r.done).toBe(true);
expect(r.exitCode).toBe(0);
expect(r.stdout).toBe('{"ok":true}');
});
it('returns done=true with exitCode 1 on failed (no errorCode given)', () => {
const r = extractResult({ jobStatus: 'failed', stdErr: 'boom' }, deviceUid);
expect(r.done).toBe(true);
expect(r.exitCode).toBe(1);
expect(r.stderr).toBe('boom');
});
it('uses per-device result when results array present', () => {
const r = extractResult(
{
jobStatus: 'running',
results: [
{ deviceUid: 'dev-1', jobStatus: 'succeeded', stdOut: 'A', errorCode: 0 },
{ deviceUid: 'dev-2', jobStatus: 'running', stdOut: null },
],
},
'dev-1'
);
expect(r.done).toBe(true);
expect(r.stdout).toBe('A');
});
it('falls back to first result when device-specific not found', () => {
const r = extractResult(
{
jobStatus: 'succeeded',
results: [
{ jobStatus: 'succeeded', stdOut: 'fallback', errorCode: 0 },
],
},
'dev-X'
);
expect(r.done).toBe(true);
expect(r.stdout).toBe('fallback');
});
});