mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 01:11:46 +03:00
fix: prevent trashing of trashed assets (#10028)
* 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
This commit is contained in:
34
web/src/lib/components/asset-viewer/delete-button.spec.ts
Normal file
34
web/src/lib/components/asset-viewer/delete-button.spec.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { type AssetResponseDto } from '@immich/sdk';
|
||||
|
||||
import { assetFactory } from '@test-data/factories/asset-factory';
|
||||
import '@testing-library/jest-dom';
|
||||
import { render } from '@testing-library/svelte';
|
||||
import DeleteButton from './delete-button.svelte';
|
||||
|
||||
let asset: AssetResponseDto;
|
||||
|
||||
describe('DeleteButton component', () => {
|
||||
describe('given an asset which is not trashed yet', () => {
|
||||
beforeEach(() => {
|
||||
asset = assetFactory.build({ isTrashed: false });
|
||||
});
|
||||
|
||||
it('displays a button to move the asset to the trash bin', () => {
|
||||
const { getByTitle, queryByTitle } = render(DeleteButton, { asset });
|
||||
expect(getByTitle('delete')).toBeInTheDocument();
|
||||
expect(queryByTitle('deletePermanently')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('but if the asset is already trashed', () => {
|
||||
beforeEach(() => {
|
||||
asset = assetFactory.build({ isTrashed: true });
|
||||
});
|
||||
|
||||
it('displays a button to permanently delete the asset', () => {
|
||||
const { getByTitle, queryByTitle } = render(DeleteButton, { asset });
|
||||
expect(getByTitle('permanently_delete')).toBeInTheDocument();
|
||||
expect(queryByTitle('delete')).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user