eb73ffb34d
为 CopyFeedbackButton 增加 actionShape 共享能力 将拼图广场详情 hero 动作迁移到共享按钮组件 将智能创作首页与抽屉入口迁移到共享按钮组件 将绑定手机号身份提示块迁移到 PlatformSubpanel 同步更新 PlatformUiKit 收口文档与团队决策记录
75 lines
2.2 KiB
TypeScript
75 lines
2.2 KiB
TypeScript
/* @vitest-environment jsdom */
|
|
|
|
import { render, screen } from '@testing-library/react';
|
|
import userEvent from '@testing-library/user-event';
|
|
import { expect, test, vi } from 'vitest';
|
|
|
|
import { CreativeAgentHome } from './CreativeAgentHome';
|
|
|
|
function renderHome({
|
|
error = null,
|
|
}: {
|
|
error?: string | null;
|
|
} = {}) {
|
|
render(
|
|
<CreativeAgentHome
|
|
recentItems={[]}
|
|
isBusy={false}
|
|
error={error}
|
|
onStartNewChat={vi.fn()}
|
|
onOpenHistoryItem={vi.fn()}
|
|
onOpenDrafts={vi.fn()}
|
|
onOpenAccount={vi.fn()}
|
|
onOpenSettings={vi.fn()}
|
|
onSubmitMessage={vi.fn()}
|
|
/>,
|
|
);
|
|
}
|
|
|
|
test('CreativeAgentHome uses shared empty state for empty drawer history', () => {
|
|
renderHome();
|
|
|
|
const emptyState = screen.getByText('暂无创作记录');
|
|
|
|
expect(emptyState.className).toContain('platform-empty-state');
|
|
expect(emptyState.className).toContain('bg-white/74');
|
|
});
|
|
|
|
test('CreativeAgentHome uses shared status message for home error', () => {
|
|
renderHome({ error: '创作助手暂时不可用' });
|
|
|
|
const statusMessage = screen.getByText('创作助手暂时不可用');
|
|
|
|
expect(statusMessage.className).toContain('platform-status-message');
|
|
expect(statusMessage.className).toContain('creative-agent-home__error');
|
|
expect(statusMessage.className).toContain(
|
|
'border-[var(--platform-button-danger-border)]',
|
|
);
|
|
});
|
|
|
|
test('CreativeAgentHome reuses shared button chrome for drawer and reward actions', async () => {
|
|
const user = userEvent.setup();
|
|
|
|
renderHome();
|
|
|
|
const menuButton = screen.getByRole('button', { name: '打开侧边栏' });
|
|
const rewardButton = screen.getByRole('button', {
|
|
name: '搓闪应用 分1亿激励',
|
|
});
|
|
|
|
expect(menuButton.className).toContain('platform-icon-button');
|
|
expect(rewardButton.className).toContain('platform-button');
|
|
|
|
await user.click(menuButton);
|
|
|
|
expect(
|
|
screen.getByRole('button', { name: '开启新对话' }).className,
|
|
).toContain('platform-button');
|
|
expect(
|
|
screen.getByRole('button', { name: '我的创作' }).className,
|
|
).toContain('platform-button');
|
|
expect(screen.getByRole('button', { name: '账号' }).className).toContain(
|
|
'platform-icon-button',
|
|
);
|
|
});
|