fix(scripts): final review Critical+Important fixes (Widget alignment, full readLayerXml, Label _string, atlas selection, hard-coded paths, exit code, dead code removal)
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { join } from 'node:path';
|
||||
import { readLayerXml } from '../../scripts/legacy-layer-to-cocos-prefab.mjs';
|
||||
import { ROOT } from '../../scripts/lib/paths.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';
|
||||
const FIXTURE = join(ROOT, 'framework-tests', 'legacy-layer-migration', 'fixtures', 'Layer00002.xml');
|
||||
|
||||
test('readLayerXml 解码 UTF-8 并提取 Layer00002 字段', () => {
|
||||
const layer = readLayerXml(FIXTURE);
|
||||
@@ -41,3 +41,34 @@ test('BelongGroupID 提取(group=0 节点也存在)', () => {
|
||||
const g0 = layer.spirits.filter(s => s.group === '0');
|
||||
assert.ok(g0.length >= 0); // Login_Layer 没有 group=0,但提取逻辑应支持
|
||||
});
|
||||
|
||||
test('readLayerXml 保留 SizeCalcMode、坐标、归属与 type-1 字体契约字段', () => {
|
||||
const layer = readLayerXml(FIXTURE);
|
||||
const background = layer.spirits.find(s => s.id === '2');
|
||||
const text = layer.spirits.find(s => s.id === '285');
|
||||
assert.ok(background);
|
||||
assert.ok(text);
|
||||
|
||||
assert.equal(background.text, undefined);
|
||||
assert.equal(background.sizeCalcMode, '2');
|
||||
assert.equal(background.sizeParentID, '20');
|
||||
assert.equal(background.widthCalcMode, '1');
|
||||
assert.equal(background.heightCalcMode, '1');
|
||||
assert.equal(background.sizeRelaWidth, '10000');
|
||||
assert.equal(background.sizeRelaHeight, '10000');
|
||||
assert.equal(background.coordSelfPos, '0');
|
||||
assert.equal(background.coordRelaX, '0');
|
||||
assert.equal(background.coordRelaY, '0');
|
||||
assert.equal(background.coordParentID, '0');
|
||||
assert.equal(background.belongLayerID, '2');
|
||||
|
||||
assert.equal(text.text, '版本显示');
|
||||
assert.equal(text.fontSize, '18');
|
||||
assert.equal(text.fontColor, '16777215');
|
||||
assert.equal(text.alignHorz, '0');
|
||||
assert.equal(text.alignVert, '0');
|
||||
assert.equal(text.fontBold, '0');
|
||||
assert.equal(text.wordWrap, '0');
|
||||
assert.equal(text.lineSpace, '0');
|
||||
assert.equal(text.rowSpace, undefined);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user