33 lines
1.9 KiB
TypeScript
33 lines
1.9 KiB
TypeScript
import { cleanup, render, screen } from '@testing-library/react'
|
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
import { ReportSummary } from '../../../src/components/ReportSummary'
|
|
|
|
afterEach(cleanup)
|
|
|
|
describe('ReportSummary', () => {
|
|
it('turns report data into decision metrics', () => {
|
|
render(<ReportSummary summary={{ selected_count: 11, processed_count: 11, error_count: 1, verdicts: { pass: 7, fail: 2, needs_human_review: 1, judge_format_error: 1 }, by_mode: { single_turn: { execution_statuses: { completed: 5, error: 1 }, verdicts: { pass: 4, fail: 1 } }, multi_turn: { execution_statuses: { completed: 5, error: 0 }, verdicts: { pass: 3, needs_human_review: 1, judge_format_error: 1 } } } }} />)
|
|
expect(screen.getByText('存在风险')).toHaveClass('result-tag-error')
|
|
expect(screen.getByText('已评估 11 / 11 条样例')).toBeInTheDocument()
|
|
expect(screen.getByText('single_turn · 6 条')).toBeInTheDocument()
|
|
expect(screen.getByText('执行错误').previousSibling).toHaveTextContent('1')
|
|
expect(screen.getByText('格式错误').previousSibling).toHaveTextContent('1')
|
|
expect(screen.queryByText('verdicts')).not.toBeInTheDocument()
|
|
})
|
|
|
|
it.each([
|
|
[{ verdicts: { needs_human_review: 2 } }, '需要人工复核'],
|
|
[{ verdicts: { pass: 3 } }, '未发现风险'],
|
|
[{}, '等待结论'],
|
|
])('shows the correct decision for %#', (summary, decision) => {
|
|
render(<ReportSummary summary={summary} />)
|
|
expect(screen.getByText(decision)).toBeInTheDocument()
|
|
})
|
|
|
|
it('counts modes from nested execution statuses', () => {
|
|
render(<ReportSummary summary={{ total_count: 5, processed_count: 5, verdicts: { pass: 3, fail: 1, needs_human_review: 1 }, by_mode: { multi_turn: { execution_statuses: { completed: 3, error: 2 }, verdicts: { pass: 2, fail: 1 } } } }} />)
|
|
expect(screen.getByText('已评估 5 / 5 条样例')).toBeInTheDocument()
|
|
expect(screen.getByText('multi_turn · 5 条')).toBeInTheDocument()
|
|
})
|
|
})
|