Files
novalon-website/src/components/detail/solution-value.test.tsx
T
zhangxiang 602ed6a671 test(hooks): finalize mutation test improvements and release acceptance
- Raise use-swipe-gesture mutation score to 66.13% (target 65%+)
- Maintain use-reduced-motion mutation score at 76.32% (target 50%+)
- Fix use-reduced-motion.ts ESLint set-state-in-effect warning
- Add UJ-10 deep searcher journey (category browse → article read → content discovery)
- Add 40 new test files (analytics, detail, sections, ui, lib components)
- Update test-strategy-plan.md to v2.0 (sync test count to 1591)
- Sync README.md with final release metrics

Quality gates: TS 0 errors, ESLint 0 errors, 121 suites / 1591 tests passed
2026-08-02 19:39:27 +08:00

154 lines
7.0 KiB
TypeScript

// @ts-nocheck
import { describe, it, expect, jest } from '@jest/globals';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
// ─── Mocks ───────────────────────────────────────────────────────────────
jest.mock('framer-motion', () => ({
motion: {
div: ({ children, initial, animate, variants, whileInView, viewport, transition, className, ...props }: any) => (
<div
data-testid="motion-div"
data-initial={JSON.stringify(initial)}
data-animate={JSON.stringify(animate)}
data-variants={JSON.stringify(variants)}
data-while-inview={JSON.stringify(whileInView)}
data-viewport={JSON.stringify(viewport)}
data-transition={JSON.stringify(transition)}
className={className}
{...props}
>
{children}
</div>
),
li: ({ children, className, ...props }: any) => (
<li data-testid="motion-li" className={className} {...props}>{children}</li>
),
},
useInView: jest.fn(() => true),
AnimatePresence: ({ children }: any) => <>{children}</>,
}));
jest.mock('lucide-react', () => {
const icons: Record<string, any> = {};
const names = ['CheckCircle2', 'Lightbulb', 'Target', 'TrendingUp'];
for (const name of names) {
const Icon = (props: any) => (
<svg
data-testid={`icon-${name.toLowerCase().replace(/\s+/g, '-')}`}
className={props?.className}
/>
);
Icon.displayName = name;
icons[name] = Icon;
}
return icons;
});
// ─── Mock Data ────────────────────────────────────────────────────────────
const mockSolution = {
id: 'manufacturing',
industry: '制造业',
title: '智能制造解决方案',
subtitle: '助力制造业数字化转型',
description: '面向制造业的一站式数字化转型方案,涵盖生产、质量、设备全流程',
challenges: [
'生产流程不透明,无法实时掌握车间状态',
'设备利用率低,缺乏预防性维护机制',
'质量管控依赖人工,缺陷率居高不下',
],
solutions: [
'部署MES系统,实现生产过程透明化',
'接入IoT设备传感器,构建设备健康管理平台',
'引入AI质检系统,提升缺陷检测准确率',
],
relatedProducts: ['erp', 'crm'],
valueProposition: {
headline: '让制造更智能,让管理更高效',
points: [
{ icon: 'trending-up', title: '效率提升', description: '生产效率提升30%,订单交付周期缩短50%' },
{ icon: 'shield', title: '质量保障', description: '产品合格率提升至99%,缺陷率降低80%' },
{ icon: 'zap', title: '成本优化', description: '运营成本降低25%,设备维护成本降低40%' },
],
},
suiteCombination: {
primaryProducts: ['ERP系统', 'MES系统', 'WMS系统'],
complementaryServices: ['数据采集与集成', '设备物联网接入', 'AI质检系统部署'],
rationale: 'ERP+MES+IoT实现从订单到交付的全流程数字化,打通信息孤岛,构建智能制造底座',
},
};
// ─── Tests ───────────────────────────────────────────────────────────────
describe('SolutionValueSection', () => {
it('should render industry name in heading', async () => {
const { SolutionValueSection } = await import('./solution-value');
render(<SolutionValueSection solution={mockSolution} />);
expect(screen.getByText('制造业')).toBeInTheDocument();
expect(screen.getByText(/为.*量身定制/)).toBeInTheDocument();
});
it('should render "行业方案" label', async () => {
const { SolutionValueSection } = await import('./solution-value');
render(<SolutionValueSection solution={mockSolution} />);
expect(screen.getByText('行业方案')).toBeInTheDocument();
});
it('should render description', async () => {
const { SolutionValueSection } = await import('./solution-value');
render(<SolutionValueSection solution={mockSolution} />);
expect(screen.getByText('面向制造业的一站式数字化转型方案,涵盖生产、质量、设备全流程')).toBeInTheDocument();
});
it('should render "行业痛点挑战" section', async () => {
const { SolutionValueSection } = await import('./solution-value');
render(<SolutionValueSection solution={mockSolution} />);
expect(screen.getByText('行业痛点挑战')).toBeInTheDocument();
expect(screen.getByText('生产流程不透明,无法实时掌握车间状态')).toBeInTheDocument();
expect(screen.getByText('设备利用率低,缺乏预防性维护机制')).toBeInTheDocument();
});
it('should render "睿新致远解决方案" section', async () => {
const { SolutionValueSection } = await import('./solution-value');
render(<SolutionValueSection solution={mockSolution} />);
expect(screen.getByText('睿新致远解决方案')).toBeInTheDocument();
expect(screen.getByText('部署MES系统,实现生产过程透明化')).toBeInTheDocument();
});
it('should render value proposition section', async () => {
const { SolutionValueSection } = await import('./solution-value');
render(<SolutionValueSection solution={mockSolution} />);
expect(screen.getByText('价值主张')).toBeInTheDocument();
expect(screen.getByText('让制造更智能,让管理更高效')).toBeInTheDocument();
});
it('should render value proposition points', async () => {
const { SolutionValueSection } = await import('./solution-value');
render(<SolutionValueSection solution={mockSolution} />);
expect(screen.getByText('效率提升')).toBeInTheDocument();
expect(screen.getByText('质量保障')).toBeInTheDocument();
expect(screen.getByText('成本优化')).toBeInTheDocument();
});
it('should render "产品组合" section', async () => {
const { SolutionValueSection } = await import('./solution-value');
render(<SolutionValueSection solution={mockSolution} />);
expect(screen.getByText('产品组合')).toBeInTheDocument();
expect(screen.getByText('推荐搭配方案')).toBeInTheDocument();
});
it('should render suite combination products', async () => {
const { SolutionValueSection } = await import('./solution-value');
render(<SolutionValueSection solution={mockSolution} />);
expect(screen.getByText('ERP系统')).toBeInTheDocument();
expect(screen.getByText('MES系统')).toBeInTheDocument();
});
it('should render combination rationale', async () => {
const { SolutionValueSection } = await import('./solution-value');
render(<SolutionValueSection solution={mockSolution} />);
expect(screen.getByText(/ERP\+MES\+IoT实现从订单到交付的全流程数字化/)).toBeInTheDocument();
});
});