1
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/* @vitest-environment node */
|
||||
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
const { requestJsonMock } = vi.hoisted(() => ({
|
||||
requestJsonMock: vi.fn(),
|
||||
}));
|
||||
|
||||
import { generateRpgWorldProfile } from './rpgCreationGenerationClient';
|
||||
|
||||
vi.mock('../apiClient', () => ({
|
||||
requestJson: requestJsonMock,
|
||||
}));
|
||||
|
||||
vi.mock('../ai', () => ({
|
||||
generateCustomWorldProfile: vi.fn(() => {
|
||||
throw new Error('不应再调用前端 legacy AI 生成链');
|
||||
}),
|
||||
}));
|
||||
|
||||
describe('rpgCreationGenerationClient node runtime', () => {
|
||||
beforeEach(() => {
|
||||
requestJsonMock.mockReset();
|
||||
requestJsonMock.mockResolvedValue({
|
||||
id: 'server-rs-profile-1',
|
||||
name: '服务端世界',
|
||||
subtitle: '副标题',
|
||||
summary: '概述',
|
||||
tone: '基调',
|
||||
playerGoal: '目标',
|
||||
settingText: '设定',
|
||||
});
|
||||
});
|
||||
|
||||
it('uses server-rs profile generation instead of importing legacy ai', async () => {
|
||||
const profile = await generateRpgWorldProfile('一个在 Node 测试中生成的世界');
|
||||
|
||||
expect(profile.id).toBe('server-rs-profile-1');
|
||||
expect(requestJsonMock).toHaveBeenCalledWith(
|
||||
'/api/runtime/custom-world/profile',
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
settingText: '一个在 Node 测试中生成的世界',
|
||||
}),
|
||||
}),
|
||||
'生成自定义世界失败',
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user