refactor: 收口公开详情封面解锁规则
This commit is contained in:
@@ -3,6 +3,7 @@ import { expect, test } from 'vitest';
|
||||
import type { BarkBattleWorkSummary } from '../../../packages/shared/src/contracts/barkBattle';
|
||||
import type { BigFishWorkSummary } from '../../../packages/shared/src/contracts/bigFishWorkSummary';
|
||||
import type { JumpHopGalleryCardResponse } from '../../../packages/shared/src/contracts/jumpHop';
|
||||
import type { PuzzleRunSnapshot } from '../../../packages/shared/src/contracts/puzzleRuntimeSession';
|
||||
import type { PuzzleWorkSummary } from '../../../packages/shared/src/contracts/puzzleWorkSummary';
|
||||
import type { CustomWorldGalleryCard } from '../../../packages/shared/src/contracts/runtime';
|
||||
import type { SquareHoleWorkSummary } from '../../../packages/shared/src/contracts/squareHoleWorks';
|
||||
@@ -33,6 +34,7 @@ import {
|
||||
resolvePlatformPublicWorkActionMode,
|
||||
resolvePlatformPublicWorkDetailOpenDecision,
|
||||
resolvePlatformPublicWorkDetailOpenStrategy,
|
||||
resolveVisiblePuzzleDetailCoverCount,
|
||||
} from './platformPublicWorkDetailFlow';
|
||||
|
||||
type TypedPlatformPublicGalleryCard = Extract<
|
||||
@@ -165,6 +167,24 @@ function buildPuzzleWork(
|
||||
};
|
||||
}
|
||||
|
||||
function buildPuzzleRun(
|
||||
overrides: Partial<PuzzleRunSnapshot> = {},
|
||||
): PuzzleRunSnapshot {
|
||||
return {
|
||||
runId: 'puzzle-run',
|
||||
entryProfileId: 'puzzle-profile',
|
||||
clearedLevelCount: 0,
|
||||
currentLevelIndex: 0,
|
||||
currentGridSize: 3,
|
||||
playedProfileIds: ['puzzle-profile'],
|
||||
previousLevelTags: [],
|
||||
currentLevel: null,
|
||||
recommendedNextProfileId: null,
|
||||
leaderboardEntries: [],
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function buildBigFishWork(
|
||||
overrides: Partial<BigFishWorkSummary> = {},
|
||||
): BigFishWorkSummary {
|
||||
@@ -593,6 +613,35 @@ test('platform public work detail flow maps detail entries back to work summarie
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
test('platform public work detail flow resolves visible puzzle cover count', () => {
|
||||
const puzzleEntry = buildTypedEntry('puzzle', {
|
||||
profileId: 'puzzle-profile',
|
||||
});
|
||||
|
||||
expect(resolveVisiblePuzzleDetailCoverCount(null, null)).toBe(1);
|
||||
expect(
|
||||
resolveVisiblePuzzleDetailCoverCount(buildTypedEntry('big-fish'), null),
|
||||
).toBe(1);
|
||||
expect(
|
||||
resolveVisiblePuzzleDetailCoverCount(
|
||||
puzzleEntry,
|
||||
buildPuzzleRun({ entryProfileId: 'other-profile', clearedLevelCount: 9 }),
|
||||
),
|
||||
).toBe(1);
|
||||
expect(
|
||||
resolveVisiblePuzzleDetailCoverCount(
|
||||
puzzleEntry,
|
||||
buildPuzzleRun({ clearedLevelCount: 2 }),
|
||||
),
|
||||
).toBe(3);
|
||||
expect(
|
||||
resolveVisiblePuzzleDetailCoverCount(
|
||||
puzzleEntry,
|
||||
buildPuzzleRun({ clearedLevelCount: -1 }),
|
||||
),
|
||||
).toBe(1);
|
||||
});
|
||||
|
||||
test('platform public work detail flow resolves edit mode only for owned works', () => {
|
||||
const entry = buildTypedEntry('puzzle');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user