refactor: 收口作品架更新回填规则
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
import type { BigFishWorkSummary } from '../../../packages/shared/src/contracts/bigFishWorkSummary';
|
||||
import type { PuzzleWorkSummary } from '../../../packages/shared/src/contracts/puzzleWorkSummary';
|
||||
import { buildCreationWorkShelfItems } from '../custom-world-home/creationWorkShelf';
|
||||
import {
|
||||
@@ -12,6 +13,8 @@ import {
|
||||
type DraftGenerationNoticeMap,
|
||||
getGenerationNoticeShelfKeys,
|
||||
hasUnreadDraftGenerationUpdates,
|
||||
mergeBigFishWorkSummary,
|
||||
mergePuzzleWorkSummary,
|
||||
} from './platformDraftGenerationShelfModel';
|
||||
|
||||
describe('platformDraftGenerationShelfModel', () => {
|
||||
@@ -53,6 +56,42 @@ describe('platformDraftGenerationShelfModel', () => {
|
||||
expect(pending).toEqual([]);
|
||||
});
|
||||
|
||||
test('mergePuzzleWorkSummary only replaces the matching profile', () => {
|
||||
const current = buildPuzzleWork({
|
||||
profileId: 'puzzle-profile-1',
|
||||
workTitle: '旧拼图',
|
||||
});
|
||||
const updated = buildPuzzleWork({
|
||||
profileId: 'puzzle-profile-1',
|
||||
workTitle: '新拼图',
|
||||
});
|
||||
const other = buildPuzzleWork({
|
||||
profileId: 'puzzle-profile-2',
|
||||
workTitle: '别的拼图',
|
||||
});
|
||||
|
||||
expect(mergePuzzleWorkSummary(current, updated)).toBe(updated);
|
||||
expect(mergePuzzleWorkSummary(current, other)).toBe(current);
|
||||
});
|
||||
|
||||
test('mergeBigFishWorkSummary only replaces the matching source session', () => {
|
||||
const current = buildBigFishWork({
|
||||
sourceSessionId: 'big-fish-session-1',
|
||||
title: '旧大鱼',
|
||||
});
|
||||
const updated = buildBigFishWork({
|
||||
sourceSessionId: 'big-fish-session-1',
|
||||
title: '新大鱼',
|
||||
});
|
||||
const other = buildBigFishWork({
|
||||
sourceSessionId: 'big-fish-session-2',
|
||||
title: '别的大鱼',
|
||||
});
|
||||
|
||||
expect(mergeBigFishWorkSummary(current, updated)).toBe(updated);
|
||||
expect(mergeBigFishWorkSummary(current, other)).toBe(current);
|
||||
});
|
||||
|
||||
test('buildCreationWorkShelfRuntimeState lets failure notice override persisted generating puzzle copy', () => {
|
||||
const [item] = buildCreationWorkShelfItems({
|
||||
rpgItems: [],
|
||||
@@ -187,3 +226,30 @@ function buildPuzzleWork(
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function buildBigFishWork(
|
||||
overrides: Partial<BigFishWorkSummary> = {},
|
||||
): BigFishWorkSummary {
|
||||
return {
|
||||
workId: 'big-fish-work-base',
|
||||
sourceSessionId: 'big-fish-session-base',
|
||||
ownerUserId: 'user-1',
|
||||
authorDisplayName: '测试作者',
|
||||
title: '潮雾大鱼',
|
||||
subtitle: '潮雾港口',
|
||||
summary: '潮雾港口大鱼吃小鱼。',
|
||||
coverImageSrc: null,
|
||||
status: 'draft',
|
||||
updatedAt: '2026-06-03T08:00:00.000Z',
|
||||
publishedAt: null,
|
||||
playCount: 0,
|
||||
remixCount: 0,
|
||||
likeCount: 0,
|
||||
publishReady: false,
|
||||
levelCount: 1,
|
||||
levelMainImageReadyCount: 0,
|
||||
levelMotionReadyCount: 0,
|
||||
backgroundReady: false,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user