收口个人中心昵称输入组件
迁移昵称弹窗输入框到 PlatformTextField 暗色表单 保留新昵称 label 语义和 Enter 提交行为 补充昵称弹窗公共输入断言 更新 PlatformUiKit 文档和 Hermes 决策记录
This commit is contained in:
@@ -3075,6 +3075,39 @@ test('desktop account entry uses saved avatar image when available', async () =>
|
||||
await screen.findByText('1 / 1');
|
||||
});
|
||||
|
||||
test('profile nickname modal uses platform text field and submits with Enter', async () => {
|
||||
const user = userEvent.setup();
|
||||
mockUpdateAuthProfile.mockResolvedValueOnce({
|
||||
id: 'user-1',
|
||||
publicUserCode: '100001',
|
||||
displayName: '新昵称',
|
||||
avatarUrl: null,
|
||||
phoneNumberMasked: null,
|
||||
loginMethod: 'password',
|
||||
bindingStatus: 'active',
|
||||
wechatBound: false,
|
||||
});
|
||||
|
||||
renderProfileView();
|
||||
await user.click(screen.getByLabelText('修改昵称'));
|
||||
|
||||
const nicknameInput = (await screen.findByLabelText(
|
||||
'新昵称',
|
||||
)) as HTMLInputElement;
|
||||
expect(nicknameInput.value).toBe('测试玩家');
|
||||
expect(nicknameInput.className).toContain('platform-text-field');
|
||||
expect(nicknameInput.className).toContain('platform-text-field--editor-dark');
|
||||
|
||||
await user.clear(nicknameInput);
|
||||
await user.type(nicknameInput, '新昵称{Enter}');
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockUpdateAuthProfile).toHaveBeenCalledWith({
|
||||
displayName: '新昵称',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('profile avatar upload uses the shared square crop tool', async () => {
|
||||
stubFileReader('data:image/png;base64,avatar-source');
|
||||
stubImage(800, 600);
|
||||
|
||||
@@ -2818,7 +2818,7 @@ function ProfileNicknameModal({
|
||||
<div className="px-5 py-5">
|
||||
<label className="block">
|
||||
<span className="sr-only">新昵称</span>
|
||||
<input
|
||||
<PlatformTextField
|
||||
autoFocus
|
||||
value={value}
|
||||
onChange={(event) => onChange(event.target.value)}
|
||||
@@ -2829,7 +2829,10 @@ function ProfileNicknameModal({
|
||||
}
|
||||
}}
|
||||
maxLength={20}
|
||||
className="w-full rounded-2xl border border-white/12 bg-white/10 px-4 py-3 text-base font-semibold text-[var(--platform-text-strong)] outline-none transition focus:border-[var(--platform-surface-hover-border)]"
|
||||
surface="editorDark"
|
||||
size="lg"
|
||||
density="roomy"
|
||||
className="rounded-2xl border-white/12 bg-white/10 text-[var(--platform-text-strong)] focus:border-[var(--platform-surface-hover-border)]"
|
||||
placeholder="输入新昵称"
|
||||
/>
|
||||
</label>
|
||||
|
||||
Reference in New Issue
Block a user