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>
This commit is contained in:
1 parent
4c50d15915
commit
0fdf46635b
5 files changed
+174
No files matched your search
@@ -0,0 +1,70 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import { TaskDetailModal } from '../TaskDetailModal';
|
||||
import { Thought } from '../../../lib/types';
|
||||
|
||||
const task: Thought = {
|
||||
id: 'th_1',
|
||||
userId: 'usr_1',
|
||||
content: 'Fenster putzen',
|
||||
tags: [],
|
||||
priority: 'normal',
|
||||
source: 'manual',
|
||||
status: 'converted',
|
||||
isCompleted: false,
|
||||
kanbanStatus: 'todo',
|
||||
dueDate: '2026-10-30T14:30',
|
||||
createdAt: '2026-10-29T08:00:00Z',
|
||||
};
|
||||
const columns = [
|
||||
{ id: 'todo', name: 'Zu erledigen' },
|
||||
{ id: 'done', name: 'Erledigt', isDone: true },
|
||||
];
|
||||
const noop = vi.fn(async () => {});
|
||||
|
||||
const props = (over: Partial<React.ComponentProps<typeof TaskDetailModal>> = {}) => ({
|
||||
task,
|
||||
isOpen: true,
|
||||
onClose: vi.fn(),
|
||||
activeColumns: columns,
|
||||
taskLists: [],
|
||||
onUpdateTitle: noop,
|
||||
onUpdateStatus: noop,
|
||||
onUpdatePriority: noop,
|
||||
onUpdateDueDate: vi.fn(async () => {}),
|
||||
onUpdateTaskList: noop,
|
||||
onUpdateNotes: noop,
|
||||
onToggleSubtask: noop,
|
||||
onAddSubtask: noop,
|
||||
onDeleteSubtask: noop,
|
||||
onConvertToDoc: vi.fn(),
|
||||
onDeleteTask: vi.fn(),
|
||||
...over,
|
||||
});
|
||||
|
||||
describe('TaskDetailModal', () => {
|
||||
it('opens and closes without breaking the hook order', () => {
|
||||
const { rerender, container } = render(<TaskDetailModal {...props({ isOpen: false })} />);
|
||||
expect(container.firstChild).toBeNull();
|
||||
rerender(<TaskDetailModal {...props()} />);
|
||||
expect(screen.getByText('Aufgabe bearbeiten')).toBeTruthy();
|
||||
rerender(<TaskDetailModal {...props({ isOpen: false })} />);
|
||||
rerender(<TaskDetailModal {...props()} />);
|
||||
expect(screen.getByText('Aufgabe bearbeiten')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('shows date and time separately and removes only the time', () => {
|
||||
const onUpdateDueDate = vi.fn(async () => {});
|
||||
render(<TaskDetailModal {...props({ onUpdateDueDate })} />);
|
||||
expect((screen.getByLabelText('Fälligkeitsdatum') as HTMLInputElement).value).toBe('2026-10-30');
|
||||
expect((screen.getByLabelText('Uhrzeit (optional)') as HTMLInputElement).value).toBe('14:30');
|
||||
fireEvent.click(screen.getByTitle(/Uhrzeit entfernen/));
|
||||
expect(onUpdateDueDate).toHaveBeenCalledWith(task, '2026-10-30');
|
||||
});
|
||||
|
||||
it('is view-only for tasks in lists shared with viewer rights', () => {
|
||||
render(<TaskDetailModal {...props({ readOnly: true })} />);
|
||||
expect(screen.getByText('Aufgabe ansehen')).toBeTruthy();
|
||||
expect((screen.getByLabelText('Fälligkeitsdatum') as HTMLInputElement).closest('fieldset')?.disabled).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user