From f3265cc2571bd8f8f2b4810c5e4ffa1b72049db9 Mon Sep 17 00:00:00 2001 From: Thacker-Meet Date: Fri, 12 Jun 2026 15:21:38 +0530 Subject: [PATCH] test(not-found): add massive scaling test coverage --- app/not-found.massive-scaling.test.tsx | 86 ++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 app/not-found.massive-scaling.test.tsx diff --git a/app/not-found.massive-scaling.test.tsx b/app/not-found.massive-scaling.test.tsx new file mode 100644 index 000000000..9987e255d --- /dev/null +++ b/app/not-found.massive-scaling.test.tsx @@ -0,0 +1,86 @@ +import { describe, expect, it, vi } from 'vitest'; +import { cleanup, render, screen } from '@testing-library/react'; +import NotFound from './not-found'; + +vi.mock('next/link', () => ({ + default: ({ href, children, ...props }: { href: string; children: React.ReactNode }) => ( + + {children} + + ), +})); + +vi.mock('sonner', () => ({ + toast: { + success: vi.fn(), + error: vi.fn(), + }, +})); + +describe('NotFound — massive scaling', () => { + it('renders successfully across many repeated mounts', () => { + for (let i = 0; i < 250; i++) { + const { unmount } = render(); + expect(screen.getAllByText('𝒐𝒐𝒑𝒔').length).toBe(2); + unmount(); + } + }); + + it('maintains terminal content integrity during repeated renders', () => { + for (let i = 0; i < 100; i++) { + render(); + + expect(screen.getByText(/The page you're looking for has been rebased/i)).toBeInTheDocument(); + + cleanup(); + } + }); + + it('keeps navigation links available under high render volume', () => { + render( + <> + {Array.from({ length: 50 }).map((_, index) => ( +
+ +
+ ))} + + ); + + expect(screen.getAllByRole('link', { name: /go back home/i })).toHaveLength(50); + + expect(screen.getAllByRole('link', { name: /git checkout main/i })).toHaveLength(50); + }); + + it('renders within acceptable performance limits', () => { + const start = performance.now(); + + for (let i = 0; i < 100; i++) { + const { unmount } = render(); + unmount(); + } + + const duration = performance.now() - start; + + expect(duration).toBeLessThan(5000); + }); + + it('preserves layout structure under bulk rendering conditions', () => { + const { container } = render( + <> + {Array.from({ length: 25 }).map((_, index) => ( + + ))} + + ); + + const mainElements = container.querySelectorAll('main'); + + expect(mainElements.length).toBe(25); + + mainElements.forEach((element) => { + expect(element.className).toContain('min-h-screen'); + expect(element.className).toContain('flex'); + }); + }); +});