When viewing a type in the sidebar, the note list now shows filter pills below the header to switch between Open, Archived, and Trashed notes. Each pill shows a count badge. Bulk actions are context-aware: Trashed filter offers Restore/Archive/Delete permanently, Archived filter offers Unarchive/Trash. Cmd+K commands added for switching filters. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
67 lines
2.8 KiB
TypeScript
67 lines
2.8 KiB
TypeScript
import { describe, it, expect, vi } from 'vitest'
|
|
import { render, screen, fireEvent } from '@testing-library/react'
|
|
import { BulkActionBar } from './BulkActionBar'
|
|
|
|
describe('BulkActionBar', () => {
|
|
const defaultProps = {
|
|
count: 3,
|
|
onArchive: vi.fn(),
|
|
onTrash: vi.fn(),
|
|
onRestore: vi.fn(),
|
|
onDeletePermanently: vi.fn(),
|
|
onClear: vi.fn(),
|
|
isTrashView: false,
|
|
}
|
|
|
|
it('shows Archive and Trash buttons in normal view', () => {
|
|
render(<BulkActionBar {...defaultProps} />)
|
|
expect(screen.getByTestId('bulk-archive-btn')).toBeInTheDocument()
|
|
expect(screen.getByTestId('bulk-trash-btn')).toBeInTheDocument()
|
|
expect(screen.queryByTestId('bulk-restore-btn')).not.toBeInTheDocument()
|
|
expect(screen.queryByTestId('bulk-delete-btn')).not.toBeInTheDocument()
|
|
})
|
|
|
|
it('shows Restore, Archive, and Delete permanently in trash view', () => {
|
|
render(<BulkActionBar {...defaultProps} isTrashView={true} />)
|
|
expect(screen.getByTestId('bulk-restore-btn')).toBeInTheDocument()
|
|
expect(screen.getByTestId('bulk-archive-btn')).toBeInTheDocument()
|
|
expect(screen.getByTestId('bulk-delete-btn')).toBeInTheDocument()
|
|
expect(screen.queryByTestId('bulk-trash-btn')).not.toBeInTheDocument()
|
|
})
|
|
|
|
it('calls onRestore when Restore button clicked in trash view', () => {
|
|
const onRestore = vi.fn()
|
|
render(<BulkActionBar {...defaultProps} isTrashView={true} onRestore={onRestore} />)
|
|
fireEvent.click(screen.getByTestId('bulk-restore-btn'))
|
|
expect(onRestore).toHaveBeenCalledTimes(1)
|
|
})
|
|
|
|
it('calls onDeletePermanently when Delete button clicked in trash view', () => {
|
|
const onDeletePermanently = vi.fn()
|
|
render(<BulkActionBar {...defaultProps} isTrashView={true} onDeletePermanently={onDeletePermanently} />)
|
|
fireEvent.click(screen.getByTestId('bulk-delete-btn'))
|
|
expect(onDeletePermanently).toHaveBeenCalledTimes(1)
|
|
})
|
|
|
|
it('shows selected count', () => {
|
|
render(<BulkActionBar {...defaultProps} count={5} />)
|
|
expect(screen.getByText('5 selected')).toBeInTheDocument()
|
|
})
|
|
|
|
it('shows Unarchive and Trash buttons in archived view', () => {
|
|
render(<BulkActionBar {...defaultProps} isArchivedView={true} />)
|
|
expect(screen.getByTestId('bulk-unarchive-btn')).toBeInTheDocument()
|
|
expect(screen.getByTestId('bulk-trash-btn')).toBeInTheDocument()
|
|
expect(screen.queryByTestId('bulk-archive-btn')).not.toBeInTheDocument()
|
|
expect(screen.queryByTestId('bulk-restore-btn')).not.toBeInTheDocument()
|
|
expect(screen.queryByTestId('bulk-delete-btn')).not.toBeInTheDocument()
|
|
})
|
|
|
|
it('calls onUnarchive when Unarchive button clicked in archived view', () => {
|
|
const onUnarchive = vi.fn()
|
|
render(<BulkActionBar {...defaultProps} isArchivedView={true} onUnarchive={onUnarchive} />)
|
|
fireEvent.click(screen.getByTestId('bulk-unarchive-btn'))
|
|
expect(onUnarchive).toHaveBeenCalledTimes(1)
|
|
})
|
|
})
|