forked from cardosofelipe/fast-next-template
- Raise coverage thresholds to 90% statements/lines/functions, 85% branches - Add comprehensive tests for ProjectDashboard, ProjectWizard, and all wizard steps - Add tests for issue management: IssueDetailPanel, BulkActions, IssueFilters - Expand IssueTable tests with keyboard navigation, dropdown menu, edge cases - Add useIssues hook tests covering all mutations and optimistic updates - Expand eventStore tests with selector hooks and additional scenarios - Expand useProjectEvents tests with error recovery, ping events, edge cases - Add PriorityBadge, StatusBadge, SyncStatusIndicator fallback branch tests - Add constants.test.ts for comprehensive constant validation Bug fixes: - Fix false positive rollback test to properly verify onMutate context setup - Replace deprecated substr() with substring() in mock helpers - Fix type errors: ProjectComplexity, ClientMode enum values - Fix unused imports and variables across test files - Fix @ts-expect-error directives and method override signatures 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
153 lines
5.2 KiB
TypeScript
153 lines
5.2 KiB
TypeScript
/**
|
|
* AgentChatStep Component Tests
|
|
*
|
|
* Tests for the agent chat placeholder/preview step.
|
|
*/
|
|
|
|
import { render, screen } from '@testing-library/react';
|
|
import { AgentChatStep } from '@/components/projects/wizard/steps/AgentChatStep';
|
|
|
|
describe('AgentChatStep', () => {
|
|
describe('Rendering', () => {
|
|
it('renders the step title', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByText('Requirements Discovery')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders the Coming in Phase 4 badge', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByText('Coming in Phase 4')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders the description text', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByText(/chat with our product owner agent/i)).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders the Preview Only badge', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByText('Preview Only')).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
describe('Agent Info', () => {
|
|
it('displays Product Owner Agent title', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByText('Product Owner Agent')).toBeInTheDocument();
|
|
});
|
|
|
|
it('displays agent description', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByText('Requirements discovery and sprint planning')).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
describe('Mock Chat Messages', () => {
|
|
it('renders the chat log area', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByRole('log', { name: /chat preview messages/i })).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders agent messages', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByText(/i'm your product owner agent/i)).toBeInTheDocument();
|
|
expect(screen.getByText(/let me break this down into user stories/i)).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders user messages', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByText(/i want to build an e-commerce platform/i)).toBeInTheDocument();
|
|
});
|
|
|
|
it('displays message timestamps', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByText('10:00 AM')).toBeInTheDocument();
|
|
expect(screen.getByText('10:02 AM')).toBeInTheDocument();
|
|
expect(screen.getByText('10:03 AM')).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
describe('Chat Input', () => {
|
|
it('renders disabled chat input', () => {
|
|
render(<AgentChatStep />);
|
|
const input = screen.getByRole('textbox', { name: /chat input/i });
|
|
expect(input).toBeDisabled();
|
|
});
|
|
|
|
it('shows placeholder text', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByPlaceholderText(/disabled in preview/i)).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders disabled send button', () => {
|
|
render(<AgentChatStep />);
|
|
const sendButton = screen.getByRole('button', { name: /send message/i });
|
|
expect(sendButton).toBeDisabled();
|
|
});
|
|
|
|
it('shows preview disclaimer', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByText(/this chat interface is a preview/i)).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
describe('Full Version Preview Card', () => {
|
|
it('renders the preview card title', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByText('What to Expect in the Full Version')).toBeInTheDocument();
|
|
});
|
|
|
|
it('lists expected features', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByText(/interactive requirements gathering/i)).toBeInTheDocument();
|
|
expect(screen.getByText(/architecture spike/i)).toBeInTheDocument();
|
|
expect(screen.getByText(/collaborative backlog creation/i)).toBeInTheDocument();
|
|
expect(screen.getByText(/real-time refinement/i)).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
describe('Accessibility', () => {
|
|
it('icons have aria-hidden attribute', () => {
|
|
render(<AgentChatStep />);
|
|
const hiddenIcons = document.querySelectorAll('[aria-hidden="true"]');
|
|
expect(hiddenIcons.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it('chat log has appropriate role', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByRole('log')).toBeInTheDocument();
|
|
});
|
|
|
|
it('disabled input has accessible label', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByRole('textbox', { name: /chat input/i })).toBeInTheDocument();
|
|
});
|
|
|
|
it('disabled button has accessible label', () => {
|
|
render(<AgentChatStep />);
|
|
expect(screen.getByRole('button', { name: /send message/i })).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
describe('Visual elements', () => {
|
|
it('renders bot icons for agent messages', () => {
|
|
render(<AgentChatStep />);
|
|
const botIcons = document.querySelectorAll('.lucide-bot');
|
|
// Should have multiple bot icons (header + messages)
|
|
expect(botIcons.length).toBeGreaterThan(1);
|
|
});
|
|
|
|
it('renders user icon for user messages', () => {
|
|
render(<AgentChatStep />);
|
|
const userIcons = document.querySelectorAll('.lucide-user');
|
|
expect(userIcons.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it('renders sparkles icon for features preview', () => {
|
|
render(<AgentChatStep />);
|
|
const sparklesIcons = document.querySelectorAll('.lucide-sparkles');
|
|
expect(sparklesIcons.length).toBeGreaterThan(0);
|
|
});
|
|
});
|
|
});
|