import { expect, test } from '@playwright/test'; import { apiRequest, createReportByApi, loginByApi, uniqueId } from './helpers'; test('editing a completed report increments revision and preserves history', async ({ page }) => { await loginByApi(page, '0001'); const title = `已完成报告 ${uniqueId('revision')}`; const created = await createReportByApi(page.request, { title, patientName: '患者甲', hospitalId: uniqueId('H'), content: '
旧报告内容
', status: 'completed', }); await page.goto(`/report-editor?id=${created.id}`); await expect(page.getByText(`编辑报告: ${created.id}`)).toBeVisible(); await page.getByRole('textbox', { name: '患者姓名' }).fill('患者甲'); await page.getByRole('textbox', { name: '住院号' }).fill(created.hospitalId); await page.getByRole('button', { name: '完成报告' }).click(); await page.waitForURL('**/report-manage'); const data = await apiRequest<{ report: any }>(page.request, 'get', `/api/reports/${created.id}`); const report = data.report; expect(report.revision).toBe(2); expect(report.history).toHaveLength(1); expect(report.history[0].revision).toBe(1); });