refactor: 迁移视觉小说与木鱼 runtime 请求骨架
This commit is contained in:
@@ -10,10 +10,12 @@ vi.mock('../apiClient', () => ({
|
||||
requestJson: requestJsonMock,
|
||||
}));
|
||||
|
||||
import type { VisualNovelRunSnapshot } from '../../../packages/shared/src/contracts/visualNovel';
|
||||
import {
|
||||
buildVisualNovelRuntimeCheckpoint,
|
||||
buildVisualNovelSaveArchiveState,
|
||||
type VisualNovelRuntimeStreamOptions,
|
||||
getVisualNovelHistory,
|
||||
getVisualNovelRun,
|
||||
listVisualNovelGallery,
|
||||
listVisualNovelSaveArchives,
|
||||
putVisualNovelRuntimeSnapshot,
|
||||
@@ -21,8 +23,8 @@ import {
|
||||
resumeVisualNovelSaveArchive,
|
||||
startVisualNovelRun,
|
||||
streamVisualNovelRuntimeAction,
|
||||
type VisualNovelRuntimeStreamOptions,
|
||||
} from './visualNovelRuntimeClient';
|
||||
import type { VisualNovelRunSnapshot } from '../../../packages/shared/src/contracts/visualNovel';
|
||||
|
||||
function createMockRun(
|
||||
overrides: Partial<VisualNovelRunSnapshot> = {},
|
||||
@@ -108,6 +110,32 @@ test('startVisualNovelRun uses the visual novel runtime work route', async () =>
|
||||
);
|
||||
});
|
||||
|
||||
test('getVisualNovelRun and getVisualNovelHistory use encoded runtime run routes', async () => {
|
||||
requestJsonMock
|
||||
.mockResolvedValueOnce({ run: createMockRun() })
|
||||
.mockResolvedValueOnce({ entries: [] });
|
||||
|
||||
await getVisualNovelRun('vn/run-1');
|
||||
await getVisualNovelHistory('vn/run-1');
|
||||
|
||||
expect(requestJsonMock.mock.calls[0]).toEqual([
|
||||
'/api/runtime/visual-novel/runs/vn%2Frun-1',
|
||||
expect.objectContaining({ method: 'GET' }),
|
||||
'读取视觉小说运行快照失败',
|
||||
expect.objectContaining({
|
||||
retry: expect.objectContaining({ maxRetries: 1 }),
|
||||
}),
|
||||
]);
|
||||
expect(requestJsonMock.mock.calls[1]).toEqual([
|
||||
'/api/runtime/visual-novel/runs/vn%2Frun-1/history',
|
||||
expect.objectContaining({ method: 'GET' }),
|
||||
'读取视觉小说历史失败',
|
||||
expect.objectContaining({
|
||||
retry: expect.objectContaining({ maxRetries: 1 }),
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
test('streamVisualNovelRuntimeAction posts to the SSE action stream route', async () => {
|
||||
const response = createSseResponse(
|
||||
[
|
||||
@@ -146,6 +174,10 @@ test('streamVisualNovelRuntimeAction posts to the SSE action stream route', asyn
|
||||
}),
|
||||
signal: undefined,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
skipAuth: undefined,
|
||||
skipRefresh: undefined,
|
||||
}),
|
||||
);
|
||||
expect(result).toMatchObject({ runId: 'vn-run-route-1' });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user