Files
RedditBot/tests/dashboard/shell-status.test.ts

23 lines
1.0 KiB
TypeScript

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: { isRunning: true, 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: 'stop', controlDisabled: false,
});
});
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,
});
});
});