Mediabibliotheek: endpoints (foto's, opslag, opruimvoorbeeld) en scherm; ASF-verhoudingen in ontwerp en aannamelijst
Continuous Integration / config-asf (pull_request) Successful in 6s
Continuous Integration / config-sls (pull_request) Successful in 7s
Continuous Integration / changes (pull_request) Successful in 11s
Continuous Integration / compile-sites (pull_request) Successful in 1m44s
Continuous Integration / backend-build (pull_request) Successful in 1m49s
Continuous Integration / vulnerability-scan (pull_request) Successful in 1m51s
Continuous Integration / frontend-prepare (pull_request) Successful in 2m2s
Continuous Integration / frontend-build (pull_request) Successful in 42s
Continuous Integration / backend-test (pull_request) Failing after 3m56s
Continuous Integration / frontend-lint (pull_request) Successful in 39s
Continuous Integration / frontend-test (pull_request) Successful in 2m33s
Continuous Integration / publish-sls-test (pull_request) Skipped
Continuous Integration / publish-sls-production (pull_request) Skipped
Continuous Integration / deploy-sls-test (pull_request) Skipped
Continuous Integration / deploy-sls-production (pull_request) Skipped
Continuous Integration / publish-asf-test (pull_request) Skipped
Continuous Integration / deploy-asf-test (pull_request) Skipped
Continuous Integration / smoke-sls-test (pull_request) Skipped
Continuous Integration / smoke-asf-test (pull_request) Skipped
Continuous Integration / config-asf (pull_request) Successful in 6s
Continuous Integration / config-sls (pull_request) Successful in 7s
Continuous Integration / changes (pull_request) Successful in 11s
Continuous Integration / compile-sites (pull_request) Successful in 1m44s
Continuous Integration / backend-build (pull_request) Successful in 1m49s
Continuous Integration / vulnerability-scan (pull_request) Successful in 1m51s
Continuous Integration / frontend-prepare (pull_request) Successful in 2m2s
Continuous Integration / frontend-build (pull_request) Successful in 42s
Continuous Integration / backend-test (pull_request) Failing after 3m56s
Continuous Integration / frontend-lint (pull_request) Successful in 39s
Continuous Integration / frontend-test (pull_request) Successful in 2m33s
Continuous Integration / publish-sls-test (pull_request) Skipped
Continuous Integration / publish-sls-production (pull_request) Skipped
Continuous Integration / deploy-sls-test (pull_request) Skipped
Continuous Integration / deploy-sls-production (pull_request) Skipped
Continuous Integration / publish-asf-test (pull_request) Skipped
Continuous Integration / deploy-asf-test (pull_request) Skipped
Continuous Integration / smoke-sls-test (pull_request) Skipped
Continuous Integration / smoke-asf-test (pull_request) Skipped
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
import { screen, waitFor, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import i18n from '@/i18n/config';
|
||||
import { server } from '@/mocks/server';
|
||||
import { renderWithProviders } from '@/test/utils';
|
||||
import { seedStorage } from '../mocks/handlers';
|
||||
import { MediaLibraryPage } from './MediaLibraryPage';
|
||||
|
||||
beforeEach(async () => {
|
||||
await i18n.changeLanguage('nl');
|
||||
});
|
||||
|
||||
describe('MediaLibraryPage', () => {
|
||||
it('lists the photos newest first with where each is used, and the storage', async () => {
|
||||
renderWithProviders(<MediaLibraryPage />);
|
||||
|
||||
const list = await screen.findByTestId('photo-selection-list');
|
||||
const rows = within(list).getAllByRole('listitem');
|
||||
expect(rows).toHaveLength(3);
|
||||
expect(within(rows[0]!).getByText('Hero, slide 1')).toBeInTheDocument();
|
||||
expect(within(rows[1]!).getByText('Niet gebruikt')).toBeInTheDocument();
|
||||
expect(within(rows[2]!).getByText('Hero, slide 2 (uit)')).toBeInTheDocument();
|
||||
expect(await screen.findByTestId('storage-text')).toHaveTextContent('van');
|
||||
expect(screen.queryByTestId('storage-warning')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('warns when the storage is nearly full and says so when it is full', async () => {
|
||||
server.use(http.get('*/media-library/storage', () => HttpResponse.json({ ...seedStorage(), usedBytes: 1_800_000_000, level: 'warning' })));
|
||||
const { unmount } = renderWithProviders(<MediaLibraryPage />);
|
||||
expect(await screen.findByTestId('storage-warning')).toHaveTextContent('80%');
|
||||
unmount();
|
||||
|
||||
server.use(http.get('*/media-library/storage', () => HttpResponse.json({ ...seedStorage(), usedBytes: 2_147_483_648, level: 'full' })));
|
||||
renderWithProviders(<MediaLibraryPage />);
|
||||
expect(await screen.findByTestId('storage-warning')).toHaveTextContent('vol');
|
||||
});
|
||||
|
||||
it('selects photos and shows the bulk bar without any delete action yet', async () => {
|
||||
renderWithProviders(<MediaLibraryPage />);
|
||||
await screen.findByTestId('photo-selection-list');
|
||||
|
||||
await userEvent.click(screen.getAllByRole('checkbox', { name: /Foto 3000/ })[0]!);
|
||||
|
||||
expect(await screen.findByTestId('bulk-count')).toHaveTextContent('1 foto geselecteerd');
|
||||
expect(screen.queryByTestId('bulk-action-delete')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('opens the clean-up: older than 7 days, only unused, all selected, newest first, and nothing is deleted', async () => {
|
||||
renderWithProviders(<MediaLibraryPage />);
|
||||
await screen.findByTestId('photo-selection-list');
|
||||
|
||||
await userEvent.click(screen.getByTestId('cleanup-open'));
|
||||
|
||||
const dialog = await screen.findByTestId('cleanup-dialog');
|
||||
expect(within(dialog).getByTestId('cleanup-only-unused')).toBeChecked();
|
||||
expect(await within(dialog).findByTestId('cleanup-summary')).toHaveTextContent('1 foto');
|
||||
expect(within(dialog).getByTestId('cleanup-preview-note')).toHaveTextContent('nog niets verwijderd');
|
||||
const boxes = within(dialog).getAllByRole('checkbox', { name: /Foto/ });
|
||||
expect(boxes).toHaveLength(1);
|
||||
await waitFor(() => expect(boxes[0]).toBeChecked());
|
||||
});
|
||||
|
||||
it('includes photos in use when "only unused" is switched off', async () => {
|
||||
renderWithProviders(<MediaLibraryPage />);
|
||||
await screen.findByTestId('photo-selection-list');
|
||||
await userEvent.click(screen.getByTestId('cleanup-open'));
|
||||
const dialog = await screen.findByTestId('cleanup-dialog');
|
||||
await within(dialog).findByTestId('cleanup-summary');
|
||||
|
||||
await userEvent.click(within(dialog).getByTestId('cleanup-only-unused'));
|
||||
|
||||
await waitFor(() => expect(within(dialog).getByTestId('cleanup-summary')).toHaveTextContent('2 foto'));
|
||||
expect(within(dialog).getAllByRole('checkbox', { name: /Foto/ })).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('shows an error when the library cannot be loaded', async () => {
|
||||
server.use(http.get('*/media-library/photos', () => new HttpResponse(null, { status: 500 })));
|
||||
renderWithProviders(<MediaLibraryPage />);
|
||||
|
||||
expect(await screen.findByTestId('media-error')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user