Files
immich-folio/app/admin/__tests__/AdminOverview.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

59 lines
2.1 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, afterEach, vi } from 'vitest';
import { render, screen, cleanup, waitFor } from '@testing-library/react';
import AdminOverview from '../components/AdminOverview';
afterEach(() => {
cleanup();
vi.unstubAllGlobals();
});
/** Every admin endpoint answers 404 except gallery.yaml, which holds `gallery`. */
function stubGallery(gallery: unknown) {
vi.stubGlobal(
'fetch',
vi.fn(async (url: string) =>
url === '/api/admin/gallery'
? new Response(JSON.stringify({ gallery, version: 'v' }), { status: 200 })
: new Response(JSON.stringify({ error: 'nope' }), { status: 404 }),
),
);
}
/** The "Pages" tile: its number and the note under it, once loaded. */
async function pagesTile() {
const label = await screen.findByText('Pages');
const tile = label.closest('a')!;
const value = () => tile.querySelector('.overview-stat-value')!.textContent;
await waitFor(() => expect(value()).not.toBe('–'));
return { value: value(), note: tile.querySelector('.overview-stat-note')!.textContent };
}
describe('AdminOverview — Pages tile', () => {
it('counts subpages written in the older map form of gallery.yaml', async () => {
// `subpages:` as a map of name → albums (or name → object) is still a
// valid gallery.yaml — getConfig() and the page builder both read it.
// The overview called .filter() on it, and the first admin screen crashed.
stubGallery({
subpages: {
Weddings: ['11111111-1111-4111-8111-111111111111'],
Travel: { albums: ['22222222-2222-4222-8222-222222222222'], enabled: false },
},
});
render(<AdminOverview />);
expect(await pagesTile()).toEqual({ value: '1', note: '1 switched off' });
});
it('leaves content-page menu entries out of the list form', async () => {
stubGallery({
subpages: [
{ name: 'Weddings', albums: ['11111111-1111-4111-8111-111111111111'] },
{ page: 'pricing' },
{ name: 'Old', albums: [], enabled: false },
],
});
render(<AdminOverview />);
expect(await pagesTile()).toEqual({ value: '1', note: '1 switched off' });
});
});