feat(settings): implement /settings hub page (E1) — Kachel-Ansicht #55

Merged
marcel merged 16 commits from feat/issue-49-settings-kachel-hub into master 2026-04-10 17:39:42 +02:00
4 changed files with 12 additions and 32 deletions
Showing only changes of commit 6e559d9f9d - Show all commits

View File

@@ -45,12 +45,12 @@
</div>
{:else}
<div class="p-[16px_20px] md:p-[40px_56px]">
{#if data.ctx === 'settings'}
{#if !isOnboarding}
<a href="/settings" class="font-[var(--font-sans)] text-[12px] text-[var(--color-text-muted)] hover:text-[var(--color-text)] mb-4 inline-block">← Einstellungen</a>
{/if}
<h1 class="mb-[8px] font-[var(--font-display)] text-[18px] font-medium md:text-[28px] text-[var(--color-text)]">Vorräte</h1>
<StaplesManager categories={data.categories} context="settings" />
{#if data.ctx === 'settings'}
{#if !isOnboarding}
<p class="mt-4 font-[var(--font-sans)] text-[11px] text-[var(--color-text-muted)]">Änderungen werden automatisch gespeichert. Gilt ab der nächsten Einkaufsliste.</p>
{/if}
</div>

View File

@@ -80,51 +80,31 @@ describe('staples page — settings context (no ctx)', () => {
expect(screen.getByRole('heading', { name: /vorräte/i })).toBeInTheDocument();
});
it('does not render back-link when ctx is null', () => {
it('renders back-link "← Einstellungen" when ctx is null (default settings view)', () => {
render(Page, { props: { data: { categories: mockCategories, ctx: null } } });
expect(screen.queryByRole('link', { name: /einstellungen/i })).not.toBeInTheDocument();
});
});
describe('staples page — ctx=settings (D3)', () => {
beforeEach(() => {
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ ok: true }));
});
afterEach(() => {
vi.unstubAllGlobals();
});
it('renders back-link "← Einstellungen" when ctx=settings', () => {
render(Page, { props: { data: { categories: mockCategories, ctx: 'settings' } } });
const backLink = screen.getByRole('link', { name: /← einstellungen/i });
expect(backLink).toBeInTheDocument();
});
it('back-link points to /settings', () => {
render(Page, { props: { data: { categories: mockCategories, ctx: 'settings' } } });
render(Page, { props: { data: { categories: mockCategories, ctx: null } } });
const backLink = screen.getByRole('link', { name: /← einstellungen/i });
expect(backLink).toHaveAttribute('href', '/settings');
});
it('renders hint text about autosave', () => {
render(Page, { props: { data: { categories: mockCategories, ctx: 'settings' } } });
render(Page, { props: { data: { categories: mockCategories, ctx: null } } });
expect(screen.getByText(/änderungen werden automatisch gespeichert/i)).toBeInTheDocument();
});
it('renders hint text about next shopping list', () => {
render(Page, { props: { data: { categories: mockCategories, ctx: 'settings' } } });
render(Page, { props: { data: { categories: mockCategories, ctx: null } } });
expect(screen.getByText(/gilt ab der nächsten einkaufsliste/i)).toBeInTheDocument();
});
});
describe('staples page — hint text absent in onboarding', () => {
beforeEach(() => {
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ ok: true }));
});
afterEach(() => {
vi.unstubAllGlobals();
it('does not render back-link in onboarding context', () => {
render(Page, { props: { data: { categories: mockCategories, ctx: 'onboarding' } } });
expect(screen.queryByRole('link', { name: /einstellungen/i })).not.toBeInTheDocument();
});
it('does not render hint text in onboarding context', () => {

View File

@@ -18,7 +18,7 @@
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 max-w-[820px]">
<!-- Card 1: Vorräte (inline, conditional content) -->
<a
href="/household/staples?ctx=settings"
href="/household/staples"
class="flex flex-col gap-3 rounded-[var(--radius-xl)] border border-[var(--color-border)] bg-[var(--color-surface)] p-[28px] no-underline text-[var(--color-text)] shadow-[var(--shadow-card)] hover:shadow-[var(--shadow-raised)] hover:border-[#C0BFB8] transition-[box-shadow,border-color] duration-150 ease focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--green-dark)] focus-visible:outline-offset-2 border-l-[3px] border-l-[var(--green-dark)]"
>
<span class="font-[var(--font-sans)] text-[16px] font-medium">Vorräte</span>

View File

@@ -17,10 +17,10 @@ describe('settings page — hub', () => {
expect(screen.getByRole('heading', { name: /einstellungen/i })).toBeInTheDocument();
});
it('renders Vorräte card linking to /household/staples?ctx=settings', () => {
it('renders Vorräte card linking to /household/staples', () => {
render(Page, { props: { data: makeData() } });
const links = screen.getAllByRole('link');
const vorrateLink = links.find((l) => l.getAttribute('href') === '/household/staples?ctx=settings');
const vorrateLink = links.find((l) => l.getAttribute('href') === '/household/staples');
expect(vorrateLink).toBeInTheDocument();
});