Public source validation / validate (push) Failing after 3m8s
25 lines
1.3 KiB
TypeScript
25 lines
1.3 KiB
TypeScript
import { cleanup, render, screen } from '@testing-library/react';
|
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
|
|
import App from '../../src/App';
|
|
import { routeFromLocation } from '../../src/routes';
|
|
|
|
afterEach(() => { cleanup(); vi.unstubAllGlobals(); window.history.replaceState({}, '', '/'); });
|
|
|
|
describe('expliciete routing', () => {
|
|
it('behoudt de Events-route en projecteert onbekende adressen op 404', () => {
|
|
expect(routeFromLocation('/events')).toBe('/events');
|
|
expect(routeFromLocation('/bestaat-niet')).toBe('/404');
|
|
});
|
|
|
|
it('toont een toegankelijke not-foundpagina in plaats van het overzicht', async () => {
|
|
window.history.replaceState({}, '', '/bestaat-niet');
|
|
vi.stubGlobal('fetch', vi.fn(async () => new Response(JSON.stringify({ version: '1', generatedAt: new Date().toISOString(), overallState: 'unknown', components: [], backup: { state: 'disabled', reason: 'not_configured' }, sourceLag: [] }), { status: 200, headers: { 'Content-Type': 'application/json' } })));
|
|
render(<App />);
|
|
|
|
expect(await screen.findByRole('heading', { level: 1, name: 'Deze pagina bestaat niet' })).toBeVisible();
|
|
expect(screen.getByRole('link', { name: 'Naar overzicht' })).toHaveAttribute('href', '/');
|
|
expect(screen.queryByRole('heading', { name: 'Status nog niet bevestigd' })).not.toBeInTheDocument();
|
|
});
|
|
});
|