mirror of
https://github.com/immich-app/immich.git
synced 2025-10-26 08:12:33 -04:00
* fix: prevent trashing of trashed assets Motivation ---------- This will improve user experience by hiding a pointless action. You can not trash a trashed asset again. It won't get any trashier than it already is. How to test ----------- 1. Visit route `/trash` 2. Click on an asset 3. Press "Delete" on your keyboard 4. Nothing happens 5. Try to find the trash button in the top right 6. You can't find it * refactor: follow @michelheusschen's review See: https://github.com/immich-app/immich/pull/10028#pullrequestreview-2105296755 * refactor: follow @michelheusschen's 2nd review See: https://github.com/immich-app/immich/pull/10028#discussion_r1632057833
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { resetSavedUser, user as userStore } from '$lib/stores/user.store';
|
|
import { assetFactory } from '@test-data/factories/asset-factory';
|
|
import { userAdminFactory } from '@test-data/factories/user-factory';
|
|
import '@testing-library/jest-dom';
|
|
import { render } from '@testing-library/svelte';
|
|
import AssetViewerNavBar from './asset-viewer-nav-bar.svelte';
|
|
|
|
describe('AssetViewerNavBar component', () => {
|
|
const additionalProps = {
|
|
showCopyButton: false,
|
|
showZoomButton: false,
|
|
showDetailButton: false,
|
|
showDownloadButton: false,
|
|
showMotionPlayButton: false,
|
|
showShareButton: false,
|
|
onZoomImage: () => {},
|
|
onCopyImage: () => {},
|
|
};
|
|
|
|
afterEach(() => {
|
|
vi.resetAllMocks();
|
|
resetSavedUser();
|
|
});
|
|
|
|
it('shows back button', () => {
|
|
const asset = assetFactory.build({ isTrashed: false });
|
|
const { getByTitle } = render(AssetViewerNavBar, { asset, ...additionalProps });
|
|
expect(getByTitle('go_back')).toBeInTheDocument();
|
|
});
|
|
|
|
describe('if the current user owns the asset', () => {
|
|
it('shows delete button', () => {
|
|
const ownerId = 'id-of-the-user';
|
|
const user = userAdminFactory.build({ id: ownerId });
|
|
const asset = assetFactory.build({ ownerId, isTrashed: false });
|
|
userStore.set(user);
|
|
const { getByTitle } = render(AssetViewerNavBar, { asset, ...additionalProps });
|
|
expect(getByTitle('delete')).toBeInTheDocument();
|
|
});
|
|
});
|
|
});
|