44 lines
2.3 KiB
JavaScript
44 lines
2.3 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { execSync } from 'node:child_process';
|
|
import { existsSync, readFileSync } from 'node:fs';
|
|
|
|
// PoC 阶段 1 端到端: Layer00619 BackHall_Layer (1 Spirit, type=3 ProgressBar) →
|
|
// prefab JSON + (diff, if any) → 关键字段校验.
|
|
//
|
|
// 注: 原 brief 建议 IconButton, 但 IconButton 无对应 Layer; spec 改用 BackHall_Layer
|
|
// 作为最简 1-Spirit PoC. Target YouleNexus prefab 不存在时 CLI 仅生成 prefab, 不报错.
|
|
//
|
|
// 路径从 cocoscreator_projects/ 运行 (与其他 legacy-layer-migration 测试一致).
|
|
const CLI = 'node scripts/legacy-layer-to-cocos-prefab-cli.mjs';
|
|
const INPUT = '../projects/Game_Surface_3/save/Layer00619.xml';
|
|
const TARGET = 'YouleNexus/assets/framework/ui/prefabs/widgets/Layer619_BackOtherGame.prefab';
|
|
const OUTPUT_DIR = 'YouleNexus/out/legacy-migration/';
|
|
const OUTPUT = 'YouleNexus/out/legacy-migration/BackHall_Layer.prefab';
|
|
|
|
test('Layer00619 端到端生成 + 校验关键字段', () => {
|
|
execSync(`${CLI} ${INPUT} ${TARGET} ${OUTPUT_DIR}`, { stdio: 'pipe' });
|
|
|
|
assert.ok(existsSync(OUTPUT), `${OUTPUT} 应生成`);
|
|
const json = JSON.parse(readFileSync(OUTPUT, 'utf8'));
|
|
assert.ok(Array.isArray(json));
|
|
assert.equal(json[0].__type__, 'cc.Prefab');
|
|
assert.equal(json[0]._name, 'BackHall_Layer');
|
|
|
|
// 校验含 group-55 父节点 (BackHall_Layer.xml Spirit BelongGroupID=55).
|
|
const groupNode = json.find(o => o.__type__ === 'cc.Node' && o._name === 'group-55');
|
|
assert.ok(groupNode, '应有 group-55 父节点');
|
|
});
|
|
|
|
test('Layer00619 端到端 - root._children 包含 group-55', () => {
|
|
execSync(`${CLI} ${INPUT} ${TARGET} ${OUTPUT_DIR}`, { stdio: 'pipe' });
|
|
const json = JSON.parse(readFileSync(OUTPUT, 'utf8'));
|
|
const rootNode = json.find(o => o.__type__ === 'cc.Node' && o._name === 'BackHall_Layer');
|
|
const groupNode = json.find(o => o.__type__ === 'cc.Node' && o._name === 'group-55');
|
|
assert.ok(rootNode, '应有 root node');
|
|
assert.ok(groupNode, '应有 group-55 node');
|
|
// The fix: root._children must reference group-55
|
|
const childIds = (rootNode._children || []).map(c => c.__id__);
|
|
assert.ok(childIds.includes(json.indexOf(groupNode)),
|
|
`root._children must include group-55 reference; got [${childIds.join(', ')}]`);
|
|
}); |