继续收口工具弹窗与分段切换预设
新增 PlatformToolModalShell 承接白底工具弹窗壳层和固定可访问名称 新增 PlatformSegmentedTabPresets 沉淀频道下划线、创作 pill rail 与二列 option segment 迁移拼图、抓大鹅、历史素材弹窗和首页 / 作品架 / 充值切换的重复组件写法 同步 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 { PlatformToolModalShell } from './PlatformToolModalShell';
|
||||
|
||||
vi.mock('../auth/AuthUiContext', () => ({
|
||||
useAuthUi: () => ({ platformTheme: 'light' }),
|
||||
}));
|
||||
|
||||
test('renders shared platform tool modal shell with remapped panel chrome', () => {
|
||||
render(
|
||||
<PlatformToolModalShell
|
||||
open
|
||||
title="发布拼图作品"
|
||||
onClose={() => {}}
|
||||
footer={<button type="button">取消</button>}
|
||||
panelClassName="!max-h-[min(90vh,42rem)]"
|
||||
>
|
||||
<div>这里是正文</div>
|
||||
</PlatformToolModalShell>,
|
||||
);
|
||||
|
||||
const dialog = screen.getByRole('dialog', { name: '发布拼图作品' });
|
||||
expect(dialog.parentElement?.className).toContain('platform-theme--light');
|
||||
expect(dialog.className).toContain('platform-remap-surface');
|
||||
expect(dialog.className).toContain('shadow-[0_24px_80px_rgba(0,0,0,0.55)]');
|
||||
expect(dialog.className).toContain('!max-h-[min(90vh,42rem)]');
|
||||
expect(within(dialog).getByText('这里是正文')).toBeTruthy();
|
||||
expect(within(dialog).getByRole('button', { name: '取消' })).toBeTruthy();
|
||||
});
|
||||
|
||||
test('supports fixed aria label while keeping visible title text', () => {
|
||||
const onClose = vi.fn();
|
||||
|
||||
render(
|
||||
<PlatformToolModalShell
|
||||
open
|
||||
title="雨夜猫街"
|
||||
ariaLabel="关卡详情"
|
||||
onClose={onClose}
|
||||
>
|
||||
<div>这里是正文</div>
|
||||
</PlatformToolModalShell>,
|
||||
);
|
||||
|
||||
const dialog = screen.getByRole('dialog', { name: '关卡详情' });
|
||||
expect(within(dialog).getByText('雨夜猫街')).toBeTruthy();
|
||||
expect(screen.getByRole('button', { name: '关闭关卡详情' })).toBeTruthy();
|
||||
|
||||
fireEvent.click(dialog.parentElement as HTMLElement);
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
Reference in New Issue
Block a user