|
| 1 | +import { describe, expect, it } from 'vitest' |
| 2 | +import { render, screen } from '@testing-library/react' |
| 3 | +import { SessionsTable } from './sessions-table' |
| 4 | +import type { DashboardInteractionSessionDto } from '../api-types' |
| 5 | + |
| 6 | +function makeSessionRow( |
| 7 | + overrides: Partial<DashboardInteractionSessionDto> = {}, |
| 8 | +): DashboardInteractionSessionDto { |
| 9 | + return { |
| 10 | + session_id: 'sess-1', |
| 11 | + branch: 'main', |
| 12 | + actor: { |
| 13 | + id: 'user-1', |
| 14 | + name: 'Jane Doe', |
| 15 | + email: 'jane@example.com', |
| 16 | + source: null, |
| 17 | + }, |
| 18 | + agent_type: 'claude-code', |
| 19 | + model: null, |
| 20 | + first_prompt: 'Fix the sessions table', |
| 21 | + started_at: '2025-02-14T10:00:00.000Z', |
| 22 | + ended_at: null, |
| 23 | + last_event_at: null, |
| 24 | + turn_count: 2, |
| 25 | + checkpoint_count: 1, |
| 26 | + token_usage: null, |
| 27 | + file_paths: [], |
| 28 | + tool_uses: [], |
| 29 | + linked_checkpoints: [], |
| 30 | + latest_commit_author: null, |
| 31 | + ...overrides, |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +describe('SessionsTable', () => { |
| 36 | + it('renders the actor column as Author', () => { |
| 37 | + render(<SessionsTable data={[makeSessionRow()]} />) |
| 38 | + expect( |
| 39 | + screen.getByRole('columnheader', { name: 'Author' }), |
| 40 | + ).toBeInTheDocument() |
| 41 | + expect( |
| 42 | + screen.queryByRole('columnheader', { name: 'Actor' }), |
| 43 | + ).not.toBeInTheDocument() |
| 44 | + }) |
| 45 | + |
| 46 | + it('renders actor name in the Author column', () => { |
| 47 | + render(<SessionsTable data={[makeSessionRow()]} />) |
| 48 | + expect(screen.getByText('Jane Doe')).toBeInTheDocument() |
| 49 | + }) |
| 50 | + |
| 51 | + it('renders empty state when data is empty', () => { |
| 52 | + render(<SessionsTable data={[]} />) |
| 53 | + expect( |
| 54 | + screen.getByText('No sessions for current filters.'), |
| 55 | + ).toBeInTheDocument() |
| 56 | + }) |
| 57 | +}) |
0 commit comments