This commit is contained in:
2026-04-29 20:56:59 +08:00
parent fb6f455530
commit 730f485f48
200 changed files with 9881 additions and 2221 deletions

View File

@@ -0,0 +1,52 @@
import { beforeEach, expect, test, vi } from 'vitest';
const { requestJsonMock } = vi.hoisted(() => ({
requestJsonMock: vi.fn(),
}));
vi.mock('../apiClient', () => ({
requestJson: requestJsonMock,
}));
import { getPuzzleGalleryDetail, listPuzzleGallery } from './puzzleGalleryClient';
beforeEach(() => {
requestJsonMock.mockReset();
requestJsonMock.mockResolvedValue({ items: [] });
});
test('listPuzzleGallery reads public gallery without auth refresh coupling', async () => {
await listPuzzleGallery();
expect(requestJsonMock).toHaveBeenCalledWith(
'/api/runtime/puzzle/gallery',
expect.objectContaining({ method: 'GET' }),
'读取拼图广场失败',
expect.objectContaining({
retry: expect.objectContaining({ maxRetries: 1 }),
skipAuth: true,
skipRefresh: true,
}),
);
});
test('getPuzzleGalleryDetail reads public detail without auth refresh coupling', async () => {
requestJsonMock.mockResolvedValueOnce({
item: {
profileId: 'puzzle-profile-1',
},
});
await getPuzzleGalleryDetail('puzzle-profile-1');
expect(requestJsonMock).toHaveBeenCalledWith(
'/api/runtime/puzzle/gallery/puzzle-profile-1',
expect.objectContaining({ method: 'GET' }),
'读取拼图广场详情失败',
expect.objectContaining({
retry: expect.objectContaining({ maxRetries: 1 }),
skipAuth: true,
skipRefresh: true,
}),
);
});

View File

@@ -1,8 +1,10 @@
import type {
PuzzleAgentSessionSnapshot,
} from '../../../packages/shared/src/contracts/puzzleAgentSession';
import type {
PuzzleWorksResponse,
PuzzleWorkSummary,
} from '../../../packages/shared/src/contracts/puzzleWorkSummary';
import type { PuzzleAgentSessionSnapshot } from '../../../packages/shared/src/contracts/puzzleAgentSession';
import { type ApiRetryOptions, requestJson } from '../apiClient';
const PUZZLE_GALLERY_API_BASE = '/api/runtime/puzzle/gallery';
@@ -24,6 +26,8 @@ export async function listPuzzleGallery() {
'读取拼图广场失败',
{
retry: PUZZLE_GALLERY_READ_RETRY,
skipAuth: true,
skipRefresh: true,
},
);
}
@@ -40,6 +44,8 @@ export async function getPuzzleGalleryDetail(profileId: string) {
'读取拼图广场详情失败',
{
retry: PUZZLE_GALLERY_READ_RETRY,
skipAuth: true,
skipRefresh: true,
},
);
}