Files
ITWorx-Pulse-Public/apps/web/tests/unit/overviewSignals.test.ts
T
ITWorx Pulse release export bd774932d5
Public source validation / validate (push) Failing after 3m8s
Publish ITWorx Pulse source
2026-09-03 02:09:19 +02:00

28 lines
1.5 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { containerSignalTone, signalToneFromState, sourceSignalTone, worstSignalTone } from '../../src/overviewSignals';
describe('overview signal semantics', () => {
it('fails source provenance closed when freshness is stale or unavailable', () => {
expect(sourceSignalTone({ state: 'healthy', freshness: 'stale' })).toBe('stale');
expect(sourceSignalTone({ state: 'healthy', freshness: 'unavailable' })).toBe('unknown');
expect(sourceSignalTone({ state: 'degraded', freshness: 'fresh' })).toBe('attention');
expect(sourceSignalTone({ state: 'healthy', freshness: 'fresh' })).toBe('healthy');
expect(sourceSignalTone(undefined)).toBe('unknown');
});
it('mirrors container domain state without escalating intentional stops', () => {
expect(containerSignalTone({ state: 'running', health: 'healthy' })).toBe('healthy');
expect(containerSignalTone({ state: 'running', health: 'unhealthy' })).toBe('attention');
expect(containerSignalTone({ state: 'restarting', health: 'unknown' })).toBe('attention');
expect(containerSignalTone({ state: 'stopped', health: 'unknown' })).toBe('critical');
expect(containerSignalTone({ state: 'stopped', health: 'unknown', intentionalStop: true })).toBe('unknown');
});
it('keeps the most severe state deterministically', () => {
expect(signalToneFromState('DOWN')).toBe('critical');
expect(worstSignalTone(['healthy', 'unknown', 'attention', 'stale'])).toBe('attention');
expect(worstSignalTone([])).toBe('unknown');
});
});