website refactor

This commit is contained in:
2026-01-18 23:43:58 +01:00
parent 7c1cf62d4e
commit c0559d8b48
76 changed files with 39 additions and 89 deletions

View File

@@ -1,50 +0,0 @@
import { render, screen, fireEvent } from '@testing-library/react';
import { describe, it, expect, vi } from 'vitest';
import { ServerErrorPageClient } from './ServerErrorPageClient';
import { useRouter } from 'next/navigation';
vi.mock('next/navigation', () => ({
useRouter: vi.fn(),
}));
describe('ServerErrorPageClient', () => {
it('renders the server error page with correct content', () => {
const push = vi.fn();
(useRouter as any).mockReturnValue({ push });
render(<ServerErrorPageClient />);
expect(screen.getByText('CRITICAL_SYSTEM_FAILURE')).toBeDefined();
expect(screen.getByText(/The application engine encountered an unrecoverable state/)).toBeDefined();
expect(screen.getByText(/Internal Server Error/)).toBeDefined();
});
it('handles home navigation', () => {
const push = vi.fn();
(useRouter as any).mockReturnValue({ push });
render(<ServerErrorPageClient />);
const homeButton = screen.getByText('Return to Pits');
fireEvent.click(homeButton);
expect(push).toHaveBeenCalledWith('/');
});
it('handles retry via page reload', () => {
const push = vi.fn();
(useRouter as any).mockReturnValue({ push });
const reloadFn = vi.fn();
vi.stubGlobal('location', { reload: reloadFn });
render(<ServerErrorPageClient />);
const retryButton = screen.getByText('Retry Session');
fireEvent.click(retryButton);
expect(reloadFn).toHaveBeenCalled();
vi.unstubAllGlobals();
});
});

View File

@@ -1,40 +0,0 @@
'use client';
import React from 'react';
import { useRouter } from 'next/navigation';
import { routes } from '@/lib/routing/RouteConfig';
import { ServerErrorTemplate, type ServerErrorViewData } from '@/templates/ServerErrorTemplate';
/**
* ServerErrorPageClient
*
* Client-side entry point for the 500 page.
* Manages navigation and retry logic and wires it to the template.
*/
export function ServerErrorPageClient() {
const router = useRouter();
const handleHome = () => {
router.push(routes.public.home);
};
const handleRetry = () => {
window.location.reload();
};
const error = new Error('Internal Server Error') as Error & { digest?: string };
error.digest = 'HTTP_500';
const viewData: ServerErrorViewData = {
error,
incidentId: error.digest
};
return (
<ServerErrorTemplate
viewData={viewData}
onRetry={handleRetry}
onHome={handleHome}
/>
);
}

View File

@@ -1,4 +1,4 @@
import { ServerErrorPageClient } from './ServerErrorPageClient';
import { ServerErrorPageClient } from '@/client-wrapper/ServerErrorPageClient';
/**
* Custom500Page