import { expect, test } from '@playwright/test'; import { apiRequest, loginByApi, uniqueId } from './helpers'; test('doctor can save current report as a personal template visible only to self', async ({ page }) => { await loginByApi(page, '0001'); const templateName = `我的测试模板 ${uniqueId('tpl')}`; page.on('dialog', async (dialog) => { if (dialog.type() === 'prompt') { await dialog.accept(templateName); return; } await dialog.accept(); }); await page.goto('/report-editor'); await expect(page.getByRole('button', { name: '保存为我的模板' })).toBeVisible(); await page.getByRole('button', { name: '保存为我的模板' }).click(); await expect.poll(async () => { const data = await apiRequest<{ items: any[] }>(page.request, 'get', '/api/templates?access=use'); return data.items.some((template) => template.name === templateName && template.scope === 'personal' && template.ownerUser === '0001'); }).toBe(true); await expect(page.locator('option:not([disabled])', { hasText: templateName })).toHaveCount(1); });