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); });