fix: allow guest recommend swipe

This commit is contained in:
kdletters
2026-05-27 04:25:09 +08:00
parent 36a413167d
commit 46f8a1e613
3 changed files with 43 additions and 2 deletions

View File

@@ -3246,6 +3246,41 @@ test('logged out active recommend bottom tab selects next work without login', a
expect(openLoginModal).not.toHaveBeenCalled();
});
test('logged out recommend card supports vertical swipe without login', () => {
vi.useFakeTimers();
const onSelectNextRecommendEntry = vi.fn();
const openLoginModal = vi.fn();
renderLoggedOutHomeView(openLoginModal, {
latestEntries: [
puzzlePublicEntry,
{
...puzzlePublicEntry,
workId: 'puzzle-work-guest-next',
profileId: 'puzzle-profile-guest-next',
ownerUserId: 'user-guest-next',
publicWorkCode: 'PZ-GUEST-NEXT',
worldName: '访客下一张',
},
],
activeRecommendEntryKey: 'puzzle:user-2:puzzle-profile-public-1',
onSelectNextRecommendEntry,
recommendRuntimeContent: <div data-testid="guest-recommend-runtime" />,
});
const meta = screen.getByLabelText('奇幻拼图 作品信息') as HTMLElement;
act(() => {
dispatchPointerEvent(meta, 'pointerdown', { pointerId: 1, clientY: 320 });
dispatchPointerEvent(meta, 'pointermove', { pointerId: 1, clientY: 220 });
dispatchPointerEvent(meta, 'pointerup', { pointerId: 1, clientY: 220 });
vi.advanceTimersByTime(180);
});
expect(onSelectNextRecommendEntry).toHaveBeenCalledTimes(1);
expect(openLoginModal).not.toHaveBeenCalled();
vi.useRealTimers();
});
test('mobile recommend meta loads real author avatar from public user summary', async () => {
mockGetPublicAuthUserById.mockResolvedValueOnce({
id: 'user-2',