feat(dashboard): add reader dashboard components

Adds 5 new components for the permission-gated reader layout:
- ReaderStatsStrip: stat tiles (documents / persons / stories) linking to list pages
- ReaderPersonChips: top-N persons by doc count with avatar + name
- ReaderDraftsModule: blog draft list for BLOG_WRITE users
- ReaderRecentDocs: 5 most-recently-updated docs with Neu/Aktualisiert badge
- ReaderRecentStories: 3 latest published stories with 150-char HTML-stripped excerpt

Each component ships with a vitest-browser spec covering the key assertions.
Avatar color/initials logic is inlined to satisfy $lib/shared → $lib/person
boundary rule.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-07 21:39:35 +02:00
committed by marcel
parent 9b82621770
commit 4d9234244e
12 changed files with 555 additions and 4 deletions

View File

@@ -0,0 +1,56 @@
import { describe, it, expect, afterEach } from 'vitest';
import { cleanup, render } from 'vitest-browser-svelte';
import { page } from 'vitest/browser';
import ReaderDraftsModule from './ReaderDraftsModule.svelte';
import type { components } from '$lib/generated/api';
type Geschichte = components['schemas']['Geschichte'];
afterEach(() => {
cleanup();
});
const draft1: Geschichte = {
id: 'g1',
title: 'Mein erster Entwurf',
status: 'DRAFT',
createdAt: '2025-01-01T00:00:00Z',
updatedAt: '2025-01-02T00:00:00Z'
};
const draft2: Geschichte = {
id: 'g2',
title: 'Zweiter Entwurf',
status: 'DRAFT',
createdAt: '2025-02-01T00:00:00Z',
updatedAt: '2025-02-01T00:00:00Z'
};
describe('ReaderDraftsModule', () => {
it('renders a link to /geschichten/{id}/edit for each draft', async () => {
render(ReaderDraftsModule, { drafts: [draft1, draft2] });
const link1 = page.getByRole('link', { name: /Mein erster Entwurf/ });
await expect.element(link1).toHaveAttribute('href', '/geschichten/g1/edit');
const link2 = page.getByRole('link', { name: /Zweiter Entwurf/ });
await expect.element(link2).toHaveAttribute('href', '/geschichten/g2/edit');
});
it('shows heading "Meine Entwürfe"', async () => {
render(ReaderDraftsModule, { drafts: [draft1] });
const heading = page.getByRole('heading', { name: /Meine Entwürfe/i });
await expect.element(heading).toBeInTheDocument();
});
it('shows empty state when drafts is empty', async () => {
render(ReaderDraftsModule, { drafts: [] });
const emptyText = page.getByText(/Keine Entwürfe/i);
await expect.element(emptyText).toBeInTheDocument();
});
it('does not show empty state when drafts are present', async () => {
render(ReaderDraftsModule, { drafts: [draft1] });
const emptyText = page.getByText(/Keine Entwürfe/i);
await expect.element(emptyText).not.toBeInTheDocument();
});
});