收口运行态状态提示组件
新增 PlatformRuntimeStatusToast 统一运行态短错误、成功和反馈 toast 迁移跳一跳、拼图、敲木鱼、方洞和宝贝爱画运行态状态 chip 补充公共组件与运行态回归测试,并更新 PlatformUiKit 文档和 Hermes 决策记录
This commit is contained in:
46
src/components/common/PlatformRuntimeStatusToast.test.tsx
Normal file
46
src/components/common/PlatformRuntimeStatusToast.test.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
/* @vitest-environment jsdom */
|
||||
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { expect, test } from 'vitest';
|
||||
|
||||
import { PlatformRuntimeStatusToast } from './PlatformRuntimeStatusToast';
|
||||
|
||||
test('renders error runtime toast with alert semantics', () => {
|
||||
render(
|
||||
<PlatformRuntimeStatusToast tone="error" className="mt-2">
|
||||
操作失败
|
||||
</PlatformRuntimeStatusToast>,
|
||||
);
|
||||
|
||||
const toast = screen.getByRole('alert');
|
||||
|
||||
expect(toast.className).toContain('platform-runtime-status-toast');
|
||||
expect(toast.className).toContain('rounded-full');
|
||||
expect(toast.className).toContain(
|
||||
'text-[var(--platform-button-danger-text)]',
|
||||
);
|
||||
expect(toast.className).toContain('mt-2');
|
||||
expect(toast.getAttribute('aria-live')).toBe('assertive');
|
||||
});
|
||||
|
||||
test('supports dark and solid runtime surfaces', () => {
|
||||
const { rerender } = render(
|
||||
<PlatformRuntimeStatusToast tone="success" surface="dark" shape="rounded">
|
||||
命中
|
||||
</PlatformRuntimeStatusToast>,
|
||||
);
|
||||
|
||||
expect(screen.getByRole('status').className).toContain(
|
||||
'border-emerald-200/35',
|
||||
);
|
||||
expect(screen.getByRole('status').className).toContain('rounded-[1.2rem]');
|
||||
|
||||
rerender(
|
||||
<PlatformRuntimeStatusToast tone="error" surface="solid" size="md">
|
||||
运行失败
|
||||
</PlatformRuntimeStatusToast>,
|
||||
);
|
||||
|
||||
expect(screen.getByRole('alert').className).toContain('bg-rose-600');
|
||||
expect(screen.getByRole('alert').className).toContain('px-4');
|
||||
});
|
||||
Reference in New Issue
Block a user