import React from 'react'; import { render, screen, waitFor, fireEvent } from '@testing-library/react'; import ExportDataModal from '../src/components/ExportDataModal'; import * as client from '../src/api/client'; jest.mock('../src/api/client', () => ({ experimentsApi: { getDailyStatuses: jest.fn() }, })); const animals = [ { id: 'a1', animal_name: 'Alpha', animal_id_string: 'R-001', subject_info: { grp: 'Control' } }, { id: 'a2', animal_name: 'Beta', animal_id_string: 'R-002', subject_info: { grp: 'Drug' } }, ]; const statuses = [ { animal_id: 'a1', date: '2026-07-01T00:00:00.000Z', analysis_summary: { total: 5 } }, { animal_id: 'a2', date: '2026-07-01T00:00:00.000Z', analysis_summary: { total: 9 } }, ]; const subjectTemplate = [{ fieldId: 'grp', label: 'Group', active: true }]; beforeEach(() => { jest.clearAllMocks(); client.experimentsApi.getDailyStatuses.mockResolvedValue(statuses); }); // Intercepts the Blob passed to URL.createObjectURL during handleExport so tests // can inspect the actual CSV text produced, rather than inferring it from the // 's DOM .value here would be misleading — React's // controlled