Files
immich-folio/lib/__tests__/settingValues.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

54 lines
2.2 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { validateSettingValues } from '../config/settingValues';
import { resolveTheme } from '../config/theme';
import { normaliseSiteUrl } from '../siteUrl';
const fields = (input: unknown) => validateSettingValues(input).map((e) => e.field);
/**
* The save route and the doctor refuse exactly what the site would ignore, no
* more (QA A-14). Each case is paired with the resolver it mirrors, so the two
* cannot drift apart unnoticed.
*/
describe('validateSettingValues', () => {
it('passes an empty or partial file', () => {
expect(fields({})).toEqual([]);
expect(fields({ title: 'Folio' })).toEqual([]);
expect(fields(null)).toEqual([]);
});
it('refuses an accent resolveTheme would replace, and only that', () => {
for (const accent of ['rot', 'red', 'rgb(230 0 18)', '#12345']) {
expect(fields({ theme: { accent } })).toEqual(['theme.accent']);
expect(resolveTheme({ preset: 'minimal', accent }).accent).toBe(
resolveTheme('minimal').accent,
);
}
for (const accent of ['#e60012', '#FFF', ' #e60012 ', '#e60012cc', '']) {
expect(fields({ theme: { accent } })).toEqual([]);
}
// A preset name alone carries no accent.
expect(fields({ theme: 'minimal' })).toEqual([]);
});
it('refuses a site URL normaliseSiteUrl cannot use', () => {
for (const url of ['folio.example', 'ftp://folio.example', 'javascript:alert(1)']) {
expect(fields({ url })).toEqual(['url']);
expect(normaliseSiteUrl(url)).toBeNull();
}
for (const url of ['https://folio.example', 'http://folio.example/sub/', '', ' ']) {
expect(fields({ url })).toEqual([]);
}
});
it('refuses grid values outside the bounds getConfig clamps to', () => {
expect(fields({ grid: { columns: 9 } })).toEqual(['grid.columns']);
expect(fields({ grid: { columns: 0 } })).toEqual(['grid.columns']);
expect(fields({ grid: { columns: 2.5 } })).toEqual(['grid.columns']);
expect(fields({ grid: { gap: 49 } })).toEqual(['grid.gap']);
expect(fields({ grid: { gap: -1 } })).toEqual(['grid.gap']);
expect(fields({ grid: { columns: 1, gap: 0 } })).toEqual([]);
expect(fields({ grid: { columns: 6, gap: 48 } })).toEqual([]);
});
});