收口作品详情分享反馈
将作品详情分享复制反馈迁移到 PlatformStatusMessage 按分享复制状态映射成功和错误提示外观 补充分享失败状态断言 更新 PlatformUiKit 文档和 Hermes 决策记录
This commit is contained in:
@@ -264,7 +264,36 @@ test('PlatformWorkDetailView copies public work code and share text', async () =
|
||||
expect(clipboardService.copyTextToClipboard).toHaveBeenLastCalledWith(
|
||||
expect.stringContaining('作品号:PZ-001'),
|
||||
);
|
||||
expect(await screen.findByText('分享内容已复制')).toBeTruthy();
|
||||
const shareCopiedMessage = await screen.findByText('分享内容已复制');
|
||||
expect(shareCopiedMessage.className).toContain('platform-status-message');
|
||||
expect(shareCopiedMessage.className).toContain(
|
||||
'bg-[var(--platform-success-bg)]',
|
||||
);
|
||||
});
|
||||
|
||||
test('PlatformWorkDetailView shows failed share feedback as an error status', async () => {
|
||||
vi.mocked(clipboardService.copyTextToClipboard).mockResolvedValue(false);
|
||||
|
||||
render(
|
||||
<PlatformWorkDetailView
|
||||
entry={createPuzzleEntry()}
|
||||
isBusy={false}
|
||||
error={null}
|
||||
onBack={vi.fn()}
|
||||
onLike={vi.fn()}
|
||||
onStart={vi.fn()}
|
||||
onRemix={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: '分享' }));
|
||||
|
||||
const shareFailedMessage = await screen.findByText('分享失败');
|
||||
|
||||
expect(shareFailedMessage.className).toContain('platform-status-message');
|
||||
expect(shareFailedMessage.className).toContain(
|
||||
'bg-[var(--platform-button-danger-fill)]',
|
||||
);
|
||||
});
|
||||
|
||||
test('PlatformWorkDetailView switches remix action label for owned work edit', () => {
|
||||
|
||||
@@ -17,10 +17,10 @@ import { useEffect, useMemo, useState } from 'react';
|
||||
import type { PublicUserSummary } from '../../../packages/shared/src/contracts/auth';
|
||||
import { buildPublicWorkDetailUrl } from '../../routing/appPageRoutes';
|
||||
import { CopyCodeButton } from '../common/CopyCodeButton';
|
||||
import { CopyFeedbackMessage } from '../common/CopyFeedbackMessage';
|
||||
import { PlatformActionButton } from '../common/PlatformActionButton';
|
||||
import { PlatformIconButton } from '../common/PlatformIconButton';
|
||||
import { PlatformPillBadge } from '../common/PlatformPillBadge';
|
||||
import { PlatformStatusMessage } from '../common/PlatformStatusMessage';
|
||||
import { useCopyFeedback } from '../common/useCopyFeedback';
|
||||
import { ResolvedAssetImage } from '../ResolvedAssetImage';
|
||||
import {
|
||||
@@ -454,12 +454,16 @@ export function PlatformWorkDetailView({
|
||||
copiedIcon={<Copy className="h-4 w-4" />}
|
||||
/>
|
||||
) : null}
|
||||
<CopyFeedbackMessage
|
||||
state={shareState}
|
||||
className="platform-work-detail__toast"
|
||||
copiedLabel="分享内容已复制"
|
||||
failedLabel="分享失败"
|
||||
/>
|
||||
{shareState !== 'idle' ? (
|
||||
<PlatformStatusMessage
|
||||
tone={shareState === 'copied' ? 'success' : 'error'}
|
||||
surface="platform"
|
||||
size="sm"
|
||||
className="platform-work-detail__toast"
|
||||
>
|
||||
{shareState === 'copied' ? '分享内容已复制' : '分享失败'}
|
||||
</PlatformStatusMessage>
|
||||
) : null}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user