Mediabibliotheek: verwijderen naar prullenbak in de UI, terugzetten, opruimen bevestigen, migratieplan, besluiten van Bryan in de docs
Continuous Integration / changes (pull_request) Successful in 14s
Continuous Integration / config-sls (pull_request) Successful in 9s
Continuous Integration / config-asf (pull_request) Successful in 8s
Continuous Integration / backend-test (pull_request) Canceled after 0s
Continuous Integration / frontend-prepare (pull_request) Canceled after 0s
Continuous Integration / frontend-build (pull_request) Canceled after 0s
Continuous Integration / frontend-test (pull_request) Canceled after 0s
Continuous Integration / frontend-lint (pull_request) Canceled after 0s
Continuous Integration / publish-sls-test (pull_request) Canceled after 0s
Continuous Integration / publish-sls-production (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-test (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-production (pull_request) Canceled after 0s
Continuous Integration / publish-asf-test (pull_request) Canceled after 0s
Continuous Integration / deploy-asf-test (pull_request) Canceled after 0s
Continuous Integration / smoke-sls-test (pull_request) Canceled after 0s
Continuous Integration / smoke-asf-test (pull_request) Canceled after 0s
Continuous Integration / backend-build (pull_request) Canceled after 48s
Continuous Integration / compile-sites (pull_request) Canceled after 52s
Continuous Integration / vulnerability-scan (pull_request) Canceled after 57s
Continuous Integration / changes (pull_request) Successful in 14s
Continuous Integration / config-sls (pull_request) Successful in 9s
Continuous Integration / config-asf (pull_request) Successful in 8s
Continuous Integration / backend-test (pull_request) Canceled after 0s
Continuous Integration / frontend-prepare (pull_request) Canceled after 0s
Continuous Integration / frontend-build (pull_request) Canceled after 0s
Continuous Integration / frontend-test (pull_request) Canceled after 0s
Continuous Integration / frontend-lint (pull_request) Canceled after 0s
Continuous Integration / publish-sls-test (pull_request) Canceled after 0s
Continuous Integration / publish-sls-production (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-test (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-production (pull_request) Canceled after 0s
Continuous Integration / publish-asf-test (pull_request) Canceled after 0s
Continuous Integration / deploy-asf-test (pull_request) Canceled after 0s
Continuous Integration / smoke-sls-test (pull_request) Canceled after 0s
Continuous Integration / smoke-asf-test (pull_request) Canceled after 0s
Continuous Integration / backend-build (pull_request) Canceled after 48s
Continuous Integration / compile-sites (pull_request) Canceled after 52s
Continuous Integration / vulnerability-scan (pull_request) Canceled after 57s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ 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 { seedPhotos, seedStorage } from '../mocks/handlers';
|
||||
import { MediaLibraryPage } from './MediaLibraryPage';
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -37,14 +37,14 @@ describe('MediaLibraryPage', () => {
|
||||
expect(await screen.findByTestId('storage-warning')).toHaveTextContent('vol');
|
||||
});
|
||||
|
||||
it('selects photos and shows the bulk bar without any delete action yet', async () => {
|
||||
it('selects photos and shows the bulk bar with the delete action', async () => {
|
||||
renderWithProviders(<MediaLibraryPage />);
|
||||
await screen.findByTestId('photo-selection-list');
|
||||
|
||||
await userEvent.click(screen.getAllByRole('checkbox', { name: /Foto 3000/ })[0]!);
|
||||
await userEvent.click(screen.getByRole('checkbox', { name: 'zomer.jpg' }));
|
||||
|
||||
expect(await screen.findByTestId('bulk-count')).toHaveTextContent('1 foto geselecteerd');
|
||||
expect(screen.queryByTestId('bulk-action-delete')).not.toBeInTheDocument();
|
||||
expect(screen.getByTestId('bulk-action-delete')).toHaveTextContent('Naar prullenbak');
|
||||
});
|
||||
|
||||
it('opens the clean-up: older than 7 days, only unused, all selected, newest first, and nothing is deleted', async () => {
|
||||
@@ -56,7 +56,7 @@ describe('MediaLibraryPage', () => {
|
||||
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');
|
||||
expect(within(dialog).getByTestId('cleanup-preview-note')).toHaveTextContent('prullenbak');
|
||||
const boxes = within(dialog).getAllByRole('checkbox', { name: /Foto/ });
|
||||
expect(boxes).toHaveLength(1);
|
||||
await waitFor(() => expect(boxes[0]).toBeChecked());
|
||||
@@ -75,6 +75,108 @@ describe('MediaLibraryPage', () => {
|
||||
expect(within(dialog).getAllByRole('checkbox', { name: /Foto/ })).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('moves an unused photo to the trash after one confirmation', async () => {
|
||||
let body: { ids: string[]; confirmedInUse: boolean } | null = null;
|
||||
server.use(
|
||||
http.post('*/media-library/delete', async ({ request }) => {
|
||||
body = (await request.json()) as { ids: string[]; confirmedInUse: boolean };
|
||||
return HttpResponse.json({ results: body.ids.map((id) => ({ id, status: 'trashed', uses: [] })) });
|
||||
}),
|
||||
);
|
||||
renderWithProviders(<MediaLibraryPage />);
|
||||
await screen.findByTestId('photo-selection-list');
|
||||
|
||||
await userEvent.click(screen.getByTestId('photo-select-hero:22222222-2222-2222-2222-222222222222'));
|
||||
await userEvent.click(screen.getByTestId('bulk-action-delete'));
|
||||
expect(await screen.findByTestId('delete-text')).toHaveTextContent('prullenbak');
|
||||
await userEvent.click(screen.getByTestId('delete-confirm'));
|
||||
|
||||
await waitFor(() => expect(screen.queryByTestId('delete-dialog')).not.toBeInTheDocument());
|
||||
expect(body).toEqual({ ids: ['hero:22222222-2222-2222-2222-222222222222'], confirmedInUse: false });
|
||||
});
|
||||
|
||||
it('asks a second confirmation that names the places for a photo in use', async () => {
|
||||
let body: { ids: string[]; confirmedInUse: boolean } | null = null;
|
||||
server.use(
|
||||
http.post('*/media-library/delete', async ({ request }) => {
|
||||
body = (await request.json()) as { ids: string[]; confirmedInUse: boolean };
|
||||
return HttpResponse.json({ results: body.ids.map((id) => ({ id, status: 'trashed', uses: [] })) });
|
||||
}),
|
||||
);
|
||||
renderWithProviders(<MediaLibraryPage />);
|
||||
await screen.findByTestId('photo-selection-list');
|
||||
|
||||
await userEvent.click(screen.getByTestId('photo-select-hero:11111111-1111-1111-1111-111111111111'));
|
||||
await userEvent.click(screen.getByTestId('bulk-action-delete'));
|
||||
expect(await screen.findByTestId('delete-inuse-count')).toHaveTextContent('1 foto wordt nog gebruikt');
|
||||
await userEvent.click(screen.getByTestId('delete-confirm'));
|
||||
|
||||
expect(await screen.findByTestId('delete-places')).toHaveTextContent('Hero, slide 1');
|
||||
expect(body).toBeNull();
|
||||
await userEvent.click(screen.getByTestId('delete-confirm'));
|
||||
|
||||
await waitFor(() => expect(body).toEqual({ ids: ['hero:11111111-1111-1111-1111-111111111111'], confirmedInUse: true }));
|
||||
});
|
||||
|
||||
it('reports photos that could not be deleted', async () => {
|
||||
server.use(
|
||||
http.post('*/media-library/delete', async ({ request }) => {
|
||||
const { ids } = (await request.json()) as { ids: string[] };
|
||||
return HttpResponse.json({ results: ids.map((id, i) => ({ id, status: i === 0 ? 'failed' : 'trashed', uses: [] })) });
|
||||
}),
|
||||
);
|
||||
renderWithProviders(<MediaLibraryPage />);
|
||||
await screen.findByTestId('photo-selection-list');
|
||||
|
||||
await userEvent.click(screen.getByTestId('photo-select-hero:22222222-2222-2222-2222-222222222222'));
|
||||
await userEvent.click(screen.getByTestId('photo-select-hero:33333333-3333-3333-3333-333333333333'));
|
||||
await userEvent.click(screen.getByTestId('bulk-action-delete'));
|
||||
await userEvent.click(screen.getByTestId('delete-confirm'));
|
||||
await userEvent.click(await screen.findByTestId('delete-confirm'));
|
||||
|
||||
expect(await screen.findByTestId('delete-partial')).toHaveTextContent('1 foto kon niet worden verwijderd');
|
||||
});
|
||||
|
||||
it('shows the trash and restores a photo', async () => {
|
||||
let restored: string[] = [];
|
||||
server.use(
|
||||
http.get('*/media-library/trash', () => HttpResponse.json({ photos: [{ ...seedPhotos()[1]!, deletedAt: new Date().toISOString() }], modules: ['hero'] })),
|
||||
http.post('*/media-library/restore', async ({ request }) => {
|
||||
restored = ((await request.json()) as { ids: string[] }).ids;
|
||||
return HttpResponse.json({ results: restored.map((id) => ({ id, status: 'restored', uses: [] })) });
|
||||
}),
|
||||
);
|
||||
renderWithProviders(<MediaLibraryPage />);
|
||||
await screen.findByTestId('photo-selection-list');
|
||||
|
||||
await userEvent.click(screen.getByTestId('view-trash'));
|
||||
expect(await screen.findByTestId('trash-note')).toBeInTheDocument();
|
||||
await userEvent.click(await screen.findByTestId('photo-select-hero:22222222-2222-2222-2222-222222222222'));
|
||||
await userEvent.click(screen.getByTestId('bulk-action-restore'));
|
||||
|
||||
await waitFor(() => expect(restored).toEqual(['hero:22222222-2222-2222-2222-222222222222']));
|
||||
});
|
||||
|
||||
it('confirming the clean-up moves exactly the selected photos to the trash', async () => {
|
||||
let body: { ids: string[]; confirmedInUse: boolean } | null = null;
|
||||
server.use(
|
||||
http.post('*/media-library/delete', async ({ request }) => {
|
||||
body = (await request.json()) as { ids: string[]; confirmedInUse: boolean };
|
||||
return HttpResponse.json({ results: body.ids.map((id) => ({ id, status: 'trashed', uses: [] })) });
|
||||
}),
|
||||
);
|
||||
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-confirm'));
|
||||
await userEvent.click(await screen.findByTestId('delete-confirm'));
|
||||
|
||||
await waitFor(() => expect(body).toEqual({ ids: ['hero:22222222-2222-2222-2222-222222222222'], confirmedInUse: false }));
|
||||
});
|
||||
|
||||
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 />);
|
||||
|
||||
Reference in New Issue
Block a user