(cherry picked from commit 2576ee28cfb790e99ddf401a129e1d9a18713121)
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
import { renderWithTooltips } from '#tests/helpers';
|
|
import type { AssetResponseDto } from '@immich/sdk';
|
|
import '@testing-library/jest-dom';
|
|
import { assetFactory } from '#test-data/factories/asset-factory';
|
|
import DeleteAction from './DeleteAction.svelte';
|
|
|
|
vi.mock(import('#lib/managers/feature-flags-manager.svelte.js'), () => {
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
return { featureFlagsManager: { init: vi.fn(), loadFeatureFlags: vi.fn(), value: { trash: true } } as any };
|
|
});
|
|
|
|
let asset: AssetResponseDto;
|
|
|
|
describe('DeleteAction 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 { getByLabelText, queryByTitle } = renderWithTooltips(DeleteAction, {
|
|
asset,
|
|
onAction: vi.fn(),
|
|
preAction: vi.fn(),
|
|
});
|
|
// @ts-expect-error pending a type fix: https://github.com/testing-library/jest-dom/pull/742/changes
|
|
expect(getByLabelText('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 { getByLabelText, queryByTitle } = renderWithTooltips(DeleteAction, {
|
|
asset,
|
|
onAction: vi.fn(),
|
|
preAction: vi.fn(),
|
|
});
|
|
// @ts-expect-error pending a type fix: https://github.com/testing-library/jest-dom/pull/742/changes
|
|
expect(getByLabelText('permanently_delete')).toBeInTheDocument();
|
|
expect(queryByTitle('delete')).toBeNull();
|
|
});
|
|
});
|
|
});
|