fix(e2e): fix Playwright E2E test suite for CI

- Replace __dirname with fileURLToPath(import.meta.url) for ESM compatibility
- Start SvelteKit dev server on port 3000 with 120s webServer timeout
- Add data-hydrated attribute (set in onMount) so tests wait for hydration
- Fix nav active class assertions: text-brand-navy (not border-brand-navy)
- Fix filter button selector: exact match to avoid matching "Alle Filter löschen"
- Fix date validation test: use pressSequentially('99') to trigger dateInvalid
- Fix person/document search: navigate directly to URL with query param
  (avoids debounced oninput → goto race condition in CI)
- Fix heading selector: level: 1 to avoid strict-mode with h1+h2 on page
- Fix auth redirect: return 401 from handleFetch instead of throwing redirect

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-03-19 11:08:56 +01:00
parent 9f3f022ec0
commit 56cbd290e3
7 changed files with 47 additions and 27 deletions

View File

@@ -3,6 +3,16 @@ import { paraglideMiddleware } from '$lib/paraglide/server';
import { sequence } from '@sveltejs/kit/hooks';
import { env } from 'process';
const PUBLIC_PATHS = ['/login', '/logout'];
const handleAuth: Handle = async ({ event, resolve }) => {
const isPublic = PUBLIC_PATHS.some((p) => event.url.pathname.startsWith(p));
if (!isPublic && !event.locals.user) {
throw redirect(302, '/login');
}
return resolve(event);
};
const handleParaglide: Handle = ({ event, resolve }) => paraglideMiddleware(event.request, ({ request, locale }) => {
event.request = request;
@@ -43,7 +53,7 @@ export const handleFetch: HandleFetch = async ({ event, request, fetch }) => {
const token = event.cookies.get('auth_token');
if (!token) {
throw redirect(302, '/login');
return new Response('Unauthorized', { status: 401 });
}
// Clone the request first to preserve the body
@@ -63,4 +73,4 @@ export const handleFetch: HandleFetch = async ({ event, request, fetch }) => {
return fetch(request);
};
export const handle = sequence(userGroup, handleParaglide);
export const handle = sequence(userGroup, handleAuth, handleParaglide);