Files
Mdeical_Sur_Report/e2e/template-management.spec.ts
admin d61ee4f83a Fix new template disappearing after save
- Update TemplateManage save flows to use the current in-memory template list instead of stale localStorage as the source of truth.

- Merge current templates back into the compatibility cache so newly created backend templates are not dropped on content save.

- Add an accessible label for the new-template button to support reliable E2E coverage.

- Add template list merge unit tests covering stale-cache replacement and newly created templates.

- Add Playwright coverage for creating a template, saving template content, and confirming it remains visible and persisted.

- Update feature, progress, testing, and AGENTS documentation for the template management fix.
2026-05-02 03:42:41 +08:00

23 lines
1.1 KiB
TypeScript

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