Files
Mdeical_Sur_Report/e2e/report-ai-region.spec.ts
admin 3774657ef5 Refresh AI region list after editor content loads
- Extract AI region scanning into a reusable utility with unit coverage.

- Refresh AI region dropdown state after drafts, reports, default templates, and selected templates write HTML into the editor.

- Keep the existing MutationObserver path for later DOM edits and inserted AI regions.

- Add E2E coverage for existing template AI regions appearing on initial report editor load.

- Update README, AGENTS, report editor, progress, and testing docs for AI region synchronization behavior.
2026-05-02 04:57:00 +08:00

39 lines
1.4 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { loginByApi, uniqueId } from './helpers';
test('existing template AI region appears in the AI writing target dropdown on page load', async ({ page }) => {
await loginByApi(page, '0001');
await page.goto('/report-editor');
await page.getByRole('button', { name: 'AI撰写' }).click();
const aiRegionSelect = page.locator('select').filter({
has: page.locator('option', { hasText: '手术步骤、术中出现的情况及处理' }),
});
await expect(aiRegionSelect).toHaveValue('手术步骤');
await expect(page.locator('select option', { hasText: '无可用 AI 区域' })).toHaveCount(0);
});
test('newly inserted AI region appears in the AI writing target dropdown immediately', async ({ page }) => {
await loginByApi(page, '0001');
const regionName = `AI区域${uniqueId('region')}`;
page.on('dialog', async (dialog) => {
if (dialog.type() === 'prompt') {
await dialog.accept(regionName);
return;
}
await dialog.accept();
});
await page.goto('/report-editor');
await page.getByTitle('插入AI可编辑区域').click();
await page.getByRole('button', { name: 'AI撰写' }).click();
const aiRegionSelect = page.locator('select').filter({
has: page.locator('option', { hasText: regionName }),
});
await expect(aiRegionSelect).toHaveValue(regionName);
await expect(page.locator('select option', { hasText: regionName })).toHaveCount(1);
});