fix(ut): 修复5个失败的单元测试用例,补全语音记事本单测首批 - #447
Conversation
There was a problem hiding this comment.
Sorry @pengfeixx, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
Warning
详情 {
"export": {
"web-editor/scripts/css-loader-hook.mjs": {
"b": [
"// string for the CSS module default export.",
"export async function load(url, context, nextLoad) {",
" source: 'export default \"\"',"
]
}
}
} |
Reviewer's GuideFixes five failing unit tests around metadata parsing, note export, and tiptap migration validation by correcting a QByteArray/QVariant comparison, ensuring the test export directory exists and is cleaned up, and enabling Node-based schema validators to import CSS inline modules via custom ESM loader hooks. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
- ut_metadataparser: 修复 EXPECT_EQ 类型不匹配(QVariant vs const char*) - ut_exportnoteworker: SetUp 创建 test 目录,TearDown 清理 - ut_migrationjsonbuilder/ut_migrationnotedataconverter: 为 node 验证器 添加 CSS inline loader,解决 voice-block.css 导入失败 本次修改6个文件,全部444个测试用例通过,无失败无崩溃。 函数覆盖率: 63.9% (661/1034) Refs: V-1329
b20c12c to
3edf1b7
Compare
|
Warning
详情 {
"export": {
"web-editor/scripts/css-loader-hook.mjs": {
"b": [
"// string for the CSS module default export.",
"export async function load(url, context, nextLoad) {",
" source: 'export default \"\"',"
]
}
}
} |
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // web-editor/scripts/css-loader-hook.mjs
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
// ESM loader hook: intercepts Vite-style CSS inline imports so that the
// validator can run under plain Node.js (no bundler). Returns an empty
// string for the CSS module default export.
export async function load(url, context, nextLoad) {
// 使用 URL 对象解析以提升匹配严谨性,避免对包含 .css 的非标准协议 URI 产生误判
try {
const urlObj = new URL(url);
if (urlObj.pathname.endsWith('.css')) {
return {
format: 'module',
source: 'export default ""',
shortCircuit: true,
};
}
} catch (e) {
// 若 URL 解析失败(如无效的本地路径传递),直接放行给下一个 loader 处理
}
return nextLoad(url, context);
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
背景
补充语音记事本单元测试,提升函数覆盖率至100%(Refs: V-1329)。
本批为第1批,目标:修复现有5个失败用例,确保全部用例无失败无崩溃。
修改内容(6个文件)
tests/src/common/ut_metadataparser.cpp — 修复
UT_MetaDataParser_makeMetaData_001:EXPECT_EQ类型不匹配(const char*vsQVariant),改用QByteArray比较。tests/src/task/ut_exportnoteworker.cpp — 修复
UT_ExportNoteWorker_exportAsHtml_001:导出路径test目录未创建导致写文件失败。SetUp创建目录,TearDown清理。tests/src/importolddata/tiptapmigration/ut_migrationjsonbuilder.cpp — 修复
GeneratedEnvelopePassesSchemaValidator:node 验证器导入voice-block.css?inline失败,添加 CSS inline loader。tests/src/importolddata/tiptapmigration/ut_migrationnotedataconverter.cpp — 修复
ComparesGoldenJsonAndPassesValidators、ConvertsVoiceBlockGoldenAndPassesValidators:同上 CSS 导入问题。web-editor/scripts/css-inline-loader.mjs(新增)— Node.js ESM loader 入口,注册 CSS 加载钩子,使
validate-envelope.mjs可在无 bundler 环境下导入含.css?inline的模块。web-editor/scripts/css-loader-hook.mjs(新增)— ESM load 钩子,将 CSS 导入返回为空字符串默认导出。
验证结果
后续计划
后续将分批次(每批5~7个文件)补充缺失测试,逐步提升函数覆盖率至100%,等待本批合入后再继续。
Summary by Sourcery
Fix failing unit tests for metadata parsing, note export, and tiptap migration validators, and introduce a Node.js CSS loader hook to allow schema validation scripts to run without a bundler.
Bug Fixes:
Enhancements: