Files
immich-folio/app/admin/__tests__/systemHealth.test.ts
Ralksta ad8b09700b release: v0.19.0
Release v0.19.0. See the `## [0.19.0] — 2026-09-29` section of
[CHANGELOG.md](https://github.com/ralksta/immich-folio/blob/dev/CHANGELOG.md)
for the full list.

Highlights: client proofing links (#683), custom content pages (#738),
asset picker search (#740), concurrent-edit detection (#742), env-locked
settings (#739), an accessibility baseline (#741), three security fixes
with advisories (#737, #755, #759), and a pre-release quality pass
(#780–#797).

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: ralksta <ralksta@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Ralf <rohlenbo79@gmail.com>
Co-authored-by: Paul Thies <110185070+ImScheinox@users.noreply.github.com>
Co-authored-by: lancetm714 <108419425+lancetm714@users.noreply.github.com>
Co-authored-by: Lance Martin <lancetaylor95@gmail.com>
2026-09-29 22:50:30 +02:00

86 lines
3.0 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { systemHealth, type SystemHealthInput } from '../components/systemHealth';
const base: SystemHealthInput = {
statusLoading: false,
setupIncomplete: false,
immich: 'ok',
doctorLevel: null,
};
const health = (over: Partial<SystemHealthInput> = {}) => systemHealth({ ...base, ...over });
describe('systemHealth', () => {
it('reports a healthy system', () => {
expect(health()).toEqual({ tone: 'connected', label: 'System OK' });
});
it('stays neutral while loading', () => {
expect(health({ statusLoading: true })).toEqual({ tone: 'unknown', label: 'Checking...' });
});
it('keeps the badge neutral while a stale error is being rechecked', () => {
// The class used to have no loading case, so a doctor error left over from
// the previous run painted the badge red under "Checking..." (#539).
expect(health({ statusLoading: true, immich: 'unknown', doctorLevel: 'error' })).toEqual({
tone: 'unknown',
label: 'Checking...',
});
});
it('treats an unfinished install as neutral, not as a fault', () => {
expect(health({ setupIncomplete: true, immich: 'error' })).toEqual({
tone: 'unknown',
label: 'Setup Incomplete',
});
});
it('lets an unreachable Immich outrank a doctor warning', () => {
// The class matched `warn` first and went neutral while the text said
// "System Degraded" — the less serious condition decided the colour (#539).
expect(health({ immich: 'error', doctorLevel: 'warn' })).toEqual({
tone: 'disconnected',
label: 'System Degraded',
});
});
it('reports a doctor error when Immich itself is fine', () => {
expect(health({ doctorLevel: 'error' })).toEqual({
tone: 'disconnected',
label: 'Needs Attention',
});
});
it('reports a doctor warning in the warning tone, not the neutral one', () => {
expect(health({ doctorLevel: 'warn' })).toEqual({
tone: 'warning',
label: 'Check Diagnostics',
});
});
it('falls back to unknown when Immich is neither ok nor in error', () => {
expect(health({ immich: 'unknown' })).toEqual({ tone: 'unknown', label: 'Status Unknown' });
});
it('never pairs a label with a tone that contradicts it', () => {
const expected: Record<string, string> = {
'Checking...': 'unknown',
'Setup Incomplete': 'unknown',
'System Degraded': 'disconnected',
'Needs Attention': 'disconnected',
'Check Diagnostics': 'warning',
'System OK': 'connected',
'Status Unknown': 'unknown',
};
for (const statusLoading of [false, true]) {
for (const setupIncomplete of [false, true]) {
for (const immich of ['ok', 'error', 'unknown']) {
for (const doctorLevel of [null, 'ok', 'warn', 'error'] as const) {
const { tone, label } = health({ statusLoading, setupIncomplete, immich, doctorLevel });
expect(expected[label], `${label} with tone ${tone}`).toBe(tone);
}
}
}
}
});
});