This commit is contained in:
51
packages/shared/src/contracts/rpgRuntimeContracts.test.ts
Normal file
51
packages/shared/src/contracts/rpgRuntimeContracts.test.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
import type { CharacterChatReplyRequest } from './rpgRuntimeChat';
|
||||
import { QUEST_NARRATIVE_TYPES } from './rpgRuntimeQuestAssist';
|
||||
import {
|
||||
SERVER_RUNTIME_FUNCTION_IDS,
|
||||
TASK5_RUNTIME_OPTION_SCOPES,
|
||||
TASK6_RUNTIME_FUNCTION_IDS,
|
||||
type RuntimeStoryActionRequest,
|
||||
} from './rpgRuntimeStoryAction';
|
||||
import type { RuntimeStoryStateRequest } from './rpgRuntimeStoryState';
|
||||
|
||||
describe('RPG runtime shared contracts', () => {
|
||||
test('拆分后的 runtime story action 契约继续导出常量与类型', () => {
|
||||
expect(SERVER_RUNTIME_FUNCTION_IDS).toContain('npc_chat');
|
||||
expect(TASK6_RUNTIME_FUNCTION_IDS).toContain('npc_trade');
|
||||
expect(TASK5_RUNTIME_OPTION_SCOPES).toEqual(['story', 'combat', 'npc']);
|
||||
|
||||
const request: RuntimeStoryActionRequest = {
|
||||
sessionId: 'runtime-session-1',
|
||||
action: {
|
||||
type: 'story_choice',
|
||||
functionId: 'npc_chat',
|
||||
},
|
||||
};
|
||||
|
||||
expect(request.action.functionId).toBe('npc_chat');
|
||||
});
|
||||
|
||||
test('拆分后的 chat 与 quest assist 契约继续导出运行时类型', () => {
|
||||
const payload: CharacterChatReplyRequest = {
|
||||
worldType: 'WUXIA',
|
||||
playerCharacter: {},
|
||||
targetCharacter: {},
|
||||
storyHistory: [],
|
||||
context: {},
|
||||
conversationHistory: [],
|
||||
conversationSummary: '测试摘要',
|
||||
playerMessage: '近况如何?',
|
||||
targetStatus: {},
|
||||
};
|
||||
|
||||
const stateRequest: RuntimeStoryStateRequest = {
|
||||
sessionId: 'runtime-session-2',
|
||||
};
|
||||
|
||||
expect(payload.playerMessage).toBe('近况如何?');
|
||||
expect(stateRequest.sessionId).toBe('runtime-session-2');
|
||||
expect(QUEST_NARRATIVE_TYPES).toContain('relationship');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user