import { fireEvent, render, screen } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import { Chat } from '@/pages/Chat';
import { TemplateProjectMenu } from '@/pages/Home/TemplateProjectMenu';
vi.mock('@/pages/Chat/OpencodeChatPanel', () => ({
OpencodeChatPanel: () =>
,
}));
describe('Home template menu', () => {
it('renders template project choices', () => {
render();
expect(screen.getByTestId('home-template-project-menu')).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Agent App' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Web App' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Desktop App' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'CLI Tool' })).toBeInTheDocument();
expect(screen.queryByTestId('mock-chat-panel')).not.toBeInTheDocument();
});
it('keeps the selected template item local to the home menu', () => {
render();
const agentTemplate = screen.getByRole('button', { name: 'Agent App' });
const cliTemplate = screen.getByRole('button', { name: 'CLI Tool' });
expect(agentTemplate).toHaveAttribute('aria-pressed', 'true');
expect(cliTemplate).toHaveAttribute('aria-pressed', 'false');
fireEvent.click(cliTemplate);
expect(agentTemplate).toHaveAttribute('aria-pressed', 'false');
expect(cliTemplate).toHaveAttribute('aria-pressed', 'true');
});
it('keeps the chat operation page separate from the home menu', () => {
render();
expect(screen.queryByTestId('home-template-project-menu')).not.toBeInTheDocument();
expect(screen.getByTestId('mock-chat-panel')).toBeInTheDocument();
});
it('lets the chat operation page fill the padded main content to the bottom edge', () => {
render();
const chatPage = screen.getByTestId('chat-operation-page');
expect(chatPage).toHaveClass('-m-6');
expect(chatPage).toHaveClass('h-[calc(100%_+_3rem)]');
});
});