fix(e2e): fix annotation delete test and harden comments fetch
Some checks failed
CI / E2E Tests (pull_request) Has been cancelled
CI / Unit & Component Tests (push) Successful in 2m30s
CI / Backend Unit Tests (push) Successful in 2m15s
CI / E2E Tests (push) Successful in 22m47s
CI / Unit & Component Tests (pull_request) Has been cancelled
CI / Backend Unit Tests (pull_request) Has been cancelled

- Add aria-label="Kommentare anzeigen" to annotation container div so
  getByRole('button', { name: /annotation löschen/i }) no longer
  matches the container (its name was previously inherited from the
  child delete button, causing the test to click the wrong element)
- Wrap the server-side comments fetch in a .catch and try/catch so a
  network error or non-JSON response never crashes the document load

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit was merged in pull request #57.
This commit is contained in:
Marcel
2026-03-24 12:27:15 +01:00
parent fd03e56c85
commit 34c66f80fc
2 changed files with 10 additions and 2 deletions

View File

@@ -120,6 +120,7 @@ const containerStyle = $derived(
data-annotation
role="button"
tabindex="0"
aria-label="Kommentare anzeigen"
onclick={() => onAnnotationClick?.(annotation.id)}
onkeydown={(e) => { if (e.key === 'Enter' || e.key === ' ') onAnnotationClick?.(annotation.id); }}
onmouseenter={() => (hoveredId = annotation.id)}

View File

@@ -10,7 +10,7 @@ export async function load({ params, fetch }) {
const [docResult, commentsRes] = await Promise.all([
api.GET('/api/documents/{id}', { params: { path: { id } } }),
fetch(`${base}/api/documents/${id}/comments`)
fetch(`${base}/api/documents/${id}/comments`).catch(() => null)
]);
if (docResult.response.status === 401) throw redirect(302, '/login');
@@ -20,7 +20,14 @@ export async function load({ params, fetch }) {
throw error(docResult.response.status, getErrorMessage(code));
}
const comments = commentsRes.ok ? await commentsRes.json() : [];
let comments: unknown[] = [];
if (commentsRes?.ok) {
try {
comments = await commentsRes.json();
} catch {
// ignore invalid response
}
}
return { document: docResult.data!, comments };
}