fix: tighten public work type routing
This commit is contained in:
@@ -42,7 +42,10 @@ import type {
|
||||
CustomWorldGalleryCard,
|
||||
CustomWorldLibraryEntry,
|
||||
} from '../../../packages/shared/src/contracts/runtime';
|
||||
import type { WoodenFishWorkSummaryResponse } from '../../../packages/shared/src/contracts/woodenFish';
|
||||
import type {
|
||||
WoodenFishGalleryCardResponse,
|
||||
WoodenFishWorkSummaryResponse,
|
||||
} from '../../../packages/shared/src/contracts/woodenFish';
|
||||
import { normalizeCustomWorldProfileRecord } from '../../data/customWorldLibrary';
|
||||
import type { HydratedSavedGameSnapshot } from '../../persistence/runtimeSnapshotTypes';
|
||||
import {
|
||||
@@ -155,6 +158,7 @@ import {
|
||||
deleteRpgEntryWorldProfile,
|
||||
getRpgEntryWorldGalleryDetail as getRpgEntryWorldGalleryDetailFromClient,
|
||||
getRpgEntryWorldGalleryDetailByCode,
|
||||
likeRpgEntryWorldGallery,
|
||||
recordRpgEntryWorldGalleryPlay,
|
||||
remixRpgEntryWorldGallery,
|
||||
} from '../../services/rpg-entry/rpgEntryLibraryClient';
|
||||
@@ -538,6 +542,7 @@ const rpgEntryLibraryServiceMocks = vi.hoisted(() => ({
|
||||
getRpgEntryWorldGalleryDetail: vi.fn(),
|
||||
getRpgEntryWorldGalleryDetailByCode: vi.fn(),
|
||||
getRpgEntryWorldLibraryDetail: vi.fn(),
|
||||
likeRpgEntryWorldGallery: vi.fn(),
|
||||
listRpgEntryWorldGallery: vi.fn(),
|
||||
listRpgEntryWorldLibrary: vi.fn(),
|
||||
publishRpgEntryWorldProfile: vi.fn(),
|
||||
@@ -7365,6 +7370,75 @@ test('home recommendation share opens publish share modal', async () => {
|
||||
.toBeTruthy();
|
||||
});
|
||||
|
||||
test('home recommendation wooden fish like does not call RPG gallery like', async () => {
|
||||
const user = userEvent.setup();
|
||||
const publishedWoodenFishWork: WoodenFishGalleryCardResponse = {
|
||||
publicWorkCode: 'WF-3A9EC89B',
|
||||
workId: 'wooden-fish-work-like-1',
|
||||
profileId: 'wooden-fish-profile-like-1',
|
||||
ownerUserId: 'wooden-fish-user-1',
|
||||
authorDisplayName: '木鱼作者',
|
||||
workTitle: '莲台木鱼',
|
||||
workDescription: '推荐页里的敲木鱼作品。',
|
||||
coverImageSrc: null,
|
||||
themeTags: ['敲木鱼'],
|
||||
publicationStatus: 'published',
|
||||
playCount: 0,
|
||||
updatedAt: '2026-04-25T09:00:00.000Z',
|
||||
publishedAt: '2026-04-25T09:00:00.000Z',
|
||||
generationStatus: 'ready',
|
||||
};
|
||||
|
||||
vi.mocked(woodenFishClient.listGallery).mockResolvedValue({
|
||||
items: [publishedWoodenFishWork],
|
||||
hasMore: false,
|
||||
nextCursor: null,
|
||||
});
|
||||
vi.mocked(woodenFishClient.startRun).mockResolvedValue({
|
||||
run: {
|
||||
runId: 'wooden-fish-run-like-1',
|
||||
profileId: publishedWoodenFishWork.profileId,
|
||||
ownerUserId: publishedWoodenFishWork.ownerUserId,
|
||||
status: 'playing',
|
||||
totalTapCount: 0,
|
||||
wordCounters: [],
|
||||
startedAtMs: 1,
|
||||
updatedAtMs: 1,
|
||||
finishedAtMs: null,
|
||||
},
|
||||
});
|
||||
vi.mocked(likeRpgEntryWorldGallery).mockResolvedValue(
|
||||
buildMockRpgGalleryDetail({
|
||||
ownerUserId: 'custom-world-user-1',
|
||||
profileId: 'custom-world-profile-1',
|
||||
publicWorkCode: 'CW-00000001',
|
||||
authorPublicUserCode: 'SY-00000001',
|
||||
visibility: 'published',
|
||||
publishedAt: '2026-04-25T09:00:00.000Z',
|
||||
updatedAt: '2026-04-25T09:00:00.000Z',
|
||||
authorDisplayName: 'RPG 作者',
|
||||
worldName: '不应被点赞的 RPG',
|
||||
subtitle: '错误分流',
|
||||
summaryText: 'WF 点赞不应进入这里。',
|
||||
coverImageSrc: null,
|
||||
themeMode: 'mythic',
|
||||
playableNpcCount: 0,
|
||||
landmarkCount: 0,
|
||||
likeCount: 1,
|
||||
}),
|
||||
);
|
||||
|
||||
render(<TestWrapper withAuth />);
|
||||
|
||||
const meta = await screen.findByLabelText('莲台木鱼 作品信息');
|
||||
await user.click(within(meta).getByRole('button', { name: '点赞 0' }));
|
||||
|
||||
expect(likeRpgEntryWorldGallery).not.toHaveBeenCalled();
|
||||
expect(
|
||||
await screen.findByText('作品类型 wooden-fish 暂不支持点赞。'),
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
test('home recommendation keeps logged-in puzzle start on default auth instead of guest token', async () => {
|
||||
const publishedPuzzleWork = {
|
||||
workId: 'puzzle-work-public-2',
|
||||
@@ -7467,12 +7541,6 @@ test('logged out home recommendation next starts the next puzzle work', async ()
|
||||
/>,
|
||||
);
|
||||
|
||||
const recommendNavButton = document.querySelector<HTMLButtonElement>(
|
||||
'.platform-bottom-nav [aria-label="推荐"]',
|
||||
);
|
||||
expect(recommendNavButton).toBeTruthy();
|
||||
await user.click(recommendNavButton!);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(startPuzzleRun).toHaveBeenCalledWith(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user