914b74ce8e
- 新增充值账单任务兑换码共享组件并补齐组件级测试 - 让 RpgEntryHomeView 改为复用新的 profile 弹层组件并删除内联实现 - 更新 PlatformUiKit 收口文档与团队共享记忆记录新的组件沉淀
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
/* @vitest-environment jsdom */
|
|
|
|
import { render, screen, within } from '@testing-library/react';
|
|
import userEvent from '@testing-library/user-event';
|
|
import { describe, expect, test, vi } from 'vitest';
|
|
|
|
import { PlatformProfileWalletLedgerModal } from './PlatformProfileWalletLedgerModal';
|
|
|
|
describe('PlatformProfileWalletLedgerModal', () => {
|
|
test('renders ledger entries with shared balance presentation', () => {
|
|
render(
|
|
<PlatformProfileWalletLedgerModal
|
|
ledger={{
|
|
entries: [
|
|
{
|
|
id: 'ledger-1',
|
|
sourceType: 'daily_task_reward',
|
|
amountDelta: 12,
|
|
balanceAfter: 88,
|
|
createdAt: '2026-06-10T08:00:00.000Z',
|
|
},
|
|
],
|
|
}}
|
|
fallbackBalance={40}
|
|
isLoading={false}
|
|
error={null}
|
|
onClose={vi.fn()}
|
|
onRetry={vi.fn()}
|
|
/>,
|
|
);
|
|
|
|
const dialog = screen.getByRole('dialog', { name: '泥点账单' });
|
|
|
|
expect(within(dialog).getByText('88泥点')).toBeTruthy();
|
|
expect(within(dialog).getByText('每日任务奖励')).toBeTruthy();
|
|
expect(within(dialog).getByText('+12')).toBeTruthy();
|
|
expect(within(dialog).getByText('余额 88')).toBeTruthy();
|
|
});
|
|
|
|
test('retries from the shared error state', async () => {
|
|
const user = userEvent.setup();
|
|
const onRetry = vi.fn();
|
|
|
|
render(
|
|
<PlatformProfileWalletLedgerModal
|
|
ledger={null}
|
|
fallbackBalance={40}
|
|
isLoading={false}
|
|
error="账单加载失败"
|
|
onClose={vi.fn()}
|
|
onRetry={onRetry}
|
|
/>,
|
|
);
|
|
|
|
await user.click(screen.getByRole('button', { name: '重新加载' }));
|
|
expect(onRetry).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|