fix: stabilize rpg publish and launch
This commit is contained in:
@@ -15,7 +15,51 @@ import {
|
||||
import { RpgEntryCharacterSelectView } from './RpgEntryCharacterSelectView';
|
||||
|
||||
vi.mock('../../data/characterPresets', () => ({
|
||||
ROLE_TEMPLATE_CHARACTERS: [],
|
||||
ROLE_TEMPLATE_CHARACTERS: [
|
||||
{
|
||||
id: 'fallback-hero',
|
||||
name: '兜底侠',
|
||||
title: '默认角色',
|
||||
description: '兜底角色',
|
||||
backstory: '兜底背景',
|
||||
personality: '冷静 果断',
|
||||
gender: 'unknown',
|
||||
portrait: '/portraits/fallback.png',
|
||||
attributes: {
|
||||
strength: 8,
|
||||
agility: 8,
|
||||
intelligence: 8,
|
||||
spirit: 8,
|
||||
},
|
||||
attributeProfile: {
|
||||
schemaId: 'schema:custom:fallback',
|
||||
values: {
|
||||
axis_a: 8,
|
||||
axis_b: 8,
|
||||
axis_c: 8,
|
||||
axis_d: 8,
|
||||
axis_e: 8,
|
||||
axis_f: 8,
|
||||
},
|
||||
evidence: [],
|
||||
},
|
||||
attributeProfiles: {
|
||||
CUSTOM: {
|
||||
schemaId: 'schema:custom:fallback',
|
||||
values: {
|
||||
axis_a: 8,
|
||||
axis_b: 8,
|
||||
axis_c: 8,
|
||||
axis_d: 8,
|
||||
axis_e: 8,
|
||||
axis_f: 8,
|
||||
},
|
||||
evidence: [],
|
||||
},
|
||||
},
|
||||
skills: [],
|
||||
},
|
||||
],
|
||||
buildCustomWorldPlayableCharacters: vi.fn(),
|
||||
}));
|
||||
|
||||
@@ -190,3 +234,46 @@ test('custom world character selection stays stable when character ids are empty
|
||||
|
||||
expect(duplicateKeyCalls).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('custom world character selection falls back instead of rendering a blank screen when profile characters are malformed', () => {
|
||||
vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
||||
vi.mocked(buildCustomWorldPlayableCharacters).mockImplementation(() => {
|
||||
throw new TypeError('profile.playableNpcs is not iterable');
|
||||
});
|
||||
|
||||
render(
|
||||
<RpgEntryCharacterSelectView
|
||||
worldType={WorldType.CUSTOM}
|
||||
customWorldProfile={{
|
||||
id: 'broken-profile',
|
||||
name: '坏数据',
|
||||
attributeSchema: {
|
||||
id: 'schema:custom:fallback',
|
||||
worldId: 'broken-profile',
|
||||
schemaVersion: 1,
|
||||
generatedFrom: {
|
||||
worldType: WorldType.CUSTOM,
|
||||
worldName: '坏数据',
|
||||
settingSummary: '坏数据',
|
||||
tone: '测试',
|
||||
conflictCore: '测试',
|
||||
},
|
||||
slots: [
|
||||
{ slotId: 'axis_a', name: '骨势' },
|
||||
{ slotId: 'axis_b', name: '身法' },
|
||||
{ slotId: 'axis_c', name: '眼脉' },
|
||||
{ slotId: 'axis_d', name: '心焰' },
|
||||
{ slotId: 'axis_e', name: '尘缘' },
|
||||
{ slotId: 'axis_f', name: '玄息' },
|
||||
],
|
||||
},
|
||||
} as unknown as CustomWorldProfile}
|
||||
onBack={() => {}}
|
||||
onConfirm={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByText('选择你的角色')).toBeTruthy();
|
||||
expect(screen.getAllByText('兜底侠').length).toBeGreaterThan(0);
|
||||
expect(screen.getByRole('button', { name: /进入营地/u })).toBeTruthy();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user