// @vitest-environment jsdom import { act } from 'react'; import { createRoot } from 'react-dom/client'; import { afterEach, describe, expect, it, vi } from 'vitest'; import { FindingReader } from '../../src/features/finding-reader/FindingReader'; import { makeSheet } from '../../src/importers/sheet-factory'; afterEach(() => { vi.unstubAllGlobals(); document.body.replaceChildren(); }); describe('Finding Reader heading actions', () => { it('places Bookmark first and Results last when a Work finding is opened', async () => { vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true); const container = document.createElement('div'); document.body.append(container); const root = createRoot(container); const record = makeSheet('Synthetic', [['Title', 'Status'], ['Synthetic finding', 'Failed']], '', 'synthetic.csv').analysis.records[0]; try { await act(async () => root.render( {}} onNext={() => {}} onReview={() => {}} onResults={() => {}}/>)); const actions = [...container.querySelector('.reader-heading-actions')!.children]; expect(actions[0].classList.contains('bookmark-label')).toBe(true); expect(actions[1].classList.contains('bookmark-btn')).toBe(true); expect(actions.at(-1)!.classList.contains('results-detail-btn')).toBe(true); } finally { await act(async () => root.unmount()); } }); });