Files
youle_cocos/cocoscreator_projects/framework-tests/legacy-layer-migration/poc-login.test.mjs
T
joywayer 36e593ecef test(scripts): PoC 阶段 3 - Login_Layer 端到端 _lpos 测试
参考 brief task-11-brief.md, 验证 Layer00002.xml → Login_Layer.prefab 在
渠道logo (Spirit405) + 游客登录 (Spirit177) 两个 anchor 节点 _lpos 误差 < 0.001.

测试目前因 ImgResID 427 (00427.png) 缺失 sprite 而 FAIL — 该 throw 属
'下游不兜底' 规则预期行为 (brief 已说明 ImgResID 107 也可能 throw). 详见
task-11-report.md.
2026-09-02 08:40:26 +08:00

45 lines
2.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { execSync } from 'node:child_process';
import { readFileSync } from 'node:fs';
// PoC 阶段 3 端到端: Layer00002.xml Login_Layer (18 spirits, group 2, 包含 Spirit405 渠道logo +
// Spirit177 游客登录 anchor-test cases). 验证生成 prefab 与 fixtures/Login_Layer.prefab 在
// 渠道logo + 游客登录两个 anchor 节点 _lpos 精度 < 0.001.
//
// 路径从 cocoscreator_projects/ 运行 (与 poc-protocol.test.mjs / poc-iconbutton.test.mjs 风格一致).
const CLI = 'node scripts/legacy-layer-to-cocos-prefab-cli.mjs';
const INPUT = '../projects/Game_Surface_3/save/Layer00002.xml';
const TARGET = 'YouleNexus/assets/framework/ui/prefabs/Login_Layer.prefab';
const OUTPUT_DIR = 'YouleNexus/out/legacy-migration/';
const OUTPUT = 'YouleNexus/out/legacy-migration/Login_Layer.prefab';
test('Login_Layer 端到端 - 渠道logo _lpos 误差 < 0.001', () => {
execSync(`${CLI} ${INPUT} ${TARGET} ${OUTPUT_DIR}`, { stdio: 'pipe' });
const generated = JSON.parse(readFileSync(OUTPUT, 'utf8'));
const expected = JSON.parse(readFileSync(TARGET, 'utf8'));
// 找渠道logo 节点(_name 包含"渠道")
const genLogo = generated.find(o => o.__type__ === 'cc.Node' && o._name && o._name.includes('渠道'));
const expLogo = expected.find(o => o.__type__ === 'cc.Node' && o._name && o._name.includes('渠道'));
assert.ok(genLogo, 'generated 缺渠道logo node');
assert.ok(expLogo, 'expected 缺渠道logo node');
assert.ok(Math.abs(genLogo._lpos.x - expLogo._lpos.x) < 0.001, `x mismatch: gen=${genLogo._lpos.x} exp=${expLogo._lpos.x}`);
assert.ok(Math.abs(genLogo._lpos.y - expLogo._lpos.y) < 0.001, `y mismatch: gen=${genLogo._lpos.y} exp=${expLogo._lpos.y}`);
});
test('Login_Layer 端到端 - 游客登录 _lpos 误差 < 0.001', () => {
execSync(`${CLI} ${INPUT} ${TARGET} ${OUTPUT_DIR}`, { stdio: 'pipe' });
const generated = JSON.parse(readFileSync(OUTPUT, 'utf8'));
const expected = JSON.parse(readFileSync(TARGET, 'utf8'));
const genVisitor = generated.find(o => o.__type__ === 'cc.Node' && o._name && o._name.includes('游客'));
const expVisitor = expected.find(o => o.__type__ === 'cc.Node' && o._name && o._name.includes('游客'));
assert.ok(genVisitor);
assert.ok(expVisitor);
assert.ok(Math.abs(genVisitor._lpos.x - expVisitor._lpos.x) < 0.001);
assert.ok(Math.abs(genVisitor._lpos.y - expVisitor._lpos.y) < 0.001);
});