Files
Genarrative/src/components/platform-entry/PlatformActiveProfileView.test.tsx
T
kdletters f3ab2f2ec0 恢复平台账号顶栏与我的页签
按新版创作页原布局恢复泥点入口与账号身份胶囊。

在桌面侧栏补回我的页签及游客、登录态个人页面。

个人页面只复用账号、钱包、统计、设置和法律信息等平台能力。

补充壳层与个人页面回归测试并更新退役边界文档。
2026-07-18 16:15:40 +08:00

66 lines
1.9 KiB
TypeScript

/* @vitest-environment jsdom */
import { render, screen } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import { PlatformActiveProfileView } from './PlatformActiveProfileView';
const callbacks = {
onLogin: vi.fn(),
onOpenAccount: vi.fn(),
onOpenRecharge: vi.fn(),
onOpenSettings: vi.fn(),
onOpenWalletLedger: vi.fn(),
};
describe('PlatformActiveProfileView', () => {
it('shows the login entry for guests', () => {
render(
<PlatformActiveProfileView
{...callbacks}
dashboard={null}
isLoadingDashboard={false}
user={null}
/>,
);
expect(screen.getByRole('main', { name: '我的' })).toBeTruthy();
expect(screen.getByText('尚未登录')).toBeTruthy();
expect(screen.getByRole('button', { name: '登录' })).toBeTruthy();
});
it('renders active account, wallet, and settings capabilities', () => {
render(
<PlatformActiveProfileView
{...callbacks}
dashboard={{
walletBalance: 108,
totalPlayTimeMs: 5_400_000,
playedWorldCount: 7,
updatedAt: '2026-07-18T00:00:00.000Z',
}}
isLoadingDashboard={false}
user={{
id: 'user-1',
publicUserCode: '100001',
displayName: '测试玩家',
avatarUrl: null,
phoneNumberMasked: null,
loginMethod: 'password',
bindingStatus: 'active',
wechatBound: false,
}}
/>,
);
expect(screen.getByText('测试玩家')).toBeTruthy();
expect(screen.getByText('陶泥号:100001')).toBeTruthy();
expect(screen.getByRole('button', { name: '泥点余额 108' })).toBeTruthy();
expect(screen.getByRole('button', { name: /泥点充值/u })).toBeTruthy();
expect(
screen.getAllByRole('button', { name: /账号与安全/u }),
).toHaveLength(2);
expect(screen.getByRole('button', { name: /通用设置/u })).toBeTruthy();
});
});