继续收口详情页头部动作组合
沉淀 PlatformDetailTopbar 与 PlatformDetailShareActions 共享骨架 接入 RPG 世界详情与公开作品详情的返回复制分享动作组合 补充测试护栏与文档决策记录
This commit is contained in:
52
src/components/common/PlatformDetailShareActions.test.tsx
Normal file
52
src/components/common/PlatformDetailShareActions.test.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
/* @vitest-environment jsdom */
|
||||
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { expect, test, vi } from 'vitest';
|
||||
|
||||
import { PlatformDetailShareActions } from './PlatformDetailShareActions';
|
||||
|
||||
test('renders overlay detail share actions with copied share state', () => {
|
||||
render(
|
||||
<PlatformDetailShareActions
|
||||
workCode="CW-001"
|
||||
copyState="idle"
|
||||
onCopyWorkCode={vi.fn()}
|
||||
shareState="copied"
|
||||
onShare={vi.fn()}
|
||||
shareAriaLabel="分享作品 测试世界"
|
||||
leading={<span>已发布</span>}
|
||||
variant="overlay"
|
||||
/>,
|
||||
);
|
||||
|
||||
const codeButton = screen.getByRole('button', { name: '复制作品号 CW-001' });
|
||||
const shareButton = screen.getByRole('button', { name: '分享作品 测试世界' });
|
||||
|
||||
expect(screen.getByText('已发布')).toBeTruthy();
|
||||
expect(codeButton.className).toContain('bg-white/72');
|
||||
expect(codeButton.className).toContain('tracking-[0.18em]');
|
||||
expect(shareButton.className).toContain('bg-white/72');
|
||||
expect(screen.getByText('已复制')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('renders solid detail share actions with compact work code chip', () => {
|
||||
render(
|
||||
<PlatformDetailShareActions
|
||||
workCode="PZ-001"
|
||||
copyState="idle"
|
||||
onCopyWorkCode={vi.fn()}
|
||||
shareState="idle"
|
||||
onShare={vi.fn()}
|
||||
shareAriaLabel="分享作品 拼图世界"
|
||||
leading={<span>已发布</span>}
|
||||
variant="solid"
|
||||
/>,
|
||||
);
|
||||
|
||||
const codeButton = screen.getByRole('button', { name: 'PZ-001' });
|
||||
const shareButton = screen.getByRole('button', { name: '分享作品 拼图世界' });
|
||||
|
||||
expect(codeButton.className).toContain('bg-[var(--platform-neutral-bg)]');
|
||||
expect(shareButton.className).toContain('bg-[var(--platform-neutral-bg)]');
|
||||
expect(screen.getByText('已发布')).toBeTruthy();
|
||||
});
|
||||
Reference in New Issue
Block a user