125 lines
4.9 KiB
TypeScript
125 lines
4.9 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { normalizeCustomWorldProfileRecord } from './customWorldLibrary';
|
|
|
|
describe('normalizeCustomWorldProfileRecord role asset descriptions', () => {
|
|
it('保留草稿生成阶段产出的角色形象描述字段', () => {
|
|
const profile = normalizeCustomWorldProfileRecord({
|
|
name: '雾港归航',
|
|
settingText: '海雾旧案',
|
|
playableNpcs: [
|
|
{
|
|
name: '岑灯',
|
|
title: '返乡守灯人',
|
|
role: '主角代理',
|
|
description: '追查旧案的人',
|
|
visualDescription: '瘦高守灯人披深蓝旧雨衣,腰挂铜灯与卷边海图,眼下有长期失眠的青影。',
|
|
actionDescription: '抬灯照出雾中航线,侧身抽出卷边海图迅速标记。',
|
|
sceneVisualDescription: '旧灯塔石阶被潮水打湿,青白灯火照着雾中海图。',
|
|
},
|
|
],
|
|
storyNpcs: [
|
|
{
|
|
name: '议长甲',
|
|
title: '群岛议长',
|
|
role: '遮掩者',
|
|
description: '压住旧档的人',
|
|
visualDescription: '银发议长穿硬挺黑色长礼服,胸前别着海鸟徽章,手套边缘沾着档案灰。',
|
|
actionDescription: '用印信压住卷宗,抬手示意巡海队封锁出口。',
|
|
sceneVisualDescription: '议会厅高窗外翻涌海雾,长桌尽头堆着封存卷宗。',
|
|
},
|
|
],
|
|
});
|
|
|
|
expect(profile?.playableNpcs[0]?.visualDescription).toBe(
|
|
'瘦高守灯人披深蓝旧雨衣,腰挂铜灯与卷边海图,眼下有长期失眠的青影。',
|
|
);
|
|
expect(profile?.playableNpcs[0]?.actionDescription).toContain('抬灯');
|
|
expect(profile?.playableNpcs[0]?.sceneVisualDescription).toContain('旧灯塔');
|
|
expect(profile?.storyNpcs[0]?.visualDescription).toBe(
|
|
'银发议长穿硬挺黑色长礼服,胸前别着海鸟徽章,手套边缘沾着档案灰。',
|
|
);
|
|
expect(profile?.storyNpcs[0]?.actionDescription).toContain('印信');
|
|
expect(profile?.storyNpcs[0]?.sceneVisualDescription).toContain('议会厅');
|
|
});
|
|
|
|
it('保留 Agent 发布门槛需要的顶层 worldHook 和 playerPremise', () => {
|
|
const profile = normalizeCustomWorldProfileRecord({
|
|
name: '雾港归航',
|
|
settingText: '海雾旧案',
|
|
summary: '海雾会吞掉记错航线的人。',
|
|
worldHook: '在失真的海图上追查一场被篡改的沉船事故。',
|
|
playerPremise: '玩家是返乡调查旧案的守灯人。',
|
|
sceneChapterBlueprints: [
|
|
{
|
|
id: 'scene-chapter-1',
|
|
sceneId: 'landmark-1',
|
|
title: '失灯港',
|
|
acts: [
|
|
{
|
|
id: 'act-1',
|
|
title: '第一幕',
|
|
summary: '玩家在雾港发现灯册被改写。',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
});
|
|
|
|
expect(profile?.worldHook).toBe(
|
|
'在失真的海图上追查一场被篡改的沉船事故。',
|
|
);
|
|
expect(profile?.playerPremise).toBe('玩家是返乡调查旧案的守灯人。');
|
|
expect(profile?.sceneChapterBlueprints?.[0]?.acts).toHaveLength(1);
|
|
});
|
|
|
|
it('直接读取 Rust 草稿角色字段和形象资源', () => {
|
|
const profile = normalizeCustomWorldProfileRecord({
|
|
name: '雾港归航',
|
|
settingText: '海雾旧案',
|
|
playableNpcs: [
|
|
{
|
|
id: 'playable-cendeng',
|
|
name: '岑灯',
|
|
title: '返乡守灯人',
|
|
role: '主角代理',
|
|
publicMask: '深蓝旧雨衣、铜灯和卷边海图。',
|
|
currentPressure: '灯塔记录被人改写,旧案正在逼近。',
|
|
relationToPlayer: '这是玩家进入世界的第一视角。',
|
|
imageSrc: '/generated-characters/playable-cendeng/portrait.png',
|
|
generatedVisualAssetId: 'visual-playable-cendeng',
|
|
},
|
|
],
|
|
storyNpcs: [
|
|
{
|
|
id: 'story-yizhang',
|
|
name: '议长甲',
|
|
title: '群岛议长',
|
|
role: '遮掩者',
|
|
publicIdentity: '压住旧档的人。',
|
|
hiddenHook: '长期维持群岛议会体面并遮掩沉船旧案。',
|
|
relationToPlayer: '会阻止玩家继续追查。',
|
|
imageSrc: '/generated-characters/story-yizhang/portrait.png',
|
|
},
|
|
],
|
|
});
|
|
|
|
expect(profile?.playableNpcs[0]?.description).toBe(
|
|
'深蓝旧雨衣、铜灯和卷边海图。',
|
|
);
|
|
expect(profile?.playableNpcs[0]?.backstory).toContain('灯塔记录');
|
|
expect(profile?.playableNpcs[0]?.relationshipHooks[0]).toBe(
|
|
'这是玩家进入世界的第一视角。',
|
|
);
|
|
expect(profile?.playableNpcs[0]?.imageSrc).toBe(
|
|
'/generated-characters/playable-cendeng/portrait.png',
|
|
);
|
|
expect(profile?.storyNpcs[0]?.description).toBe('压住旧档的人。');
|
|
expect(profile?.storyNpcs[0]?.backstory).toContain('沉船旧案');
|
|
expect(profile?.storyNpcs[0]?.imageSrc).toBe(
|
|
'/generated-characters/story-yizhang/portrait.png',
|
|
);
|
|
});
|
|
});
|
|
|