Files
Genarrative/src/components/rpg-entry/rpgEntryShared.test.ts
2026-04-28 19:36:39 +08:00

41 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import type { CustomWorldProfile } from '../../types';
import {
normalizeRpgEntryAgentBackedProfile,
stringifyRpgEntryAgentBackedProfile,
} from './rpgEntryShared';
describe('rpgEntryShared profile save boundary', () => {
it('does not rewrite settingText from creatorIntent on the frontend', () => {
const profile = {
id: 'cwprof_test',
settingText: '结果页用户正在编辑的草稿文案',
creatorIntent: {
worldHook: '海图会在午夜改写群岛航路',
playerPremise: '玩家是失忆领航员',
openingSituation: '正在禁航区醒来',
themeKeywords: ['海雾'],
toneDirectives: ['悬疑'],
coreConflicts: ['议会隐瞒沉船真相'],
keyCharacters: [
{
name: '顾潮音',
role: '守灯人',
relationToPlayer: '旧识',
hiddenHook: '掌握伪造海图',
},
],
iconicElements: ['会说谎的罗盘'],
},
} as CustomWorldProfile;
expect(normalizeRpgEntryAgentBackedProfile(profile)).toBe(profile);
expect(
JSON.parse(stringifyRpgEntryAgentBackedProfile(profile)),
).toMatchObject({
settingText: '结果页用户正在编辑的草稿文案',
});
});
});