diff --git a/docs/architecture/refactoring-master-plan.md b/docs/architecture/refactoring-master-plan.md index e82a64f..19e3d3c 100644 --- a/docs/architecture/refactoring-master-plan.md +++ b/docs/architecture/refactoring-master-plan.md @@ -644,3 +644,4 @@ npm --prefix frontend run build | 2026-08-15 | 完成测试覆盖率提升切片“确定性 Browser/命令入口覆盖与前端覆盖率采集” | 新增 Cookie 快照、浏览器池/持久化上下文、登录页、订单 DOM、滑块页面辅助、命令行入口测试;修复 Playwright 数值类型导致的登录成功误判;新增 Go `cover-browser`、前端 V8 `test:coverage` 与 Makefile 入口;普通 Go 全量覆盖率 70.9%,本地 Chromium 覆盖 Browser 约 60.0%,前端当前全源覆盖率为语句 19.22%;真实账号/外部平台流程仍明确不触网 | 下一步:按覆盖率报告继续补齐前端页面行为与 Browser 非账号错误分支,不降低门禁或伪造 100% | | 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 非账号错误分支 | diff --git a/frontend/app/features/presentational-components.test.tsx b/frontend/app/features/presentational-components.test.tsx index 24f4b51..ddb50ae 100644 --- a/frontend/app/features/presentational-components.test.tsx +++ b/frontend/app/features/presentational-components.test.tsx @@ -1,9 +1,13 @@ import ReactDOMServer from 'react-dom/server'; import { describe, expect, test } from 'vitest'; +import type { NotificationChannel } 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 { OrderFilterBar } from './orders/components/OrderFilterBar'; +import { AutomationIssuePanel } from './rules/components/AutomationIssuePanel'; +import type { AutomationRunIssue, DeferredAutomationIssue } from './rules/api'; // render 将 React 展示组件转换为静态 HTML,验证不依赖浏览器 DOM 的渲染分支。 const render = (element: React.ReactElement): string => ReactDOMServer.renderToStaticMarkup(element); @@ -20,6 +24,15 @@ const resolveAccountName = (id: string): string => id === 'account-1' ? '测试 // noopSearchChange 是静态渲染测试使用的订单搜索回调占位实现。 const noopSearchChange = (): void => undefined; +// noopChannelAction 是静态渲染测试使用的通知渠道操作占位实现。 +const noopChannelAction = (): void => undefined; + +// noopRunResolution 是静态渲染测试使用的自动化运行处理占位实现。 +const noopRunResolution = (): void => undefined; + +// noopDeferredResolution 是静态渲染测试使用的延迟任务处理占位实现。 +const noopDeferredResolution = (): void => undefined; + describe('前端纯展示组件', /* 当前回调处理无浏览器依赖的展示组件断言。 */ () => { test('卡密图标覆盖各交付类型', /* 当前回调处理库存图标类型分支。 */ () => { expect(render()).toContain('text-blue-500'); @@ -46,6 +59,36 @@ describe('前端纯展示组件', /* 当前回调处理无浏览器依赖的展 expect(selected).toContain('border-gray-100 hover:border-gray-300'); }); + test('通知渠道列表覆盖空列表、停用和测试中状态', /* 当前回调处理通知渠道摘要和操作状态。 */ () => { + // empty 是没有配置渠道时的空状态静态 HTML。 + const empty = render(); + expect(empty).toContain('还没有配置任何通知渠道'); + // channel 是覆盖配置摘要和停用展示的最小渠道对象。 + const channel: NotificationChannel = { id: 'channel-1', name: '测试 Bark', type: 'bark', config: { server_url: 'https://api.day.app', device_key: 'device-key' }, event_types: ['system_error'], enabled: false }; + // list 是渠道列表生成的静态 HTML。 + const list = render(); + expect(list).toContain('测试 Bark'); + expect(list).toContain('已停用'); + expect(list).toContain('系统错误'); + expect(list).toContain('animate-spin'); + }); + + 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' }; + // deferredIssue 是达到重试上限的延迟任务异常。 + const deferredIssue: DeferredAutomationIssue = { id: 2, cookie_id: 'account-1', trigger_type: 'review_missing_timeout', error_message: '任务重试失败', attempt_count: 3, updated_at: '2026-08-15T00:00:00Z' }; + // panel 是自动化异常面板生成的静态 HTML。 + const panel = render(); + expect(panel).toContain('需要人工处理的自动化任务'); + expect(panel).toContain('外部动作结果未知'); + expect(panel).toContain('已执行,继续下一步'); + expect(panel).toContain('未执行,安全重试'); + expect(panel).toContain('终止'); + expect(panel).toContain('重新入队'); + expect(panel).toContain('忽略'); + }); + test('订单筛选栏渲染状态、账号和关键词输入', /* 当前回调处理订单筛选工具栏的静态结构。 */ () => { // markup 是订单筛选栏生成的静态 HTML。 const markup = render(