Files
MindSift/frontend/src/features/workspace/__tests__/TrashView.test.tsx
T
sandrodachandClaude Opus 5.5 0fdf46635b test(frontend): task dialog, sharing avatars, trash, API key scopes, passwords (FLAW-19)
Covers opening and closing the task dialog (the former hook-order bug),
date/time fields and the view-only mode for viewer lists, the avatar
stack of shared items, the two-tap delete in the trash, scope selection
and badges of API keys, and the shared password rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 15:03:54 +01:00

31 lines
1.3 KiB
TypeScript

import { describe, it, expect, vi } from 'vitest';
import { render, screen, fireEvent, act } from '@testing-library/react';
import { TrashView } from '../TrashView';
const items = [
{ id: 'doc_1', title: 'Urlaub', icon: '🏔️', folderPath: 'Privat', deletedAt: '2026-10-29T08:00:00Z', isOwner: true },
];
describe('TrashView', () => {
it('deletes for good only on the second tap', async () => {
const onPurge = vi.fn(async () => {});
render(<TrashView items={items} onOpen={vi.fn()} onRestore={vi.fn(async () => {})} onPurge={onPurge} onEmpty={vi.fn(async () => {})} onBackMobile={vi.fn()} />);
fireEvent.click(screen.getByText('Endgültig löschen'));
expect(onPurge).not.toHaveBeenCalled();
await act(async () => {
fireEvent.click(screen.getByText('Wirklich löschen?'));
});
expect(onPurge).toHaveBeenCalledWith('doc_1');
});
it('restores with one tap and shows the original folder', async () => {
const onRestore = vi.fn(async () => {});
render(<TrashView items={items} onOpen={vi.fn()} onRestore={onRestore} onPurge={vi.fn(async () => {})} onEmpty={vi.fn(async () => {})} onBackMobile={vi.fn()} />);
expect(screen.getByText('Privat')).toBeTruthy();
await act(async () => {
fireEvent.click(screen.getByText('Wiederherstellen'));
});
expect(onRestore).toHaveBeenCalledWith('doc_1');
});
});