690522:0839 227 #02
This commit is contained in:
@@ -8,6 +8,7 @@ import { useEffect, useState } from 'react';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogFooter,
|
||||
@@ -101,6 +102,10 @@ export function FilePreviewModal({ attachment, onClose, onUnavailable }: FilePre
|
||||
</span>
|
||||
)}
|
||||
</DialogTitle>
|
||||
{/* sr-only: ซ่อนจาก UI แต่ screen reader อ่านได้ — จำเป็นสำหรับ Radix DialogContent */}
|
||||
<DialogDescription className="sr-only">
|
||||
{attachment?.originalFilename ?? t('filePreview.fallbackTitle')}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
{/* Body — Preview Area */}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// File: frontend/hooks/__tests__/use-ai-chat.test.ts
|
||||
// Change Log:
|
||||
// - 2026-05-19: สร้าง Unit Test สำหรับ useAiChat Hook
|
||||
// - 2026-05-22: แก้ act() warning ใน test ล้างประวัติ — ใช้ async act() แทน sync
|
||||
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { renderHook, waitFor, act } from '@testing-library/react';
|
||||
@@ -65,8 +66,9 @@ describe('useAiChat hook', () => {
|
||||
it('ควรสามารถล้างประวัติการสนทนาได้', async () => {
|
||||
const { wrapper } = createTestQueryClient();
|
||||
const { result } = renderHook(() => useAiChat(mockContext), { wrapper });
|
||||
act(() => {
|
||||
result.current.sendMessage('สวัสดี');
|
||||
// ใช้ async act() เพื่อให้ React flush state updates จาก sendMessage (Promise) ได้ครบ
|
||||
await act(async () => {
|
||||
void result.current.sendMessage('สวัสดี');
|
||||
});
|
||||
act(() => {
|
||||
result.current.clearHistory();
|
||||
|
||||
Reference in New Issue
Block a user