refactor: 深化公开作品详情状态策略
This commit is contained in:
@@ -10,7 +10,9 @@ import {
|
||||
getPlatformPublicWorkDetailKind,
|
||||
type PlatformPublicWorkDetailKind,
|
||||
type PlatformPublicWorkDetailOpenStrategy,
|
||||
resolveActivePlatformPublicWorkAuthorEntry,
|
||||
resolvePlatformPublicWorkActionMode,
|
||||
resolvePlatformPublicWorkDetailOpenDecision,
|
||||
resolvePlatformPublicWorkDetailOpenStrategy,
|
||||
} from './platformPublicWorkDetailFlow';
|
||||
|
||||
@@ -227,3 +229,91 @@ test('platform public work detail flow resolves edit mode only for owned works',
|
||||
expect(resolvePlatformPublicWorkActionMode(entry, 'user-2')).toBe('remix');
|
||||
expect(resolvePlatformPublicWorkActionMode(entry, null)).toBe('remix');
|
||||
});
|
||||
|
||||
test('platform public work detail flow resolves direct open decision', () => {
|
||||
const entry = buildTypedEntry('match3d', {
|
||||
publicWorkCode: ' M3D-001 ',
|
||||
});
|
||||
const buildWorkDetailPath = (publicWorkCode: string) =>
|
||||
`/works/detail?work=${publicWorkCode.trim()}`;
|
||||
|
||||
expect(
|
||||
resolvePlatformPublicWorkDetailOpenDecision(entry, {
|
||||
buildWorkDetailPath,
|
||||
}),
|
||||
).toEqual({
|
||||
type: 'open',
|
||||
selectedDetail: entry,
|
||||
errorMessage: null,
|
||||
selectionStage: 'work-detail',
|
||||
historyPath: '/works/detail?work=M3D-001',
|
||||
});
|
||||
expect(
|
||||
resolvePlatformPublicWorkDetailOpenDecision(
|
||||
buildTypedEntry('match3d', { publicWorkCode: ' ' }),
|
||||
{
|
||||
buildWorkDetailPath,
|
||||
},
|
||||
),
|
||||
).toEqual({
|
||||
type: 'open',
|
||||
selectedDetail: buildTypedEntry('match3d', { publicWorkCode: ' ' }),
|
||||
errorMessage: null,
|
||||
selectionStage: 'work-detail',
|
||||
historyPath: null,
|
||||
});
|
||||
expect(
|
||||
resolvePlatformPublicWorkDetailOpenDecision(entry, {
|
||||
canExposeEntry: () => false,
|
||||
hiddenMessage: '隐藏',
|
||||
buildWorkDetailPath,
|
||||
}),
|
||||
).toEqual({
|
||||
type: 'blocked',
|
||||
selectedDetail: null,
|
||||
errorMessage: '隐藏',
|
||||
selectionStage: 'platform',
|
||||
historyPath: null,
|
||||
});
|
||||
});
|
||||
|
||||
test('platform public work detail flow selects author lookup entry by stage', () => {
|
||||
const selectedPublicWorkDetail = buildTypedEntry('puzzle');
|
||||
const publishedRpgEntry = buildRpgEntry({
|
||||
visibility: 'published',
|
||||
profileId: 'published-rpg-profile',
|
||||
});
|
||||
const draftRpgEntry = buildRpgEntry({
|
||||
visibility: 'draft',
|
||||
profileId: 'draft-rpg-profile',
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveActivePlatformPublicWorkAuthorEntry({
|
||||
selectionStage: 'work-detail',
|
||||
selectedPublicWorkDetail,
|
||||
selectedRpgDetailEntry: publishedRpgEntry,
|
||||
}),
|
||||
).toBe(selectedPublicWorkDetail);
|
||||
expect(
|
||||
resolveActivePlatformPublicWorkAuthorEntry({
|
||||
selectionStage: 'detail',
|
||||
selectedPublicWorkDetail: null,
|
||||
selectedRpgDetailEntry: publishedRpgEntry,
|
||||
}),
|
||||
).toBe(publishedRpgEntry);
|
||||
expect(
|
||||
resolveActivePlatformPublicWorkAuthorEntry({
|
||||
selectionStage: 'detail',
|
||||
selectedPublicWorkDetail: null,
|
||||
selectedRpgDetailEntry: draftRpgEntry,
|
||||
}),
|
||||
).toBeNull();
|
||||
expect(
|
||||
resolveActivePlatformPublicWorkAuthorEntry({
|
||||
selectionStage: 'platform',
|
||||
selectedPublicWorkDetail,
|
||||
selectedRpgDetailEntry: publishedRpgEntry,
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user