This commit is contained in:
2026-05-13 00:28:07 +08:00
parent ef4f91a75e
commit 01c5ab985a
101 changed files with 10635 additions and 2292 deletions

View File

@@ -21,6 +21,10 @@ import type {
ProfileTaskCenterResponse,
} from '../../../packages/shared/src/contracts/runtime';
import { AuthUiContext } from '../auth/AuthUiContext';
import {
ICP_RECORD_NUMBER,
ICP_RECORD_URL,
} from '../common/legalDocuments';
import {
RpgEntryHomeView,
type RpgEntryHomeViewProps,
@@ -1089,11 +1093,48 @@ test('opens reward code modal from profile action on mobile', async () => {
expect(screen.getByLabelText('关闭兑换码')).toBeTruthy();
});
test('shows a reachable login entry in logged out mobile shell', async () => {
test('profile page shows legal entries and ICP record link', async () => {
const user = userEvent.setup();
renderProfileView();
const shortcutRegion = screen.getByRole('region', { name: '常用功能' });
expect(
shortcutRegion.querySelector('.grid')?.className.includes('grid-cols-3'),
).toBe(true);
expect(within(shortcutRegion).getByRole('button', { name: //u }))
.toBeTruthy();
expect(within(shortcutRegion).getByRole('button', { name: //u }))
.toBeTruthy();
expect(within(shortcutRegion).getByRole('button', { name: //u }))
.toBeTruthy();
expect(within(shortcutRegion).getByRole('button', { name: //u }))
.toBeTruthy();
const legalRegion = screen.getByRole('region', { name: '法律信息' });
expect(within(legalRegion).getByRole('button', { name: //u }))
.toBeTruthy();
expect(within(legalRegion).getByRole('button', { name: //u }))
.toBeTruthy();
expect(within(legalRegion).getByRole('button', { name: //u }))
.toBeTruthy();
const recordLink = within(legalRegion).getByRole('link', {
name: ICP_RECORD_NUMBER,
});
expect(recordLink.getAttribute('href')).toBe(ICP_RECORD_URL);
expect(recordLink.getAttribute('target')).toBe('_blank');
expect(recordLink.getAttribute('rel')).toBe('noreferrer');
await user.click(within(legalRegion).getByRole('button', { name: //u }));
expect(await screen.findByRole('dialog', { name: '隐私政策' })).toBeTruthy();
});
test('shows a reachable login entry outside mobile recommend tab', async () => {
const user = userEvent.setup();
const openLoginModal = vi.fn();
renderLoggedOutHomeView(openLoginModal);
renderLoggedOutHomeView(openLoginModal, {}, 'category');
await user.click(screen.getByRole('button', { name: '登录' }));
expect(openLoginModal).toHaveBeenCalledTimes(1);
@@ -1360,6 +1401,10 @@ test('logged out mobile shell defaults to discover tab', () => {
expect(
screen.getByPlaceholderText('搜索作品号、名称、作者、描述'),
).toBeTruthy();
expect(container.querySelector('.platform-mobile-topbar')).toBeTruthy();
expect(
container.querySelector('.platform-mobile-entry-shell--recommend'),
).toBeNull();
});
test('logged out recommend tab opens login modal and shows cover only', async () => {
@@ -1381,6 +1426,10 @@ test('logged out recommend tab opens login modal and shows cover only', async ()
expect(
container.querySelector('.platform-recommend-cover-only'),
).toBeTruthy();
expect(container.querySelector('.platform-mobile-topbar')).toBeNull();
expect(
container.querySelector('.platform-mobile-entry-shell--recommend'),
).toBeTruthy();
expect(screen.queryByTestId('recommend-runtime')).toBeNull();
expect(screen.queryByLabelText('奇幻拼图 作品信息')).toBeNull();
expect(screen.getAllByText('奇幻拼图').length).toBeGreaterThan(0);
@@ -1647,6 +1696,7 @@ test('logged in recommend runtime preloads adjacent work previews and drag switc
});
const meta = screen.getByLabelText('当前拼图 作品信息') as HTMLElement;
expect(meta.closest('[data-recommend-swipe-zone="true"]')).toBeTruthy();
const activeRecommendCard = within(meta);
const likeButton = activeRecommendCard.getByRole('button', {
name: '点赞 12',