1
This commit is contained in:
@@ -451,4 +451,101 @@ describe('storyChoiceRuntime', () => {
|
||||
);
|
||||
expect(setGameState).toHaveBeenLastCalledWith(finalState);
|
||||
});
|
||||
|
||||
it('commits server-returned next-scene state after idle_travel_next_scene resolution', async () => {
|
||||
const gameState = createState({
|
||||
currentScenePreset: {
|
||||
id: 'wuxia-bamboo-road',
|
||||
name: '竹林古道',
|
||||
description: '风穿竹影,路面狭长。',
|
||||
imageSrc: '/scene-a.png',
|
||||
connectedSceneIds: ['wuxia-rain-street'],
|
||||
connections: [
|
||||
{
|
||||
sceneId: 'wuxia-rain-street',
|
||||
relativePosition: 'forward',
|
||||
summary: '沿石板路继续前行',
|
||||
},
|
||||
],
|
||||
forwardSceneId: 'wuxia-rain-street',
|
||||
treasureHints: [],
|
||||
npcs: [],
|
||||
},
|
||||
currentEncounter: {
|
||||
kind: 'npc',
|
||||
id: 'npc-bridge',
|
||||
npcName: '桥头行商',
|
||||
npcDescription: '正准备收摊离开的行商',
|
||||
npcAvatar: '桥',
|
||||
context: '桥口',
|
||||
hostile: false,
|
||||
},
|
||||
npcInteractionActive: true,
|
||||
});
|
||||
const setGameState = vi.fn();
|
||||
const setCurrentStory = vi.fn();
|
||||
|
||||
resolveServerRuntimeChoiceMock.mockResolvedValueOnce({
|
||||
hydratedSnapshot: {
|
||||
gameState: {
|
||||
...gameState,
|
||||
runtimeActionVersion: 3,
|
||||
currentScenePreset: {
|
||||
id: 'wuxia-rain-street',
|
||||
name: '夜雨长街',
|
||||
description: '雨丝压低灯火,街面反着潮光。',
|
||||
imageSrc: '/scene-b.png',
|
||||
connectedSceneIds: ['wuxia-bamboo-road'],
|
||||
connections: [
|
||||
{
|
||||
sceneId: 'wuxia-bamboo-road',
|
||||
relativePosition: 'back',
|
||||
summary: '可以沿原路退回竹林古道',
|
||||
},
|
||||
],
|
||||
forwardSceneId: 'wuxia-ferry-bridge',
|
||||
treasureHints: [],
|
||||
npcs: [],
|
||||
},
|
||||
currentEncounter: null,
|
||||
npcInteractionActive: false,
|
||||
sceneHostileNpcs: [],
|
||||
runtimeStats: {
|
||||
...gameState.runtimeStats,
|
||||
scenesTraveled: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
nextStory: createStory('服务端故事'),
|
||||
});
|
||||
|
||||
await runServerRuntimeChoiceAction({
|
||||
gameState,
|
||||
currentStory: createStory('当前故事'),
|
||||
option: createOption('idle_travel_next_scene'),
|
||||
character: createCharacter(),
|
||||
setBattleReward: vi.fn(),
|
||||
setAiError: vi.fn(),
|
||||
setIsLoading: vi.fn(),
|
||||
setGameState,
|
||||
setCurrentStory: setCurrentStory as (story: StoryMoment) => void,
|
||||
buildFallbackStoryForState: () => createStory('fallback'),
|
||||
});
|
||||
|
||||
expect(setGameState).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
currentScenePreset: expect.objectContaining({
|
||||
id: 'wuxia-rain-street',
|
||||
}),
|
||||
runtimeStats: expect.objectContaining({
|
||||
scenesTraveled: 1,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
expect(setCurrentStory).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
text: '服务端故事',
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user