refactor(link): 营销页站内链接统一 StaticLink(静态托管适配)+ 删除 0 引用死代码组件 + QA 页 client/server 拆分
This commit is contained in:
@@ -261,12 +261,6 @@ const mockProduct = {
|
||||
],
|
||||
};
|
||||
|
||||
const mockCrossRefItems = [
|
||||
{ id: 's1', title: '智能制造方案', type: 'solution' as const, href: '/solutions/s1', reason: 'ERP 是核心组件' },
|
||||
{ id: 'p2', title: 'CRM 系统', type: 'product' as const, href: '/products/crm', reason: '常与 ERP 一起使用' },
|
||||
{ id: 'sv1', title: '软件定制开发', type: 'service' as const, href: '/services/sv1', reason: '配套服务' },
|
||||
];
|
||||
|
||||
// ─── Tests ───────────────────────────────────────────────────────────────
|
||||
|
||||
describe('DetailHero', () => {
|
||||
@@ -573,58 +567,4 @@ describe('DetailCTASection', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('CrossRecommendGrid', () => {
|
||||
it('should render nothing when items is empty', async () => {
|
||||
const { CrossRecommendGrid } = await import('./detail-cross-recommend');
|
||||
const { container } = render(<CrossRecommendGrid items={[]} />);
|
||||
expect(container.innerHTML).toBe('');
|
||||
});
|
||||
|
||||
it('should render default title', async () => {
|
||||
const { CrossRecommendGrid } = await import('./detail-cross-recommend');
|
||||
render(<CrossRecommendGrid items={mockCrossRefItems} />);
|
||||
expect(screen.getByText('相关推荐')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render custom title', async () => {
|
||||
const { CrossRecommendGrid } = await import('./detail-cross-recommend');
|
||||
render(<CrossRecommendGrid items={mockCrossRefItems} title="更多推荐" />);
|
||||
expect(screen.getByText('更多推荐')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render all items', async () => {
|
||||
const { CrossRecommendGrid } = await import('./detail-cross-recommend');
|
||||
render(<CrossRecommendGrid items={mockCrossRefItems} />);
|
||||
expect(screen.getByText('智能制造方案')).toBeInTheDocument();
|
||||
expect(screen.getByText('CRM 系统')).toBeInTheDocument();
|
||||
expect(screen.getByText('软件定制开发')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render reason for each item', async () => {
|
||||
const { CrossRecommendGrid } = await import('./detail-cross-recommend');
|
||||
render(<CrossRecommendGrid items={mockCrossRefItems} />);
|
||||
expect(screen.getByText('ERP 是核心组件')).toBeInTheDocument();
|
||||
expect(screen.getByText('常与 ERP 一起使用')).toBeInTheDocument();
|
||||
expect(screen.getByText('配套服务')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render correct type labels', async () => {
|
||||
const { CrossRecommendGrid } = await import('./detail-cross-recommend');
|
||||
render(<CrossRecommendGrid items={mockCrossRefItems} />);
|
||||
// Type labels: product=产品, solution=方案, service=服务
|
||||
expect(screen.getByText('产品')).toBeInTheDocument();
|
||||
// There might be multiple "方案" texts in the page, so use getAllByText
|
||||
const solutionLabels = screen.getAllByText('方案');
|
||||
expect(solutionLabels.length).toBeGreaterThanOrEqual(1);
|
||||
expect(screen.getByText('服务')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render links for items', async () => {
|
||||
const { CrossRecommendGrid } = await import('./detail-cross-recommend');
|
||||
render(<CrossRecommendGrid items={mockCrossRefItems} />);
|
||||
const solutionLink = screen.getByText('智能制造方案').closest('a');
|
||||
expect(solutionLink).toHaveAttribute('href', '/solutions/s1');
|
||||
const productLink = screen.getByText('CRM 系统').closest('a');
|
||||
expect(productLink).toHaveAttribute('href', '/products/crm');
|
||||
});
|
||||
});
|
||||
// 注:CrossRecommendGrid 相关测试已随组件删除(2026-08-31,组件生产 0 引用)
|
||||
Reference in New Issue
Block a user