1ad25e30f8
新增 PlatformUiKit 通用弹窗、按钮、状态、空态、媒体、表单和标签等公共组件 迁移结果页、创作工作台、认证入口、RPG 暗色面板和运行态弹窗的重复 UI chrome 补充组件测试、页面回归测试、技术文档和 Hermes 共享决策记录
95 lines
2.7 KiB
TypeScript
95 lines
2.7 KiB
TypeScript
/* @vitest-environment jsdom */
|
|
|
|
import { render, screen } from '@testing-library/react';
|
|
import { expect, test } from 'vitest';
|
|
|
|
import { VisualNovelAttributePanel } from './VisualNovelAttributePanel';
|
|
import { VisualNovelHistoryPanel } from './VisualNovelHistoryPanel';
|
|
import { mockVisualNovelRun } from './visualNovelMockData';
|
|
import { VisualNovelSavePanel } from './VisualNovelSavePanel';
|
|
|
|
test('visual novel history panel uses platform empty state', () => {
|
|
render(
|
|
<VisualNovelHistoryPanel
|
|
run={{
|
|
...mockVisualNovelRun,
|
|
history: [],
|
|
}}
|
|
/>,
|
|
);
|
|
|
|
const emptyState = screen.getByText('暂无历史');
|
|
|
|
expect(emptyState.className).toContain('bg-white/74');
|
|
expect(emptyState.className).toContain('text-[var(--platform-text-soft)]');
|
|
});
|
|
|
|
test('visual novel attribute panel uses platform empty state', () => {
|
|
render(
|
|
<VisualNovelAttributePanel
|
|
run={{
|
|
...mockVisualNovelRun,
|
|
metrics: {},
|
|
}}
|
|
/>,
|
|
);
|
|
|
|
const emptyState = screen.getByText('暂无属性');
|
|
|
|
expect(emptyState.className).toContain('bg-white/74');
|
|
expect(emptyState.className).toContain('py-5');
|
|
});
|
|
|
|
test('visual novel save panel uses platform empty states', () => {
|
|
const { rerender } = render(
|
|
<VisualNovelSavePanel
|
|
run={mockVisualNovelRun}
|
|
saveArchives={[]}
|
|
isLoadingArchives
|
|
/>,
|
|
);
|
|
|
|
expect(screen.getByText('读取中').className).toContain('bg-white/74');
|
|
|
|
rerender(<VisualNovelSavePanel run={mockVisualNovelRun} saveArchives={[]} />);
|
|
|
|
expect(screen.getByText('暂无存档').className).toContain('bg-white/74');
|
|
});
|
|
|
|
test('visual novel runtime list cards use platform subpanel chrome', () => {
|
|
const { rerender } = render(
|
|
<VisualNovelHistoryPanel run={mockVisualNovelRun} />,
|
|
);
|
|
|
|
const historyCard = screen.getByText('#1').closest('article');
|
|
|
|
expect(historyCard?.className).toContain('bg-white/72');
|
|
expect(historyCard?.className).toContain('rounded-[1rem]');
|
|
expect(historyCard?.className).toContain('p-3');
|
|
|
|
rerender(
|
|
<VisualNovelSavePanel
|
|
run={mockVisualNovelRun}
|
|
saveArchives={[
|
|
{
|
|
worldKey: 'visual-novel:archive-1',
|
|
ownerUserId: 'mock-user',
|
|
profileId: 'vn-profile-mock-1',
|
|
worldType: 'visual-novel',
|
|
worldName: '雪线电台',
|
|
subtitle: '风雪站台',
|
|
summaryText: '第 2 回合',
|
|
coverImageSrc: null,
|
|
lastPlayedAt: '2026-05-05T12:00:00.000Z',
|
|
},
|
|
]}
|
|
/>,
|
|
);
|
|
|
|
const archiveCard = screen.getByText('雪线电台').closest('button');
|
|
|
|
expect(archiveCard?.className).toContain('bg-white/72');
|
|
expect(archiveCard?.className).toContain('hover:bg-white');
|
|
expect(archiveCard?.getAttribute('type')).toBe('button');
|
|
});
|