|
| 1 | +/* eslint-disable react/display-name, @typescript-eslint/no-explicit-any */ |
| 2 | +import React from 'react'; |
| 3 | +import { render, screen } from '@testing-library/react'; |
| 4 | +import LandingPage from '@/app/page'; |
| 5 | + |
| 6 | +// Mock translations |
| 7 | +jest.mock('@/lib/i18n/useAppTranslation', () => ({ |
| 8 | + useAppTranslation: () => ({ |
| 9 | + t: (key: string) => { |
| 10 | + const translations: Record<string, string> = { |
| 11 | + 'landing.badge': 'Now live on Soroban Testnet', |
| 12 | + 'landing.headline': 'Settle Globally.', |
| 13 | + 'landing.headlineAccent': 'Instantly & Non-Custodial.', |
| 14 | + 'landing.description': 'The next-generation merchant payment platform for African businesses.', |
| 15 | + 'landing.primaryCta': 'Start Accepting Crypto', |
| 16 | + 'landing.secondaryCta': 'Explore Features', |
| 17 | + 'landing.featuresTitle': 'Powered by Stellar & Soroban', |
| 18 | + 'landing.featuresDescription': 'Enterprise-grade payment infrastructure designed for speed, low fees, and perfect transparency.', |
| 19 | + 'landing.features.settlement.title': 'Instant Settlement', |
| 20 | + 'landing.features.settlement.description': 'Transactions settle in 3-5 seconds.', |
| 21 | + 'landing.features.offRamps.title': 'SEP-24 Fiat Off-Ramps', |
| 22 | + 'landing.features.offRamps.description': 'Automated routing to Stellar Anchors.', |
| 23 | + 'landing.features.fees.title': 'Smart Fee Splits', |
| 24 | + 'landing.features.fees.description': 'Soroban contracts automatically calculate and route platform fees.', |
| 25 | + }; |
| 26 | + return translations[key] || key; |
| 27 | + }, |
| 28 | + }), |
| 29 | +})); |
| 30 | + |
| 31 | +// Mock next/link |
| 32 | +jest.mock('next/link', () => { |
| 33 | + return ({ children, href }: any) => { |
| 34 | + return <a href={href}>{children}</a>; |
| 35 | + }; |
| 36 | +}); |
| 37 | + |
| 38 | +// Mock Header and Footer to isolate the page test |
| 39 | +jest.mock('@/components/layout', () => { |
| 40 | + return function MockLayout() { |
| 41 | + return <div data-testid="layout-component" />; |
| 42 | + }; |
| 43 | +}); |
| 44 | + |
| 45 | +describe('Landing Page Integration Tests', () => { |
| 46 | + beforeEach(() => { |
| 47 | + jest.clearAllMocks(); |
| 48 | + }); |
| 49 | + |
| 50 | + it('renders the main hero section with correct text', () => { |
| 51 | + render(<LandingPage />); |
| 52 | + expect(screen.getByText('Settle Globally.')).toBeInTheDocument(); |
| 53 | + expect(screen.getByText('Instantly & Non-Custodial.')).toBeInTheDocument(); |
| 54 | + }); |
| 55 | + |
| 56 | + it('renders the "Powered by Stellar & Soroban" headline as required', () => { |
| 57 | + render(<LandingPage />); |
| 58 | + expect(screen.getByText('Powered by Stellar & Soroban')).toBeInTheDocument(); |
| 59 | + }); |
| 60 | + |
| 61 | + it('renders all three feature cards with translations', () => { |
| 62 | + render(<LandingPage />); |
| 63 | + |
| 64 | + // Feature 1 |
| 65 | + expect(screen.getByText('Instant Settlement')).toBeInTheDocument(); |
| 66 | + expect(screen.getByText('Transactions settle in 3-5 seconds.')).toBeInTheDocument(); |
| 67 | + |
| 68 | + // Feature 2 |
| 69 | + expect(screen.getByText('SEP-24 Fiat Off-Ramps')).toBeInTheDocument(); |
| 70 | + expect(screen.getByText('Automated routing to Stellar Anchors.')).toBeInTheDocument(); |
| 71 | + |
| 72 | + // Feature 3 |
| 73 | + expect(screen.getByText('Smart Fee Splits')).toBeInTheDocument(); |
| 74 | + expect(screen.getByText('Soroban contracts automatically calculate and route platform fees.')).toBeInTheDocument(); |
| 75 | + }); |
| 76 | + |
| 77 | + it('renders feature elements within a list structure', () => { |
| 78 | + render(<LandingPage />); |
| 79 | + // The grid div has role="list" |
| 80 | + const list = screen.getByRole('list'); |
| 81 | + expect(list).toBeInTheDocument(); |
| 82 | + |
| 83 | + // Features are in listitems |
| 84 | + const listitems = screen.getAllByRole('listitem'); |
| 85 | + expect(listitems).toHaveLength(3); |
| 86 | + }); |
| 87 | +}); |
0 commit comments