Files
Mdeical_Sur_Report/e2e/report-ai-region.spec.ts
admin 7631ae34ce Sync inserted AI regions immediately
- Track report editor AI regions in React state instead of only scanning contentEditable DOM during render.

- Observe editor AI region mutations and refresh the AI writing target dropdown without requiring page navigation or refresh.

- Select newly inserted AI regions immediately after insertion and keep a live DOM fallback for generation.

- Harden AI region insertion so it still appends the region if execCommand has no active editor selection.

- Escape AI region names before injecting template HTML and add an accessible label for the insert button.

- Add Playwright coverage for inserting an AI region and seeing it immediately in the AI writing dropdown.

- Update report editor, feature, progress, testing, and AGENTS documentation for AI region synchronization.
2026-05-02 04:08:48 +08:00

26 lines
899 B
TypeScript

import { expect, test } from '@playwright/test';
import { loginByApi, uniqueId } from './helpers';
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);
});