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.
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
| 报告查看 | 真实集成 | `ReportView` 优先调用 `GET /api/reports/:id`,后端校验查看权限;页面渲染报告 HTML;只有开发/显式回退模式下 API 不可用才回退本地权限检查。 |
|
||||
| PDF 导出 | 真实集成 | 通过隐藏 iframe 或 `window.print()` 调用浏览器打印,用户手动保存为 PDF;不是后端 PDF 生成。 |
|
||||
| JSON 导出 | 真实可用 | Blob 下载结构化报告字段或模板包。 |
|
||||
| 模板管理 | 真实集成 | `TemplateManage` 优先调用 `/api/templates?access=manage`,新增/编辑/删除会写后端并清洗 HTML;字段库优先调用 `/api/library/fields`,模板图片资源优先调用 `/api/files`。导入导出仍主要在前端处理。 |
|
||||
| 模板管理 | 真实集成 | `TemplateManage` 优先调用 `/api/templates?access=manage`,新增/编辑/删除会写后端并清洗 HTML;新增后保存内容以当前页面模板列表为准并同步兼容缓存,避免旧本地缓存覆盖新模板;字段库优先调用 `/api/library/fields`,模板图片资源优先调用 `/api/files`。导入导出仍主要在前端处理。 |
|
||||
| 模板权限 | 真实集成 | 后端按部门模板、部门授权和个人模板过滤 `access=use/manage`;迁移期仍同步 `localStorage.templates`,仅在开发/显式回退模式下作为回退。 |
|
||||
| 我的个人模板 | 真实集成 | 医生在报告编辑器中保存个人模板时优先调用 `POST /api/templates`,后端把模板归属当前用户;只有开发/显式回退模式下 API 不可用才回退本地模板。 |
|
||||
| 用户管理 | 真实集成 | `UserManage` 优先调用 `/api/users` 增删改查,后端校验超级管理员/管理员范围、管理员唯一性和医生创建约束;只有开发/显式回退模式下 API 不可用才保留本地回退。 |
|
||||
@@ -66,6 +66,7 @@
|
||||
| `src/auth/backendUser.test.ts` | 后端用户 DTO 到前端兼容用户的角色和模板权限映射。 |
|
||||
| `src/pages/ReportManage.test.tsx` | 医生/管理员报告可见范围。 |
|
||||
| `src/utils/permissions.test.ts` | 报告权限、管理员本部门范围、医生个人模板和部门模板范围。 |
|
||||
| `src/utils/templateList.test.ts` | 模板列表合并,覆盖新增模板不被旧缓存覆盖。 |
|
||||
| `src/utils/storage.test.ts` | 本地存储、系统设置混淆兼容、会话恢复键、默认 Provider 不携带内置 Key 的契约。 |
|
||||
| `src/utils/defaultContent.test.ts` | 默认模板结构、智能字段、图片占位符、AI 区域、字段和 Provider 配置。 |
|
||||
| `src/utils/print.test.ts` | 浏览器打印导出入口。 |
|
||||
|
||||
Reference in New Issue
Block a user