diff --git a/docs/architecture/refactoring-master-plan.md b/docs/architecture/refactoring-master-plan.md index 19e3d3c..055e505 100644 --- a/docs/architecture/refactoring-master-plan.md +++ b/docs/architecture/refactoring-master-plan.md @@ -645,3 +645,4 @@ npm --prefix frontend run build | 2026-08-15 | 完成测试覆盖率提升切片“前端规则与领域状态边界补测” | 新增规则工具、账号运行态、批量任务、仪表盘、通知和聊天状态的确定性边界测试,覆盖默认值、空值、状态映射、过期响应、错误消息、SMTP 校验和时间格式化;前端 196 个测试、类型检查、注释门禁通过,全源语句覆盖率提升至 22.02%;页面组件与真实平台账号流程仍按覆盖率报告列为后续切片,不降低门禁或伪造 100% | 下一步:补齐 React 页面/Hook 行为测试,并继续覆盖 Browser 非账号错误分支 | | 2026-08-15 | 完成测试覆盖率提升切片“React 纯展示组件静态渲染覆盖” | 新增无需浏览器环境的静态渲染测试,覆盖卡密图标类型、批量阶段高亮、通知事件选中状态和订单筛选栏结构;前端 200 个测试、类型检查、注释门禁通过,全源语句覆盖率提升至 22.53%;交互回调和页面 Hook 仍需后续使用可控测试替身继续补齐,不降低门禁或伪造 100% | 下一步:补齐 React 页面/Hook 行为测试,并继续覆盖 Browser 非账号错误分支 | | 2026-08-15 | 完成测试覆盖率提升切片“React 通知与自动化异常组件分支覆盖” | 扩展静态渲染测试覆盖通知渠道空状态/停用/测试中状态,以及自动化运行异常和延迟任务的人工处理按钮;前端 202 个测试、类型检查、注释门禁通过,全源语句覆盖率提升至 23.00%;复杂表单交互与页面 Hook 仍需后续使用可控测试替身继续补齐,不降低门禁或伪造 100% | 下一步:补齐 React 页面/Hook 行为测试,并继续覆盖 Browser 非账号错误分支 | +| 2026-08-15 | 完成测试覆盖率提升切片“React SMTP 设置组件展示分支覆盖” | 新增 SMTP 设置面板静态渲染测试,覆盖密码显隐、保存中禁用状态、TLS/SSL 配置及发件人字段回填;前端 203 个测试、类型检查、注释门禁通过,全源语句覆盖率提升至 23.18%;表单事件回调和页面 Hook 仍需后续使用可控测试替身继续补齐,不降低门禁或伪造 100% | 下一步:补齐 React 页面/Hook 行为测试,并继续覆盖 Browser 非账号错误分支 | diff --git a/frontend/app/features/presentational-components.test.tsx b/frontend/app/features/presentational-components.test.tsx index ddb50ae..bfcd051 100644 --- a/frontend/app/features/presentational-components.test.tsx +++ b/frontend/app/features/presentational-components.test.tsx @@ -1,10 +1,12 @@ import ReactDOMServer from 'react-dom/server'; import { describe, expect, test } from 'vitest'; import type { NotificationChannel } from '../../types'; +import type { SystemSettings } from '../../types'; import { CardIcon } from './cards/components/CardIcon'; import { BatchPhaseIndicator } from './items/components/BatchPhaseIndicator'; import { NotificationChannelList } from './notifications/components/NotificationChannelList'; import { NotificationEventSelector } from './notifications/components/NotificationEventSelector'; +import { NotificationSmtpSettings } from './notifications/components/NotificationSmtpSettings'; import { OrderFilterBar } from './orders/components/OrderFilterBar'; import { AutomationIssuePanel } from './rules/components/AutomationIssuePanel'; import type { AutomationRunIssue, DeferredAutomationIssue } from './rules/api'; @@ -33,6 +35,15 @@ const noopRunResolution = (): void => undefined; // noopDeferredResolution 是静态渲染测试使用的延迟任务处理占位实现。 const noopDeferredResolution = (): void => undefined; +// noopSmtpUpdate 是静态渲染测试使用的 SMTP 配置更新占位实现。 +const noopSmtpUpdate = (): void => undefined; + +// noopPasswordToggle 是静态渲染测试使用的密码显隐更新占位实现。 +const noopPasswordToggle = (): void => undefined; + +// noopSmtpSave 是静态渲染测试使用的 SMTP 保存占位实现。 +const noopSmtpSave = (): void => undefined; + describe('前端纯展示组件', /* 当前回调处理无浏览器依赖的展示组件断言。 */ () => { test('卡密图标覆盖各交付类型', /* 当前回调处理库存图标类型分支。 */ () => { expect(render()).toContain('text-blue-500'); @@ -73,6 +84,21 @@ describe('前端纯展示组件', /* 当前回调处理无浏览器依赖的展 expect(list).toContain('animate-spin'); }); + test('SMTP 设置面板覆盖密码显隐和保存中状态', /* 当前回调处理系统邮件配置的展示分支。 */ () => { + // smtp 是覆盖 TLS/SSL 和发件人回填的系统邮件配置。 + const smtp: SystemSettings = { smtp_server: 'smtp.example.com', smtp_port: 465, smtp_user: 'sender@example.com', smtp_password: 'secret', smtp_use_tls: false, smtp_use_ssl: true }; + // hiddenMarkup 是密码隐藏且保存按钮可用时的静态 HTML。 + const hiddenMarkup = render(); + expect(hiddenMarkup).toContain('type="password"'); + expect(hiddenMarkup).toContain('保存 SMTP 配置'); + expect(hiddenMarkup).toContain('SMTP 邮件配置'); + // savingMarkup 是密码显示且请求执行中的静态 HTML。 + const savingMarkup = render(); + expect(savingMarkup).toContain('type="text"'); + expect(savingMarkup).toContain('保存中...'); + expect(savingMarkup).toContain('disabled'); + }); + test('自动化异常面板渲染运行异常和延迟任务操作', /* 当前回调处理人工核对面板的异常分支。 */ () => { // runIssue 是允许继续、重试和终止的运行异常。 const runIssue: AutomationRunIssue = { id: 1, cookie_id: 'account-1', order_id: 'order-1', trigger_type: 'order_paid', error_message: '发送结果未知', issue_kind: 'external_result_unknown', allowed_resolutions: ['continue', 'retry', 'cancel'], action_cursor: 1, sent_count: 1, updated_at: '2026-08-15T00:00:00Z' };