新增 PlatformAsyncStatePanel 统一 profile 异步状态骨架 扩展 PlatformSegmentedTabs 支持滚动 tab 并接入创作入口与发现页 统一 PixelCloseButton 复用 PlatformModalCloseButton 像素关闭能力 抽取平台入口泥点前置提示弹层并收紧阻断语义 补充组件收口文档与共享决策记录
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
/* @vitest-environment jsdom */
|
|
|
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
import { expect, test, vi } from 'vitest';
|
|
|
|
import {
|
|
PlatformDraftGenerationPointNoticeDialog,
|
|
} from './PlatformDraftGenerationPointNoticeDialog';
|
|
|
|
test('renders the insufficient-points notice with the shared blocking copy', () => {
|
|
const onClose = vi.fn();
|
|
|
|
render(
|
|
<PlatformDraftGenerationPointNoticeDialog
|
|
notice={{
|
|
kind: 'insufficient-points',
|
|
requiredPoints: 30,
|
|
currentPoints: 12,
|
|
}}
|
|
onClose={onClose}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.getByRole('dialog', { name: '泥点不足' })).toBeTruthy();
|
|
expect(screen.getByText('本次需要 30 泥点,当前 12 泥点。')).toBeTruthy();
|
|
expect(
|
|
screen.getByText('当前表单不会丢失,关闭后可继续编辑或补足泥点再继续。'),
|
|
).toBeTruthy();
|
|
|
|
fireEvent.click(screen.getByRole('button', { name: '知道了' }));
|
|
expect(onClose).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
test('renders the balance-load-failed notice without the amber icon override', () => {
|
|
render(
|
|
<PlatformDraftGenerationPointNoticeDialog
|
|
notice={{ kind: 'balance-load-failed' }}
|
|
onClose={() => {}}
|
|
/>,
|
|
);
|
|
|
|
const dialog = screen.getByRole('dialog', { name: '读取泥点余额失败' });
|
|
|
|
expect(screen.getByText('请稍后重试。')).toBeTruthy();
|
|
expect(
|
|
screen.getByText('当前表单不会丢失,关闭后可继续编辑,稍后再试。'),
|
|
).toBeTruthy();
|
|
expect(dialog.innerHTML).not.toContain('bg-amber-100/80');
|
|
});
|