继续收口认证入口弹窗壳层
新增 PlatformAuthModalShell 统一认证白底弹窗壳层 登录入口和邀请码弹窗复用共享认证壳层 补充认证壳层和 AuthGate 接入测试 同步 PlatformUiKit 文档和 Hermes 决策记录
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/* @vitest-environment jsdom */
|
||||
|
||||
import { fireEvent, render, screen, within } from '@testing-library/react';
|
||||
import { expect, test, vi } from 'vitest';
|
||||
|
||||
import { PlatformAuthModalShell } from './PlatformAuthModalShell';
|
||||
|
||||
test('renders auth modal shell with platform theme and auth card chrome', () => {
|
||||
const onClose = vi.fn();
|
||||
|
||||
render(
|
||||
<PlatformAuthModalShell
|
||||
title="账号入口"
|
||||
platformTheme="light"
|
||||
onClose={onClose}
|
||||
closeLabel="关闭登录弹窗"
|
||||
panelClassName="!max-w-md"
|
||||
>
|
||||
<div>登录表单</div>
|
||||
</PlatformAuthModalShell>,
|
||||
);
|
||||
|
||||
const dialog = screen.getByRole('dialog', { name: '账号入口' });
|
||||
|
||||
expect(dialog.parentElement?.className).toContain('platform-theme--light');
|
||||
expect(dialog.className).toContain('platform-modal-shell');
|
||||
expect(dialog.className).toContain('platform-auth-card');
|
||||
expect(dialog.className).toContain('!max-w-md');
|
||||
expect(within(dialog).getByText('登录表单')).toBeTruthy();
|
||||
|
||||
fireEvent.click(dialog.parentElement as HTMLElement);
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('keeps escape disabled for auth flows', () => {
|
||||
const onClose = vi.fn();
|
||||
|
||||
render(
|
||||
<PlatformAuthModalShell
|
||||
title="请填写邀请码"
|
||||
platformTheme="dark"
|
||||
onClose={onClose}
|
||||
closeLabel="取消填写邀请码"
|
||||
zIndexClassName="z-[130]"
|
||||
>
|
||||
<div>邀请码表单</div>
|
||||
</PlatformAuthModalShell>,
|
||||
);
|
||||
|
||||
fireEvent.keyDown(window, { key: 'Escape' });
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
expect(screen.getByRole('button', { name: '取消填写邀请码' })).toBeTruthy();
|
||||
});
|
||||
Reference in New Issue
Block a user