import React from 'react'; import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { render, screen, waitFor, act, cleanup } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import '@testing-library/jest-dom/vitest'; import App from './App'; // Reuse the basic mocks vi.mock('./components/VisualizationPanel', () => ({ default: () =>
})); vi.mock('./components/ActionFeed', () => ({ default: () => })); vi.mock('./components/OverloadPanel', () => ({ default: () => })); vi.mock('./hooks/usePanZoom', () => ({ usePanZoom: () => ({ viewBox: null, setViewBox: vi.fn() }) })); const mockApi = vi.hoisted(() => ({ updateConfig: vi.fn().mockResolvedValue({ monitored_lines_count: 10, total_lines_count: 10 }), getBranches: vi.fn().mockResolvedValue({ branches: [], name_map: {} }), getVoltageLevels: vi.fn().mockResolvedValue({ voltage_levels: ['VL1'], name_map: {} }), getNominalVoltages: vi.fn().mockResolvedValue({ mapping: {}, unique_kv: [63, 225] }), getVoltageLevelSubstations: vi.fn().mockResolvedValue({ mapping: {} }), getNetworkDiagram: vi.fn().mockResolvedValue({ svg: '', metadata: null }), getUserConfig: vi.fn().mockResolvedValue({ network_path: '/path', action_file_path: '/path' }), getConfigFilePath: vi.fn().mockResolvedValue('/config'), saveUserConfig: vi.fn().mockResolvedValue({}), })); vi.mock('./api', () => ({ api: mockApi })); describe('Datalist performance clamping', () => { beforeEach(() => { vi.clearAllMocks(); }); afterEach(() => { cleanup(); }); it('exposes all branches through the contingency multi-select dropdown', async () => { // The legacy