From 4fec28ce8da110e92ae9275447f1fec798f321d2 Mon Sep 17 00:00:00 2001 From: aerospaceboy <790286734@qq.com> Date: Sun, 18 Oct 2026 12:17:11 +0800 Subject: [PATCH] fix: display canonical API failure labels in the grading page --- frontend/src/App.tsx | 1 + frontend/tests/batches.spec.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 8cbb27a..8b358dc 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -34,6 +34,7 @@ const pageTypeLabel = (value: string) => pageTypeLabels[value] || '未分类页 const statusLabels: Record = { pending: '待评分', scored: '模型已评分', reviewed: '教师已复核', needs_review: '待教师复核', unscorable: '材料缺失或解析失败', failed: '评分失败' }; const statusLabel = (value: string) => statusLabels[value] || value; const scoreStatusLabel = (row: any) => { + if (row.status_label) return row.status_label; if (row.status !== 'failed') return statusLabel(row.status); if (/模型证据|target_id|评分项或满分|JSON校验/.test(row.error || '')) return '模型输出校验失败'; if (/ConnectError|Timeout|Network|连接|超时|HTTP/i.test(row.error || '')) return '模型连接失败'; diff --git a/frontend/tests/batches.spec.ts b/frontend/tests/batches.spec.ts index 18f404a..aa0da22 100644 --- a/frontend/tests/batches.spec.ts +++ b/frontend/tests/batches.spec.ts @@ -140,12 +140,14 @@ test('failed scoring shows the network error and retry guidance on the page', as await page.route('**/api/projects/11/scores?*', route => route.fulfill({ json: { student_no: '9000000001', name: '学生甲', topic: '项目', totals: { overall: null }, facts: {}, rows: [{ criterion: { criterion_id: 'stage1.problem', category: 'stage1', name: '需求分析', max_score: 25 }, - status: 'failed', error: 'ConnectError:无法连接模型端点,请检查 Docker 网络、DNS 或代理', + status: 'failed', status_label: '模型连接失败', + error: '模型请求或JSON校验失败(ConnectError:无法连接模型端点,请检查 Docker 网络、DNS 或代理),已重试2次', evidence: [], missing_evidence: [], evidence_gaps: [] }], } })); await page.goto('/?page=scores&batch_id=71&project_id=11'); await expect(page.getByText('当前项目有 1 项评分失败', { exact: true })).toBeVisible(); await expect(page.getByText(/ConnectError:无法连接模型端点/)).toBeVisible(); + await expect(page.getByText('模型连接失败', { exact: true })).toBeVisible(); await expect(page.getByText(/已经成功的评分和教师复核会保留/)).toBeVisible(); });