Files
Genarrative/src/components/common/PlatformRuntimeStatusToast.test.tsx
kdletters b601b3b57e 收口运行态状态提示组件
新增 PlatformRuntimeStatusToast 统一运行态短错误、成功和反馈 toast
迁移跳一跳、拼图、敲木鱼、方洞和宝贝爱画运行态状态 chip
补充公共组件与运行态回归测试,并更新 PlatformUiKit 文档和 Hermes 决策记录
2026-06-10 11:24:40 +08:00

47 lines
1.4 KiB
TypeScript

/* @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');
});