Adds front-end set-up

This commit is contained in:
2026-06-20 17:04:17 +02:00
parent efd1569c26
commit 7dfc3a9692
62 changed files with 6875 additions and 3 deletions
+28
View File
@@ -0,0 +1,28 @@
import { describe, expect, it } from 'vitest';
import { screen } from '@testing-library/react';
import { renderApp, mockAuthenticated, mockGuest } from '@/test/utils';
describe('Route guards (BR-U1-05, BR-U1-06)', () => {
it('redirects an unauthenticated user from a protected route to /login', async () => {
mockGuest();
renderApp('/dashboard');
expect(await screen.findByTestId('login-form-submit-button')).toBeInTheDocument();
expect(screen.queryByTestId('dashboard-title')).not.toBeInTheDocument();
});
it('allows an authenticated user to reach a protected route', async () => {
mockAuthenticated();
renderApp('/dashboard');
expect(await screen.findByTestId('dashboard-title')).toBeInTheDocument();
});
it('redirects an authenticated user away from /login to the dashboard', async () => {
mockAuthenticated();
renderApp('/login');
expect(await screen.findByTestId('dashboard-title')).toBeInTheDocument();
expect(screen.queryByTestId('login-form-submit-button')).not.toBeInTheDocument();
});
});