收口认证表单输入组件

迁移登录、重置密码、绑定手机号、邀请码和账号安全表单到 PlatformTextField 与 PlatformFieldLabel

补充认证表单公共输入断言和绑定手机号独立测试

更新 PlatformUiKit 文档和 Hermes 决策记录
This commit is contained in:
2026-06-10 11:37:26 +08:00
parent b601b3b57e
commit 9389f9401f
10 changed files with 193 additions and 75 deletions

View File

@@ -0,0 +1,56 @@
/* @vitest-environment jsdom */
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { expect, test, vi } from 'vitest';
import type { AuthUser } from '../../services/authService';
import { BindPhoneScreen } from './BindPhoneScreen';
const baseUser: AuthUser = {
id: 'user-1',
displayName: '微信旅人',
avatarUrl: null,
publicUserCode: 'user-bind-phone',
phoneNumberMasked: null,
loginMethod: 'wechat',
bindingStatus: 'pending_bind_phone',
wechatBound: true,
};
test('绑定手机号表单复用平台输入和字段标题', async () => {
const user = userEvent.setup();
const onSubmit = vi.fn().mockResolvedValue(undefined);
render(
<BindPhoneScreen
user={baseUser}
platformTheme="light"
sendingCode={false}
binding={false}
error=""
captchaChallenge={null}
onSendCode={vi.fn().mockResolvedValue({
cooldownSeconds: 60,
expiresInSeconds: 300,
})}
onSubmit={onSubmit}
onLogout={vi.fn().mockResolvedValue(undefined)}
/>,
);
const phoneInput = screen.getByLabelText('手机号') as HTMLInputElement;
const codeInput = screen.getByLabelText('验证码') as HTMLInputElement;
expect(phoneInput.className).toContain('platform-text-field');
expect(codeInput.className).toContain('platform-text-field');
expect(screen.getByText('手机号').className).toContain(
'text-[var(--platform-text-strong)]',
);
await user.type(phoneInput, '13800000000');
await user.type(codeInput, '123456');
await user.click(screen.getByRole('button', { name: '绑定手机号并进入游戏' }));
expect(onSubmit).toHaveBeenCalledWith('13800000000', '123456');
});