fix(review): GeschichtenCard uses GeschichteSummary type; focus-visible on journey links; fix stale tests
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 3m17s
CI / OCR Service Tests (pull_request) Successful in 23s
CI / Backend Unit Tests (pull_request) Successful in 3m42s
CI / fail2ban Regex (pull_request) Successful in 47s
CI / Semgrep Security Scan (pull_request) Successful in 22s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m4s
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 3m17s
CI / OCR Service Tests (pull_request) Successful in 23s
CI / Backend Unit Tests (pull_request) Successful in 3m42s
CI / fail2ban Regex (pull_request) Successful in 47s
CI / Semgrep Security Scan (pull_request) Successful in 22s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m4s
- GeschichtenCard.svelte: use GeschichteSummary instead of Geschichte (list endpoint returns summaries; no items/createdAt/updatedAt needed) - GeschichtenCard.svelte.test.ts: factory returns GeschichteSummary with lean author shape; drop Geschichte-only fields (createdAt, groups, etc.) - geschichten/[id]/+page.svelte: add focus:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring to journey item document links (WCAG 2.4.7) - page.svelte.test.ts ([id]): replace stale documents[] factory field with items[]; test now checks placeholder text + note caption - page.svelte.test.ts (new): remove removed initialDocuments from baseData; rename test to reflect that only initialPersons is passed through Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,10 +4,10 @@ import type { components } from '$lib/generated/api';
|
||||
import { plainExcerpt } from '$lib/shared/utils/extractText';
|
||||
import { formatDate } from '$lib/shared/utils/date';
|
||||
|
||||
type Geschichte = components['schemas']['Geschichte'];
|
||||
type GeschichteSummary = components['schemas']['GeschichteSummary'];
|
||||
|
||||
interface Props {
|
||||
geschichten: Geschichte[];
|
||||
geschichten: GeschichteSummary[];
|
||||
personId: string;
|
||||
personName: string;
|
||||
canWrite: boolean;
|
||||
@@ -18,12 +18,12 @@ let { geschichten, personId, personName, canWrite }: Props = $props();
|
||||
const visible = $derived(geschichten.slice(0, 3));
|
||||
const hasOverflow = $derived(geschichten.length >= 3);
|
||||
|
||||
function formatPublishedDate(g: Geschichte): string | null {
|
||||
function formatPublishedDate(g: GeschichteSummary): string | null {
|
||||
if (!g.publishedAt) return null;
|
||||
return formatDate(g.publishedAt.slice(0, 10), 'short');
|
||||
}
|
||||
|
||||
function authorName(g: Geschichte): string {
|
||||
function authorName(g: GeschichteSummary): string {
|
||||
const a = g.author;
|
||||
if (!a) return '';
|
||||
const full = [a.firstName, a.lastName].filter(Boolean).join(' ').trim();
|
||||
|
||||
@@ -4,11 +4,11 @@ import { page } from 'vitest/browser';
|
||||
import GeschichtenCard from './GeschichtenCard.svelte';
|
||||
import type { components } from '$lib/generated/api';
|
||||
|
||||
type Geschichte = components['schemas']['Geschichte'];
|
||||
type GeschichteSummary = components['schemas']['GeschichteSummary'];
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
const makeGeschichte = (overrides: Record<string, unknown> = {}): Geschichte =>
|
||||
const makeGeschichte = (overrides: Record<string, unknown> = {}): GeschichteSummary =>
|
||||
({
|
||||
id: 'g1',
|
||||
title: 'Reise nach Berlin',
|
||||
@@ -16,25 +16,16 @@ const makeGeschichte = (overrides: Record<string, unknown> = {}): Geschichte =>
|
||||
status: 'PUBLISHED' as const,
|
||||
type: 'STORY' as const,
|
||||
publishedAt: '2026-04-15T10:00:00Z',
|
||||
createdAt: '2026-04-01T00:00:00Z',
|
||||
updatedAt: '2026-04-15T10:00:00Z',
|
||||
author: {
|
||||
id: 'u1',
|
||||
email: 'a@b',
|
||||
firstName: 'Anna',
|
||||
lastName: 'Schmidt',
|
||||
color: '#ccc',
|
||||
enabled: true,
|
||||
notifyOnReply: false,
|
||||
notifyOnMention: false,
|
||||
groups: [],
|
||||
createdAt: '2024-01-01T00:00:00'
|
||||
lastName: 'Schmidt'
|
||||
},
|
||||
...overrides
|
||||
}) as Geschichte;
|
||||
}) as GeschichteSummary;
|
||||
|
||||
const baseProps = (overrides: Record<string, unknown> = {}) => ({
|
||||
geschichten: [] as ReturnType<typeof makeGeschichte>[],
|
||||
geschichten: [] as GeschichteSummary[],
|
||||
personId: 'p-1',
|
||||
personName: 'Anna Schmidt',
|
||||
canWrite: false,
|
||||
|
||||
@@ -108,7 +108,7 @@ async function handleDelete() {
|
||||
<li>
|
||||
<a
|
||||
href="/documents/{item.documentId}"
|
||||
class="block rounded border border-line bg-surface px-4 py-3 font-serif text-base text-ink hover:bg-muted"
|
||||
class="block rounded border border-line bg-surface px-4 py-3 font-serif text-base text-ink hover:bg-muted focus:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring"
|
||||
>
|
||||
{m.geschichten_document_link_placeholder()}
|
||||
</a>
|
||||
|
||||
@@ -19,7 +19,7 @@ const baseGeschichte = (overrides: Record<string, unknown> = {}) => ({
|
||||
email: string;
|
||||
} | null,
|
||||
persons: [] as { id: string; displayName: string }[],
|
||||
documents: [] as { id: string; title: string; documentDate?: string | null }[],
|
||||
items: [] as { id: string; documentId?: string; position: number; note?: string }[],
|
||||
...overrides
|
||||
});
|
||||
|
||||
@@ -130,20 +130,21 @@ describe('geschichten/[id] page', () => {
|
||||
await expect.element(page.getByText('Erwähnte Dokumente')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders the documents section when there are linked documents', async () => {
|
||||
it('renders the documents section when there are linked journey items', async () => {
|
||||
render(GeschichtePage, {
|
||||
context: new Map([[CONFIRM_KEY, createConfirmService()]]),
|
||||
props: {
|
||||
data: baseData({
|
||||
geschichte: baseGeschichte({
|
||||
documents: [{ id: 'd1', title: 'Brief 1923', documentDate: '1923-04-15' }]
|
||||
items: [{ id: 'item1', documentId: 'd1', position: 0, note: 'Brief aus 1923' }]
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
await expect.element(page.getByText('Erwähnte Dokumente')).toBeVisible();
|
||||
await expect.element(page.getByText('Brief 1923')).toBeVisible();
|
||||
await expect.element(page.getByText('Dokument öffnen')).toBeVisible();
|
||||
await expect.element(page.getByText('Brief aus 1923')).toBeVisible();
|
||||
});
|
||||
|
||||
it('renders edit and delete actions when canBlogWrite is true', async () => {
|
||||
|
||||
@@ -21,8 +21,7 @@ const { default: GeschichtenNewPage } = await import('./+page.svelte');
|
||||
afterEach(cleanup);
|
||||
|
||||
const baseData = {
|
||||
initialPersons: [] as { id: string; displayName: string }[],
|
||||
initialDocuments: [] as { id: string; title: string }[]
|
||||
initialPersons: [] as { id: string; displayName: string }[]
|
||||
};
|
||||
|
||||
describe('geschichten/new page', () => {
|
||||
@@ -53,18 +52,15 @@ describe('geschichten/new page', () => {
|
||||
expect(inputs.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('passes initialPersons and initialDocuments through to the editor', async () => {
|
||||
it('passes initialPersons through to the editor', async () => {
|
||||
render(GeschichtenNewPage, {
|
||||
props: {
|
||||
data: {
|
||||
initialPersons: [{ id: 'p1', displayName: 'Anna Schmidt' }],
|
||||
initialDocuments: [{ id: 'd1', title: 'Brief 1923' }]
|
||||
initialPersons: [{ id: 'p1', displayName: 'Anna Schmidt' }]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Both should appear somewhere in the rendered editor
|
||||
await expect.element(page.getByText('Anna Schmidt')).toBeVisible();
|
||||
await expect.element(page.getByText('Brief 1923')).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user