// ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. ========= // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. ========= import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import { SearchHistoryDialog } from '../../../src/components/SearchHistoryDialog'; // ---- Mocks ---- vi.mock('react-router-dom', () => ({ useNavigate: () => vi.fn(), })); vi.mock('@/hooks/useChatStoreAdapter', () => ({ default: () => ({ chatStore: { activeTaskId: undefined }, projectStore: { getProjectById: vi.fn(() => null), setHistoryId: vi.fn(), setActiveProject: vi.fn(), }, }), })); vi.mock('@/store/globalStore', () => ({ useGlobalStore: () => ({ history_type: 'list' }), })); const proxyFetchDeleteMock = vi.fn().mockResolvedValue({ code: 0 }); vi.mock('@/api/http', () => ({ proxyFetchDelete: (...args: any[]) => proxyFetchDeleteMock(...args), })); vi.mock('@/store/authStore', () => ({ getAuthStore: () => ({ email: 'test@example.com' }), })); vi.mock('@/service/historyApi', () => ({ fetchHistoryTasks: (setter: (tasks: any[]) => void) => { setter([ { id: '1', task_id: 'task-1', project_id: 'project-1', question: 'My history item', }, ]); }, })); vi.mock('@/components/ui/command', () => ({ CommandDialog: ({ open, children }: any) => open ?