import { expect, test } from '@playwright/test'; import { apiRequest, loginByApi, uniqueId } from './helpers'; test('admin created template remains visible after saving content', async ({ page }) => { await loginByApi(page, 'admin'); const templateName = `E2E新增模板 ${uniqueId('tpl')}`; await page.goto('/template-manage'); await page.getByRole('button', { name: '新增模板' }).click(); await page.getByPlaceholder('请输入模板名称').fill(templateName); await page.getByPlaceholder('请输入模板描述').fill('新增后保存内容仍留在列表中'); await page.getByRole('button', { name: '保存模板信息' }).click(); await expect(page.getByText(templateName).first()).toBeVisible(); await page.getByRole('button', { name: '保存模板' }).click(); await expect(page.getByText(templateName).first()).toBeVisible(); await expect.poll(async () => { const data = await apiRequest<{ items: any[] }>(page.request, 'get', '/api/templates?access=manage'); return data.items.some((template) => template.name === templateName); }).toBe(true); });