import { describe, expect, it } from 'vitest'; import { deriveShellStatus } from '../../apps/dashboard/src/app/shell-status.js'; describe('global shell status', () => { it('derives safety-critical labels from authoritative snapshots', () => { expect(deriveShellStatus({ stats: { mode: 'running', dryRunMode: true, invitationCooldown: { reason: 'Reddit cooldown' } }, reddit: { ready: true, loggedIn: true, status: 'authenticated' }, realtime: { status: 'reconnecting', isStale: true }, sync: { syncing: true, syncingKind: 'full' }, })).toEqual({ bot: 'Running (dry run)', reddit: 'Reddit authenticated', realtime: 'Realtime reconnecting (stale)', cooldown: 'Reddit cooldown', sync: 'Full sync active', controlAction: 'stopped', controlDisabled: false, }); }); it('labels scan mode and offers a full start as the next step', () => { expect(deriveShellStatus({ stats: { mode: 'scan', dryRunMode: false, invitationCooldown: null }, realtime: { status: 'connected', isStale: false }, })).toMatchObject({ bot: 'Scanning', controlAction: 'running' }); }); it('guards bot controls until the authoritative bot state is available', () => { expect(deriveShellStatus({ realtime: { status: 'idle', isStale: true } })).toMatchObject({ bot: 'Bot state unavailable', controlDisabled: true, }); }); });