diff --git a/components/dashboard/StatsCard.massive-scaling.test.tsx b/components/dashboard/StatsCard.massive-scaling.test.tsx new file mode 100644 index 000000000..531fd0bbb --- /dev/null +++ b/components/dashboard/StatsCard.massive-scaling.test.tsx @@ -0,0 +1,91 @@ +import { render, screen } from '@testing-library/react'; +import { beforeAll, describe, it, expect, vi } from 'vitest'; +import StatsCard from './StatsCard'; + +beforeAll(() => { + class MockIntersectionObserver { + observe = vi.fn(); + unobserve = vi.fn(); + disconnect = vi.fn(); + } + + Object.defineProperty(globalThis, 'IntersectionObserver', { + writable: true, + configurable: true, + value: MockIntersectionObserver, + }); +}); + +describe('StatsCard massive scaling', () => { + it('renders very large metric values without crashing', () => { + render( + + ); + + expect(screen.getByText('Total Contributions')).toBeInTheDocument(); + expect(screen.getByText(/999,999,999|999999999/)).toBeInTheDocument(); + }); + + it('handles extremely long title text with wrapping', () => { + const longTitle = + 'Very Long Contributor Activity Metric Title That Should Wrap Correctly Without Breaking Layout'; + + render( + + ); + + expect(screen.getByText(longTitle)).toBeInTheDocument(); + }); + + it('handles extremely long description text safely', () => { + const longDescription = 'Activity '.repeat(1000); + + render( + + ); + + expect(screen.getByText('Activity Logs')).toBeInTheDocument(); + }); + + it('renders zero and boundary values correctly', () => { + render( + + ); + + expect(screen.getByText('Empty Contributors')).toBeInTheDocument(); + expect(screen.getByText(/0/)).toBeInTheDocument(); + }); + + it('renders within acceptable performance limits', () => { + const start = performance.now(); + + render( + + ); + + const end = performance.now(); + + expect(end - start).toBeLessThan(100); + expect(screen.getByText('Massive Dataset')).toBeInTheDocument(); + }); +});