From d51a99e6454605f70d0ebc8ad23756f07907beac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=BF=94?= Date: Sun, 3 May 2026 13:36:40 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BF=AE=E5=A4=8D=E5=9B=A0=E9=A2=84?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=A8=A1=E5=BC=8F=E6=96=87=E6=A1=88=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E5=AF=BC=E8=87=B4=E7=9A=84=E6=B5=8B=E8=AF=95=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - header/footer/mobile-menu/mobile-tab-bar: 更新导航项断言与 mock - insight-card/page-header: 适配组件结构变更(InkGlowCard、Badge) - about/products/news: 修复重复文本匹配,添加 PageNav/date-fns mock - constants: 更新服务标题断言 - 修复 mock 组件缺少 displayName 的 ESLint 错误 --- src/app/(marketing)/about/page.test.tsx | 34 ++++++++--- .../news/[slug]/NewsDetailClient.test.tsx | 8 ++- .../(marketing)/products/[id]/page.test.tsx | 38 +++++++----- src/components/layout/footer.test.tsx | 53 +++++++++-------- src/components/layout/header.test.tsx | 46 +++++++++++---- src/components/layout/mobile-menu.test.tsx | 59 +++++++++++++++++-- src/components/layout/mobile-tab-bar.test.tsx | 12 ++-- .../sections/about-section.test.tsx | 24 ++++---- src/components/ui/insight-card.test.tsx | 40 ++++++++++--- src/components/ui/page-header.test.tsx | 33 ++++------- src/lib/constants.test.ts | 13 ++-- 11 files changed, 237 insertions(+), 123 deletions(-) diff --git a/src/app/(marketing)/about/page.test.tsx b/src/app/(marketing)/about/page.test.tsx index 6b4752d..e6b2555 100644 --- a/src/app/(marketing)/about/page.test.tsx +++ b/src/app/(marketing)/about/page.test.tsx @@ -93,6 +93,22 @@ jest.mock('@/components/ui/flip-clock', () => { return { FlipClock }; }); +jest.mock('@/components/layout/page-nav', () => ({ + PageNav: ({ items }: { items: Array<{ label: string }> }) => ( + + ), +})); + +jest.mock('date-fns', () => ({ + differenceInYears: () => 0, + differenceInMonths: () => 0, + differenceInDays: () => 0, + subYears: (d: Date) => d, + subMonths: (d: Date) => d, +})); + jest.mock('@/lib/constants', () => ({ COMPANY_INFO: { name: '四川睿新致远科技有限公司', @@ -100,14 +116,14 @@ jest.mock('@/lib/constants', () => ({ displayName: '睿新致远', description: '以智慧连接数字趋势,以伙伴身份陪您成长', address: '四川省成都市龙泉驿区', - email: 'contact@ruixin.com', - phone: '028-12345678', + email: 'contact@novalon.cn', + phone: '028-88888888', }, STATS: [ - { value: '10+', label: '企业客户' }, - { value: '20+', label: '成功案例' }, - { value: '30+', label: '项目交付' }, - { value: '12+', label: '年行业经验' }, + { value: '6', label: '研发产品' }, + { value: '5+', label: '行业覆盖' }, + { value: '10+', label: '团队成员' }, + { value: '12+', label: '年核心团队经验' }, ], })); @@ -127,8 +143,8 @@ describe('AboutPage', () => { it('should render company introduction', () => { render(); - const intro = screen.getByText(/关于我们/i); - expect(intro).toBeInTheDocument(); + const intros = screen.getAllByText(/关于我们/i); + expect(intros.length).toBeGreaterThan(0); }); it('should render company history', () => { @@ -157,7 +173,7 @@ describe('AboutPage', () => { it('should render statistics', () => { render(); - const stats = screen.getByText(/企业客户/i); + const stats = screen.getByText(/研发产品/i); expect(stats).toBeInTheDocument(); }); }); diff --git a/src/app/(marketing)/news/[slug]/NewsDetailClient.test.tsx b/src/app/(marketing)/news/[slug]/NewsDetailClient.test.tsx index 490c797..0cedbe8 100644 --- a/src/app/(marketing)/news/[slug]/NewsDetailClient.test.tsx +++ b/src/app/(marketing)/news/[slug]/NewsDetailClient.test.tsx @@ -10,9 +10,11 @@ jest.mock('next/navigation', () => ({ })); jest.mock('next/link', () => { - return ({ children, href }: { children: React.ReactNode; href: string }) => { + const MockLink = ({ children, href }: { children: React.ReactNode; href: string }) => { return {children}; }; + MockLink.displayName = 'MockLink'; + return MockLink; }); jest.mock('framer-motion', () => ({ @@ -39,8 +41,8 @@ describe('NewsDetailClient', () => { describe('Rendering', () => { it('should render news detail page', () => { render(); - const container = screen.getByText('测试新闻标题').closest('div'); - expect(container).toBeInTheDocument(); + const titles = screen.getAllByText('测试新闻标题'); + expect(titles.length).toBeGreaterThan(0); }); it('should render news title', () => { diff --git a/src/app/(marketing)/products/[id]/page.test.tsx b/src/app/(marketing)/products/[id]/page.test.tsx index 14b093f..630e863 100644 --- a/src/app/(marketing)/products/[id]/page.test.tsx +++ b/src/app/(marketing)/products/[id]/page.test.tsx @@ -19,22 +19,22 @@ jest.mock('next/link', () => { }); jest.mock('@/lib/constants', () => ({ + COMPANY_INFO: { + displayName: '睿新致远', + name: '四川睿新致远科技有限公司', + }, PRODUCTS: [ { id: 'test-product', title: '测试产品', category: '企业软件', + status: '研发中', description: '这是测试产品描述', overview: '这是测试产品概述', features: ['功能1', '功能2'], benefits: ['优势1', '优势2'], process: ['步骤1', '步骤2'], specs: ['规格1', '规格2'], - pricing: { - base: '¥10,000/年', - standard: '¥30,000/年', - enterprise: '定制', - }, }, ], })); @@ -49,8 +49,8 @@ describe('ProductDetailPage', () => { const page = await ProductDetailPage({ params: Promise.resolve({ id: 'test-product' }) }); render(page); - const container = screen.getByText('测试产品').closest('div'); - expect(container).toBeInTheDocument(); + const titles = screen.getAllByText('测试产品'); + expect(titles.length).toBeGreaterThan(0); }); it('should render product title', async () => { @@ -70,6 +70,14 @@ describe('ProductDetailPage', () => { expect(category).toBeInTheDocument(); }); + it('should render product status badge', async () => { + const page = await ProductDetailPage({ params: Promise.resolve({ id: 'test-product' }) }); + render(page); + + const status = screen.getByText('研发中'); + expect(status).toBeInTheDocument(); + }); + it('should render product description', async () => { const page = await ProductDetailPage({ params: Promise.resolve({ id: 'test-product' }) }); render(page); @@ -86,11 +94,11 @@ describe('ProductDetailPage', () => { expect(overview).toBeInTheDocument(); }); - it('should render product features section', async () => { + it('should render product features section as planned features', async () => { const page = await ProductDetailPage({ params: Promise.resolve({ id: 'test-product' }) }); render(page); - const features = screen.getByText('核心功能'); + const features = screen.getByText('规划功能'); expect(features).toBeInTheDocument(); }); @@ -102,22 +110,22 @@ describe('ProductDetailPage', () => { expect(benefits).toBeInTheDocument(); }); - it('should render pricing section', async () => { + it('should render pricing pending section instead of pricing plans', async () => { const page = await ProductDetailPage({ params: Promise.resolve({ id: 'test-product' }) }); render(page); - const pricing = screen.getByText('价格方案'); - expect(pricing).toBeInTheDocument(); + const pricingPending = screen.getByText('定价待公布'); + expect(pricingPending).toBeInTheDocument(); }); }); describe('Navigation', () => { - it('should have contact link', async () => { + it('should have appointment link', async () => { const page = await ProductDetailPage({ params: Promise.resolve({ id: 'test-product' }) }); render(page); - const contactLinks = screen.getAllByRole('link', { name: /联系我们/i }); - expect(contactLinks.length).toBeGreaterThan(0); + const appointmentLinks = screen.getAllByRole('link', { name: /预约体验/i }); + expect(appointmentLinks.length).toBeGreaterThan(0); }); }); diff --git a/src/components/layout/footer.test.tsx b/src/components/layout/footer.test.tsx index 42f23c5..2a33b00 100644 --- a/src/components/layout/footer.test.tsx +++ b/src/components/layout/footer.test.tsx @@ -44,13 +44,23 @@ jest.mock('@/lib/constants', () => ({ icp: '蜀ICP备XXXXXXXX号', police: '川公网安备XXXXXXXXXXX号', }, - NAVIGATION: [ - { id: 'home', label: '首页', href: '/' }, - { id: 'services', label: '服务', href: '/#services' }, + NAVIGATION_V2: [ { id: 'products', label: '产品', href: '/products' }, - { id: 'about', label: '关于', href: '/about' }, - { id: 'contact', label: '联系', href: '/contact' }, + { id: 'solutions', label: '解决方案', href: '/solutions' }, + { id: 'services', label: '服务', href: '/services' }, + { id: 'about', label: '关于我们', href: '/about' }, + { id: 'contact', label: '联系我们', href: '/contact' }, ], + MEGA_DROPDOWN_DATA: { + products: [ + { id: 'erp', title: 'ERP 管理系统', description: '财务·采购·销售·库存·生产', href: '/products/erp' }, + { id: 'crm', title: 'CRM 客户管理', description: '线索·商机·合同·服务', href: '/products/crm' }, + ], + solutions: [ + { id: 'manufacturing', title: '制造业', description: '智能制造·MES·质量管控', href: '/solutions/manufacturing' }, + { id: 'retail', title: '零售业', description: '全渠道·会员·精准营销', href: '/solutions/retail' }, + ], + }, })); import { Footer } from './footer'; @@ -79,12 +89,13 @@ describe('Footer', () => { it('should render quick links section', () => { render(