84 lines
2.4 KiB
TypeScript
84 lines
2.4 KiB
TypeScript
import { expect, test, vi } from 'vitest';
|
|
|
|
import { buildCreationWorkShelfItems } from './creationWorkShelf';
|
|
|
|
test('buildCreationWorkShelfItems maps visual novel items with VN public code', () => {
|
|
const items = buildCreationWorkShelfItems({
|
|
rpgItems: [],
|
|
bigFishItems: [],
|
|
puzzleItems: [],
|
|
visualNovelItems: [
|
|
{
|
|
runtimeKind: 'visual-novel',
|
|
profileId: 'vn-profile-demo-12345678',
|
|
ownerUserId: 'user-1',
|
|
title: '雨夜终章',
|
|
description: '失踪列车上的选择。',
|
|
coverImageSrc: '/vn-cover.png',
|
|
tags: ['悬疑', '列车'],
|
|
publishStatus: 'published',
|
|
publishReady: true,
|
|
playCount: 12,
|
|
updatedAt: '2026-05-07T00:00:00.000Z',
|
|
publishedAt: '2026-05-07T00:00:00.000Z',
|
|
},
|
|
{
|
|
runtimeKind: 'visual-novel',
|
|
profileId: 'vn-profile-draft-00000001',
|
|
ownerUserId: 'user-1',
|
|
title: '',
|
|
description: '',
|
|
coverImageSrc: null,
|
|
tags: [],
|
|
publishStatus: 'draft',
|
|
publishReady: false,
|
|
playCount: 0,
|
|
updatedAt: '2026-05-06T00:00:00.000Z',
|
|
publishedAt: null,
|
|
},
|
|
],
|
|
});
|
|
|
|
expect(items[0]?.kind).toBe('visual-novel');
|
|
expect(items[0]?.publicWorkCode).toBe('VN-12345678');
|
|
expect(items[0]?.sharePath).toContain('/works/detail?work=VN-12345678');
|
|
expect(items[1]?.status).toBe('draft');
|
|
expect(items[1]?.publicWorkCode).toBeNull();
|
|
});
|
|
|
|
test('buildCreationWorkShelfItems attaches open and delete actions through shelf adapters', () => {
|
|
const onOpenPuzzleDetail = vi.fn();
|
|
const onDeletePuzzle = vi.fn();
|
|
const puzzleWork = {
|
|
workId: 'puzzle:work-action',
|
|
profileId: 'puzzle-profile-action',
|
|
ownerUserId: 'user-1',
|
|
authorDisplayName: '测试作者',
|
|
levelName: '动作拼图',
|
|
summary: '验证作品架动作 Adapter。',
|
|
themeTags: [],
|
|
coverImageSrc: null,
|
|
publicationStatus: 'draft' as const,
|
|
updatedAt: '2026-05-08T00:00:00.000Z',
|
|
publishedAt: null,
|
|
playCount: 0,
|
|
remixCount: 0,
|
|
likeCount: 0,
|
|
publishReady: false,
|
|
};
|
|
|
|
const [item] = buildCreationWorkShelfItems({
|
|
rpgItems: [],
|
|
bigFishItems: [],
|
|
puzzleItems: [puzzleWork],
|
|
onOpenPuzzleDetail,
|
|
onDeletePuzzle,
|
|
});
|
|
|
|
item?.actions.open();
|
|
item?.actions.delete?.();
|
|
|
|
expect(onOpenPuzzleDetail).toHaveBeenCalledWith(puzzleWork);
|
|
expect(onDeletePuzzle).toHaveBeenCalledWith(puzzleWork);
|
|
});
|