25 lines
1.2 KiB
TypeScript
25 lines
1.2 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { act } from 'react';
|
|
import { createRoot } from 'react-dom/client';
|
|
import { expect, it, vi } from 'vitest';
|
|
import { ScoringMethodology } from '../../src/features/dashboard/ScoringMethodology';
|
|
|
|
it('discloses the mixed-method score and check basis in an operable dialog', () => {
|
|
(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
const container = document.createElement('div');
|
|
const root = createRoot(container);
|
|
const close = vi.fn();
|
|
try {
|
|
act(() => root.render(<ScoringMethodology onClose={close} sources={[{
|
|
tool: { id: 'synthetic', label: 'Synthetic source' }, score: 200 / 3, weight: 1, passed: 2, assessed: 3
|
|
}]} />));
|
|
const dialog = document.querySelector('[role="dialog"]')!;
|
|
expect(dialog.textContent).toContain('different methods');
|
|
expect(dialog.textContent).toContain('Rule 1.0.0');
|
|
expect(dialog.querySelector('tbody')?.textContent).toContain('66.67');
|
|
expect(dialog.querySelector('tbody')?.textContent).toContain('2 / 3 passed');
|
|
act(() => dialog.querySelector<HTMLButtonElement>('[aria-label="Close window"]')!.click());
|
|
expect(close).toHaveBeenCalledOnce();
|
|
} finally { act(() => root.unmount()); }
|
|
});
|