test(title): 补标题工具函数单测,前端覆盖率从49.99%提升到50.15% #2056

Merged
auto-approve-bot merged 1 commits from test/title-utils-coverage-20260927 into develop 2026-09-27 00:45:24 +08:00
Owner

背景

staging 升级到 778b17a 后前端单测覆盖率 49.99%,差 0.01% 到 50% 阈值,CI 流水线标记 failure,E2E/Prod 部署被门控。

修复

新增 src/test/components/title/titleUtils.test.ts,13 个用例覆盖 components/title/utils.ts 和 components/title/constants.ts 中的 6 个工具函数:

  • getFontFamily:已知字体/未知字体回退/新增书法字体
  • getTitlePreset:合法 key/非法 key
  • titleStyleConfigToCamel:snake→camel 字段映射、空对象
  • camelToTitleStyleConfig:camel→snake 映射、两种转换往返一致性
  • buildPresetPreviewSettings:未知 key 透传 base、合法 preset 固定字号
  • templateToPreviewSettings:size 缩放逻辑、无 size 默认分支

覆盖率

指标 before after 阈值
lines 49.99% 50.15% 50% ✅
branches 65.44% 65.79% 50% ✅
functions 42.49% 43.05% 20% ✅

验证

  • npx vitest run:99 passed / 1 skipped(原 98+1,新增 13 个用例全部通过)
  • eslint 0 error
  • prettier 已格式化
  • 仅新增测试文件,无生产代码改动,零风险
## 背景 staging 升级到 778b17a 后前端单测覆盖率 49.99%,差 0.01% 到 50% 阈值,CI 流水线标记 failure,E2E/Prod 部署被门控。 ## 修复 新增 `src/test/components/title/titleUtils.test.ts`,13 个用例覆盖 `components/title/utils.ts` 和 `components/title/constants.ts` 中的 6 个工具函数: - `getFontFamily`:已知字体/未知字体回退/新增书法字体 - `getTitlePreset`:合法 key/非法 key - `titleStyleConfigToCamel`:snake→camel 字段映射、空对象 - `camelToTitleStyleConfig`:camel→snake 映射、两种转换往返一致性 - `buildPresetPreviewSettings`:未知 key 透传 base、合法 preset 固定字号 - `templateToPreviewSettings`:size 缩放逻辑、无 size 默认分支 ## 覆盖率 | 指标 | before | after | 阈值 | |---|---|---|---| | lines | 49.99% | **50.15%** | 50% ✅ | | branches | 65.44% | 65.79% | 50% ✅ | | functions | 42.49% | 43.05% | 20% ✅ | ## 验证 - `npx vitest run`:99 passed / 1 skipped(原 98+1,新增 13 个用例全部通过) - eslint 0 error - prettier 已格式化 - 仅新增测试文件,无生产代码改动,零风险
xiaoxia added 1 commit 2026-09-27 00:37:02 +08:00
test(title): 补标题工具函数单测,前端覆盖率从49.99%提升到50.15%
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 0s
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m7s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 1m14s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m16s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 2m54s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 3m1s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 4m16s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 4m41s
AI Code Review / AI Code Review (pull_request) Successful in 6m28s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 7m39s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 2s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 7m8s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 28s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 30s
d5cc43ae27
新增 src/test/components/title/titleUtils.test.ts 覆盖:
- getFontFamily: 已知字体/未知字体回退/新增书法字体
- getTitlePreset: 合法 key/非法 key
- titleStyleConfigToCamel: snake→camel 字段映射/空对象
- camelToTitleStyleConfig: camel→snake 映射/往返一致性
- buildPresetPreviewSettings: 未知 key 透传 base/合法 preset 固定字号
- templateToPreviewSettings: size 缩放逻辑/无 size 默认分支

覆盖率变化:
- lines: 49.99% → 50.15%(过50%阈值)
- branches: 65.44% → 65.79%
- functions: 42.49% → 43.05%
- Test Files: 99 passed / 1 skipped(全部通过)
auto-approve-bot approved these changes 2026-09-27 00:38:16 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot approved these changes 2026-09-27 00:38:16 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。

🚀 预览环境已部署

项目 详情
PR号 #2056
预览链接 https://pr-2056.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #2056 | | 预览链接 | [https://pr-2056.preview.xiaoxiajianji.com](https://pr-2056.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
auto-approve-bot merged commit 6778f4be32 into develop 2026-09-27 00:45:24 +08:00
auto-approve-bot deleted branch test/title-utils-coverage-20260927 2026-09-27 00:45:27 +08:00

🗑️ 预览环境已清理

PR #2056 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #2056 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.