feat(#145): add DashboardResumeStrip component
- Component reads familienarchiv.lastVisited from localStorage and shows a 'Zuletzt geöffnet' link to the last-visited document - Renders nothing when no localStorage entry exists - Document detail page writes id+title to localStorage on mount Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { describe, it, expect, afterEach } from 'vitest';
|
||||
import { cleanup, render } from 'vitest-browser-svelte';
|
||||
import { page } from 'vitest/browser';
|
||||
|
||||
import DashboardResumeStrip from './DashboardResumeStrip.svelte';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
describe('DashboardResumeStrip', () => {
|
||||
it('renders nothing when no last-visited document in localStorage', async () => {
|
||||
render(DashboardResumeStrip, {});
|
||||
const strip = page.getByTestId('resume-strip');
|
||||
await expect.element(strip).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the strip with link when localStorage has a document', async () => {
|
||||
localStorage.setItem(
|
||||
'familienarchiv.lastVisited',
|
||||
JSON.stringify({ id: 'doc-123', title: 'Geburtsurkunde 1920' })
|
||||
);
|
||||
render(DashboardResumeStrip, {});
|
||||
const strip = page.getByTestId('resume-strip');
|
||||
await expect.element(strip).toBeInTheDocument();
|
||||
const link = page.getByRole('link', { name: /Geburtsurkunde 1920/ });
|
||||
await expect.element(link).toBeInTheDocument();
|
||||
await expect.element(link).toHaveAttribute('href', '/documents/doc-123');
|
||||
});
|
||||
|
||||
it('uses title fallback text when title is empty', async () => {
|
||||
localStorage.setItem(
|
||||
'familienarchiv.lastVisited',
|
||||
JSON.stringify({ id: 'doc-456', title: '' })
|
||||
);
|
||||
render(DashboardResumeStrip, {});
|
||||
const strip = page.getByTestId('resume-strip');
|
||||
await expect.element(strip).toBeInTheDocument();
|
||||
const link = page.getByRole('link');
|
||||
await expect.element(link).toHaveAttribute('href', '/documents/doc-456');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user