From b7c002d6f3975408cd20a5ed54f5ac349bebbb88 Mon Sep 17 00:00:00 2001 From: Joywayer Date: Wed, 2 Sep 2026 08:05:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(scripts):=20xml-parser.test.mjs=20=E7=94=A8?= =?UTF-8?q?=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84=E4=BF=AE=20fixture=20ENOEN?= =?UTF-8?q?T=20(Task=202=20fix=20round=201)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legacy-layer-migration/xml-parser.test.mjs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cocoscreator_projects/framework-tests/legacy-layer-migration/xml-parser.test.mjs b/cocoscreator_projects/framework-tests/legacy-layer-migration/xml-parser.test.mjs index 4c54c47..94f2bfe 100644 --- a/cocoscreator_projects/framework-tests/legacy-layer-migration/xml-parser.test.mjs +++ b/cocoscreator_projects/framework-tests/legacy-layer-migration/xml-parser.test.mjs @@ -2,8 +2,12 @@ import { test } from 'node:test'; import assert from 'node:assert/strict'; import { readLayerXml } from '../../scripts/legacy-layer-to-cocos-prefab.mjs'; +// 绝对路径 -- tests 从 cocoscreator_projects/ 运行, 相对路径会解析到仓库根, +// 漏掉 cocoscreator_projects/ 段导致 ENOENT (Task 2 fix round 1 Finding 3). +const FIXTURE = 'G:/Works/YouleGamesCocosCreator/cocoscreator_projects/framework-tests/legacy-layer-migration/fixtures/Layer00002.xml'; + test('readLayerXml 解码 UTF-8 并提取 Layer00002 字段', () => { - const layer = readLayerXml('framework-tests/legacy-layer-migration/fixtures/Layer00002.xml'); + const layer = readLayerXml(FIXTURE); assert.equal(layer.layerId, '2'); assert.equal(layer.layerName, 'Login_Layer'); @@ -11,7 +15,7 @@ test('readLayerXml 解码 UTF-8 并提取 Layer00002 字段', () => { }); test('Spirit 字段完整提取(含中文名)', () => { - const layer = readLayerXml('framework-tests/legacy-layer-migration/fixtures/Layer00002.xml'); + const layer = readLayerXml(FIXTURE); const spirit405 = layer.spirits.find(s => s.id === '405'); assert.ok(spirit405, 'Spirit id=405 应存在'); assert.equal(spirit405.type, '0'); // Sprite @@ -30,7 +34,7 @@ test('Spirit 字段完整提取(含中文名)', () => { }); test('BelongGroupID 提取(group=0 节点也存在)', () => { - const layer = readLayerXml('framework-tests/legacy-layer-migration/fixtures/Layer00002.xml'); + const layer = readLayerXml(FIXTURE); for (const s of layer.spirits) { assert.ok(s.group !== undefined, `Spirit ${s.id} (${s.name}) 应有 group 字段`); }