import { test, expect } from '@playwright/test'; /** * EN: E2E tests for chat functionality * VI: E2E tests cho chức năng chat */ test.describe('Chat', () => { test.beforeEach(async ({ page }) => { // EN: Navigate to chat page (assuming authenticated) / VI: Điều hướng đến trang chat (giả sử đã authenticated) await page.goto('/chat'); }); test('should display chat interface', async ({ page }) => { // EN: Check for chat input with exact placeholder / VI: Kiểm tra chat input với placeholder chính xác await expect(page.getByPlaceholder('Type your message...')).toBeVisible(); }); test('should send message', async ({ page }) => { const input = page.getByPlaceholder('Type your message...'); // EN: Type into the textarea (controlled component) / VI: Nhập vào textarea (controlled component) await input.type('Test message'); // EN: Wait for send button to be enabled / VI: Đợi nút send được kích hoạt const sendButton = page.getByRole('button', { name: 'Send message' }); await expect(sendButton).toBeEnabled(); await sendButton.click(); // EN: Check if message appears / VI: Kiểm tra nếu tin nhắn xuất hiện // Note: This would require WebSocket mocking in actual implementation // Lưu ý: Điều này sẽ cần mock WebSocket trong implementation thực tế }); });