Mediascherm: paneel Controle bibliotheek (read-check in gewone taal, stand van de schakelaars)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 23:36:05 +01:00
co-authored by Claude Sonnet 5.5
parent 30599c60ee
commit e1f2abf004
16 changed files with 237 additions and 6 deletions
@@ -339,6 +339,52 @@ describe('MediaLibraryPage', () => {
expect(within(dialog).getByTestId('cleanup-confirm')).toBeInTheDocument();
});
it('checks the library against the hero in plain words, with the state of the switches, only when asked', async () => {
let calls = 0;
server.use(
http.get('*/media-library/read-check', () => {
calls += 1;
return HttpResponse.json({ mode: 'compare', modules: [{ module: 'hero', mode: 'compare', photos: 11, uses: 8, matches: true, differences: [] }], copyOnStartup: true, dualWrite: true });
}),
);
renderPage();
await screen.findByTestId('photo-selection-list');
expect(calls).toBe(0);
expect(screen.queryByTestId('library-check-result')).not.toBeInTheDocument();
await userEvent.click(screen.getByTestId('library-check-run'));
expect(await screen.findByTestId('library-check-hero')).toHaveTextContent('De bibliotheek komt overeen met Hero (11 foto');
expect(screen.getByTestId('library-check-switches')).toHaveTextContent('kopie bij het opstarten: aan; schrijven naar de bibliotheek: aan; lezen uit de bibliotheek: vergelijken (alleen loggen)');
expect(calls).toBe(1);
});
it('lists the differences when the library does not match', async () => {
server.use(
http.get('*/media-library/read-check', () =>
HttpResponse.json({ mode: 'off', modules: [{ module: 'hero', mode: 'off', photos: 3, uses: 2, matches: false, differences: ['photo 1 is missing in the library', 'use 2 differs'] }], copyOnStartup: false, dualWrite: false }),
),
);
renderPage();
await screen.findByTestId('photo-selection-list');
await userEvent.click(screen.getByTestId('library-check-run'));
expect(await screen.findByTestId('library-check-hero')).toHaveTextContent('De bibliotheek wijkt af van Hero: 2 verschillen.');
expect(within(screen.getByTestId('library-check-hero-differences')).getAllByRole('listitem')).toHaveLength(2);
expect(screen.getByTestId('library-check-switches')).toHaveTextContent('kopie bij het opstarten: uit; schrijven naar de bibliotheek: uit; lezen uit de bibliotheek: uit');
});
it('says so when the check cannot be run', async () => {
server.use(http.get('*/media-library/read-check', () => new HttpResponse(null, { status: 500 })));
renderPage();
await screen.findByTestId('photo-selection-list');
await userEvent.click(screen.getByTestId('library-check-run'));
expect(await screen.findByTestId('library-check-error')).toHaveTextContent('De controle kon niet worden uitgevoerd.');
});
it('shows an error when the library cannot be loaded', async () => {
server.use(http.get('*/media-library/photos', () => new HttpResponse(null, { status: 500 })));
renderPage();