收口个人中心状态弹层与扫码组件
新增 PlatformStatusDialog 统一支付结果与确认中状态弹层 新增 PlatformProfileQrScannerModal 统一个人中心扫码面板 RpgEntryHomeView 改用共享组件并删除内联支付与扫码实现 更新 PlatformUiKit 收口文档与团队决策记录
This commit is contained in:
67
src/components/common/PlatformStatusDialog.test.tsx
Normal file
67
src/components/common/PlatformStatusDialog.test.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
/* @vitest-environment jsdom */
|
||||
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { expect, test, vi } from 'vitest';
|
||||
|
||||
import { PlatformStatusDialog } from './PlatformStatusDialog';
|
||||
|
||||
test('renders result state with description and primary action', () => {
|
||||
const onClose = vi.fn();
|
||||
const onAction = vi.fn();
|
||||
|
||||
render(
|
||||
<PlatformStatusDialog
|
||||
status="success"
|
||||
title="支付成功"
|
||||
description="账户状态已刷新"
|
||||
onClose={onClose}
|
||||
action={{ label: '知道了', onClick: onAction }}
|
||||
/>,
|
||||
);
|
||||
|
||||
const dialog = screen.getByRole('dialog', { name: '支付成功' });
|
||||
const badge = dialog.querySelector('.platform-icon-badge');
|
||||
const action = screen.getByRole('button', { name: '知道了' });
|
||||
const visibleDescription = dialog.querySelector(
|
||||
'.mt-3.text-sm.font-semibold.leading-6.text-\\[var\\(--platform-text-soft\\)\\]',
|
||||
);
|
||||
|
||||
expect(dialog).toBeTruthy();
|
||||
expect(visibleDescription?.textContent).toBe('账户状态已刷新');
|
||||
expect(badge?.className).toContain('text-[var(--platform-success-text)]');
|
||||
expect(action.className).toContain('platform-primary-button');
|
||||
|
||||
fireEvent.click(action);
|
||||
expect(onAction).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('supports blocking confirming state without close action', () => {
|
||||
const onClose = vi.fn();
|
||||
|
||||
render(
|
||||
<PlatformStatusDialog
|
||||
status="confirming"
|
||||
title="正在确认支付"
|
||||
description="订单 A100 正在同步到账状态,请先停留在当前页面。"
|
||||
onClose={onClose}
|
||||
closeDisabled
|
||||
zIndexClassName="z-[95]"
|
||||
/>,
|
||||
);
|
||||
|
||||
const dialog = screen.getByRole('dialog', { name: '正在确认支付' });
|
||||
const overlay = dialog.parentElement as HTMLElement;
|
||||
const spinner = dialog.querySelector('.platform-icon-badge svg');
|
||||
|
||||
expect(overlay.className).toContain('z-[95]');
|
||||
expect(spinner?.getAttribute('class')).toContain('animate-spin');
|
||||
expect(
|
||||
screen.queryByRole('button', { name: '关闭' }) ||
|
||||
screen.queryByRole('button', { name: '知道了' }),
|
||||
).toBeNull();
|
||||
|
||||
fireEvent.click(overlay);
|
||||
fireEvent.keyDown(window, { key: 'Escape' });
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
});
|
||||
Reference in New Issue
Block a user