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 父节点'); });