Files
immich-folio/app/admin/components/__tests__/settings-field-errors.test.tsx
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

75 lines
2.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// @vitest-environment jsdom
import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest';
import { render, screen, cleanup, fireEvent } from '@testing-library/react';
import SettingsEditor from '../SettingsEditor';
import { NotificationProvider } from '../Notifications';
import { ConfirmProvider } from '../ConfirmDialog';
const nav = vi.hoisted(() => ({ section: 'grid' }));
vi.mock('next/navigation', () => ({
useRouter: () => ({ refresh: () => {}, push: () => {}, replace: () => {} }),
useParams: () => ({ section: nav.section }),
usePathname: () => `/admin/settings/${nav.section}`,
}));
/**
* A value the site would ignore is named next to its input as it is typed,
* not only after a refused save (QA A-14).
*/
beforeEach(() => {
window.sessionStorage.clear();
vi.stubGlobal(
'fetch',
vi.fn(
async () =>
new Response(
JSON.stringify({ settings: { title: 'Folio' }, version: 'v1', envLocks: {} }),
{
status: 200,
},
),
),
);
});
afterEach(() => {
cleanup();
vi.unstubAllGlobals();
});
function mount() {
return render(
<NotificationProvider>
<ConfirmProvider>
<SettingsEditor />
</ConfirmProvider>
</NotificationProvider>,
);
}
describe('Settings form: values the site would ignore', () => {
it('marks grid columns outside 1–6 at the input', async () => {
nav.section = 'grid';
mount();
const columns = (await screen.findByLabelText(/Columns/)) as HTMLInputElement;
expect(columns.getAttribute('aria-invalid')).toBeNull();
fireEvent.change(columns, { target: { value: '9' } });
expect(columns.getAttribute('aria-invalid')).toBe('true');
const error = document.getElementById(columns.getAttribute('aria-describedby')!);
expect(error?.textContent).toBe('Must be a whole number from 1 to 6.');
fireEvent.change(columns, { target: { value: '4' } });
expect(columns.getAttribute('aria-invalid')).toBeNull();
});
it('marks an accent that is not hex', async () => {
nav.section = 'theme';
mount();
const accent = (await screen.findByLabelText('Accent colour (hex)')) as HTMLInputElement;
fireEvent.change(accent, { target: { value: 'rot' } });
expect(accent.getAttribute('aria-invalid')).toBe('true');
expect(screen.getByText('Must be a hex colour such as #e60012.')).toBeTruthy();
});
});