diff --git a/tests/src/common/ut_metadataparser.cpp b/tests/src/common/ut_metadataparser.cpp index ef520b40..7a05f1da 100644 --- a/tests/src/common/ut_metadataparser.cpp +++ b/tests/src/common/ut_metadataparser.cpp @@ -80,7 +80,7 @@ TEST_F(UT_MetaDataParser, UT_MetaDataParser_makeMetaData_001) metadataparser.parse(metadata, noteData); metadata = ""; metadataparser.makeMetaData(noteData, metadata); - EXPECT_EQ("{\"dataCount\":1,\"noteDatas\":[{\"text\":\"sdfgsgssrgstg\",\"type\":1}],\"voiceMaxId\":0}", metadata) << "htmlCode is empty"; + EXPECT_EQ(QByteArrayLiteral("{\"dataCount\":1,\"noteDatas\":[{\"text\":\"sdfgsgssrgstg\",\"type\":1}],\"voiceMaxId\":0}"), metadata.toByteArray()) << "htmlCode is empty"; noteData->htmlCode = "abc"; metadataparser.makeMetaData(noteData, metadata); diff --git a/tests/src/importolddata/tiptapmigration/ut_migrationjsonbuilder.cpp b/tests/src/importolddata/tiptapmigration/ut_migrationjsonbuilder.cpp index 6eef419c..a58b7511 100644 --- a/tests/src/importolddata/tiptapmigration/ut_migrationjsonbuilder.cpp +++ b/tests/src/importolddata/tiptapmigration/ut_migrationjsonbuilder.cpp @@ -196,7 +196,7 @@ TEST(UT_MigrationJsonBuilder, GeneratedEnvelopePassesSchemaValidator) const QString path = writeTempEnvelope(envelope); QProcess validator; validator.setWorkingDirectory(findRepoRoot()); - validator.start(QStringLiteral("node"), { QStringLiteral("web-editor/scripts/validate-envelope.mjs"), path }); + validator.start(QStringLiteral("node"), { QStringLiteral("--import"), QStringLiteral("./web-editor/scripts/css-inline-loader.mjs"), QStringLiteral("web-editor/scripts/validate-envelope.mjs"), path }); ASSERT_TRUE(validator.waitForFinished(30000)); EXPECT_EQ(0, validator.exitCode()) << validator.readAllStandardError().toStdString(); QFile::remove(path); diff --git a/tests/src/importolddata/tiptapmigration/ut_migrationnotedataconverter.cpp b/tests/src/importolddata/tiptapmigration/ut_migrationnotedataconverter.cpp index 7a8d86fd..289ecda3 100644 --- a/tests/src/importolddata/tiptapmigration/ut_migrationnotedataconverter.cpp +++ b/tests/src/importolddata/tiptapmigration/ut_migrationnotedataconverter.cpp @@ -91,7 +91,7 @@ void expectPassesValidators(const QJsonObject &envelope) QProcess validator; validator.setWorkingDirectory(repoRoot); - validator.start(QStringLiteral("node"), { QStringLiteral("web-editor/scripts/validate-envelope.mjs"), envelopeFile.fileName() }); + validator.start(QStringLiteral("node"), { QStringLiteral("--import"), QStringLiteral("./web-editor/scripts/css-inline-loader.mjs"), QStringLiteral("web-editor/scripts/validate-envelope.mjs"), envelopeFile.fileName() }); ASSERT_TRUE(validator.waitForFinished(30000)); EXPECT_EQ(0, validator.exitCode()) << validator.readAllStandardError().toStdString(); } diff --git a/tests/src/task/ut_exportnoteworker.cpp b/tests/src/task/ut_exportnoteworker.cpp index 1cb95e21..080b8f13 100644 --- a/tests/src/task/ut_exportnoteworker.cpp +++ b/tests/src/task/ut_exportnoteworker.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -8,10 +8,12 @@ #include "common/vnoteitem.h" #include +#include #include void UT_ExportNoteWorker::SetUp() { + QDir().mkpath(QStringLiteral("test")); VNOTE_ALL_NOTES_MAP *notes = VNoteDataManager::instance()->getAllNotesInFolder(); if (notes && !notes->notes.isEmpty()) { VNOTE_ITEMS_MAP *tmp = notes->notes.first(); @@ -33,6 +35,7 @@ void UT_ExportNoteWorker::SetUp() void UT_ExportNoteWorker::TearDown() { delete note; + QDir("test").removeRecursively(); } UT_ExportNoteWorker::UT_ExportNoteWorker() diff --git a/web-editor/scripts/css-inline-loader.mjs b/web-editor/scripts/css-inline-loader.mjs new file mode 100644 index 00000000..0aaee15a --- /dev/null +++ b/web-editor/scripts/css-inline-loader.mjs @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +// Entry module for `node --import`: registers the CSS loader hook below so +// that validate-envelope.mjs can import create-schema.js (which transitively +// imports voice-block.css?inline) without a bundler. +import { register } from 'node:module'; +import { pathToFileURL } from 'node:url'; + +const hookURL = new URL('./css-loader-hook.mjs', import.meta.url); +register(pathToFileURL(hookURL.pathname)); diff --git a/web-editor/scripts/css-loader-hook.mjs b/web-editor/scripts/css-loader-hook.mjs new file mode 100644 index 00000000..2f77cfaa --- /dev/null +++ b/web-editor/scripts/css-loader-hook.mjs @@ -0,0 +1,17 @@ +// 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) { + if (url.includes('.css')) { + return { + format: 'module', + source: 'export default ""', + shortCircuit: true, + }; + } + return nextLoad(url, context); +}