SupplyChainModel.test.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import React from 'react';
  2. import { render, screen } from '@testing-library/react';
  3. import { describe, it, expect } from 'vitest';
  4. import SupplyChainModel from '@/client/home/pages/SupplyChainDashboards/components/SupplyChainModel';
  5. describe('SupplyChainModel', () => {
  6. it('should render the supply chain model with all elements', () => {
  7. render(<SupplyChainModel />);
  8. // Check main title elements
  9. expect(screen.getByText('省粮油集团+区域公司+新型农业经营主体')).toBeInTheDocument();
  10. expect(screen.getByText('1+1+N')).toBeInTheDocument();
  11. expect(screen.getByText('供应链合作模式')).toBeInTheDocument();
  12. });
  13. it('should render the three main entities', () => {
  14. render(<SupplyChainModel />);
  15. // Check entity titles
  16. expect(screen.getByText('省粮油集团')).toBeInTheDocument();
  17. expect(screen.getByText('区域公司')).toBeInTheDocument();
  18. expect(screen.getByText('新型农业经营主体')).toBeInTheDocument();
  19. // Check entity descriptions
  20. expect(screen.getByText('核心龙头企业')).toBeInTheDocument();
  21. expect(screen.getByText('资源整合平台')).toBeInTheDocument();
  22. expect(screen.getByText('标准制定者')).toBeInTheDocument();
  23. expect(screen.getByText('区域运营中心')).toBeInTheDocument();
  24. expect(screen.getByText('服务支撑平台')).toBeInTheDocument();
  25. expect(screen.getByText('市场对接桥梁')).toBeInTheDocument();
  26. expect(screen.getByText('家庭农场')).toBeInTheDocument();
  27. expect(screen.getByText('合作社')).toBeInTheDocument();
  28. expect(screen.getByText('农业企业')).toBeInTheDocument();
  29. });
  30. it('should render the cooperation process', () => {
  31. render(<SupplyChainModel />);
  32. // Check process title
  33. expect(screen.getByText('合作流程')).toBeInTheDocument();
  34. // Check process steps
  35. expect(screen.getByText('资源整合')).toBeInTheDocument();
  36. expect(screen.getByText('区域运营')).toBeInTheDocument();
  37. expect(screen.getByText('产业协同')).toBeInTheDocument();
  38. // Check process step numbers
  39. expect(screen.getByText('①')).toBeInTheDocument();
  40. expect(screen.getByText('②')).toBeInTheDocument();
  41. expect(screen.getByText('③')).toBeInTheDocument();
  42. });
  43. it('should render with correct positioning', () => {
  44. render(<SupplyChainModel />);
  45. const container = screen.getByRole('generic');
  46. // Check positioning
  47. expect(container).toHaveClass('absolute');
  48. expect(container).toHaveClass('right-[80px]');
  49. expect(container).toHaveClass('top-[150px]');
  50. });
  51. it('should render with correct styling for main title', () => {
  52. render(<SupplyChainModel />);
  53. // Check 1+1+N styling
  54. const mainTitle = screen.getByText('1+1+N');
  55. expect(mainTitle).toHaveClass('text-[80px]');
  56. expect(mainTitle).toHaveClass('font-bold');
  57. // Check "供应链合作模式" styling
  58. const subTitle = screen.getByText('供应链合作模式');
  59. expect(subTitle).toHaveClass('text-[50px]');
  60. expect(subTitle).toHaveClass('text-[cyan]');
  61. });
  62. it('should render entity cards with correct styling', () => {
  63. render(<SupplyChainModel />);
  64. // Check entity card containers
  65. const entityCards = screen.getAllByText(/省粮油集团|区域公司|新型农业经营主体/);
  66. expect(entityCards).toHaveLength(3);
  67. // Check entity number indicators
  68. const numbers = screen.getAllByText(/1|N/);
  69. expect(numbers).toHaveLength(3);
  70. });
  71. it('should render process flow with correct styling', () => {
  72. render(<SupplyChainModel />);
  73. // Check process flow container
  74. const processContainer = screen.getByText('合作流程').closest('div');
  75. expect(processContainer).toHaveClass('border-t');
  76. expect(processContainer).toHaveClass('border-[rgba(255,255,255,0.1)]');
  77. // Check process step indicators
  78. const stepIndicators = screen.getAllByText(/①|②|③/);
  79. expect(stepIndicators).toHaveLength(3);
  80. stepIndicators.forEach(indicator => {
  81. expect(indicator).toHaveClass('text-white');
  82. });
  83. });
  84. });