feat(frontend): UX review followups — primitives + a11y/UX fixes across 4 passes

New shared primitives:
- Toaster + toast-store, ConfirmSheet, Modal, focusTrap action,
  pullToRefresh action, avatarPalette + initials helper, Skeleton,
  HeartBurst, haptics, export-status store with onClearAuth hook

Critical UX/a11y:
- Replaced window.confirm with branded ConfirmSheet
- Focus management + Escape on every modal (PIN, Lightbox,
  Onboarding, ContextSheet, data-mode sheet, leave-confirm,
  HTML guide, host/admin ban + PIN-display modals)
- Sheet backdrops are real buttons with aria-label
- Silent ApiError catches now surface via global Toaster

Major polish:
- Dark-mode parity on HashtagChips + avatars (shared palette)
- Conditional Export tab in BottomNav (badge dot when ZIP ready)
- Back chevrons on /recover (history-aware) and /export
- Upload composer discard confirmation when content is staged
- Camera segmented Photo/Video shutter
- PIN auto-submit on 4th digit, paste-flash-free (controlled input)
- Welcome-back toast on /feed after PIN recovery

Minor:
- Skeleton states on feed; pull-to-refresh with live drag indicator
- Haptics on like / capture / submit / PIN-copy / onboarding complete
- Comment 500-char counter; quota "Fast voll" / "Limit erreicht" labels
- Onboarding pip ≥24px tap targets; long-press hint step
- overscroll-behavior lock on <html> while feed mounted
- teardownExportStatus wired via onClearAuth (covers 401 + explicit logout)
- ConfirmSheet per-instance titleId; Modal requires titleId or ariaLabel

Tests (7 new Playwright specs):
- 01-auth/pin-auto-submit, 01-auth/back-chevron
- 03-feed/confirm-sheet-delete, 03-feed/toast-on-failure
- 09-mobile/focus-trap, 09-mobile/sheet-escape,
  09-mobile/upload-cancel-confirm

FOLLOWUPS.md captures the deferred AT inert containment work
with acceptance criteria + implementation sketches.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-05-24 22:50:28 +02:00
parent b241ba6415
commit 309c25bc06
36 changed files with 1751 additions and 433 deletions

View File

@@ -0,0 +1,28 @@
/**
* UX polish — back chevrons on /recover and /export. Both pages used to be
* dead-ends for deep-linked users; the chevron mirrors the upload-composer
* header pattern and routes back to /feed.
*/
import { test, expect } from '../../fixtures/test';
test.describe('Navigation — back chevrons', () => {
test('/recover back chevron navigates to /feed (which redirects to /join when unauth)', async ({ page }) => {
await page.goto('/recover');
const back = page.getByTestId('recover-back');
await expect(back).toBeVisible();
await back.click();
// Unauthenticated → /feed mounts and redirects to /join.
await page.waitForURL(/\/(join|feed)$/);
});
test('/export back chevron returns the authenticated guest to /feed', async ({ page, guest, signIn }) => {
const g = await guest('ExportBack');
await signIn(page, g);
await page.goto('/export');
const back = page.getByTestId('export-back');
await expect(back).toBeVisible();
await back.click();
await page.waitForURL('**/feed');
});
});

View File

@@ -0,0 +1,44 @@
/**
* UX polish — PIN inputs auto-submit on the 4th digit. Both the inline
* recovery on /join (name-taken state) and the standalone /recover route
* share the same auto-submit pattern: a $effect watching `pin.length === 4`.
*
* Coverage:
* - Inline recovery on /join: typing 4 digits navigates to /feed without
* a tap on Anmelden.
* - Standalone /recover: typing 4 digits navigates to /feed.
*/
import { test, expect } from '../../fixtures/test';
import { JoinPage, RecoverPage } from '../../page-objects';
import { clearAllStorage } from '../../helpers/storage-helpers';
test.describe('Auth — PIN auto-submit', () => {
test('inline recovery: 4th digit auto-submits and navigates to /feed', async ({ page, guest }) => {
const original = await guest('AutoInline');
await clearAllStorage(page);
const join = new JoinPage(page);
await join.goto();
await join.fillName('AutoInline');
await join.submit();
// Name-taken state: type the PIN one digit at a time, do NOT click submit.
await expect(join.recoveryPinInput).toBeVisible();
await join.recoveryPinInput.pressSequentially(original.pin, { delay: 30 });
// Auto-submit must fire on the 4th digit.
await page.waitForURL('**/feed', { timeout: 5_000 });
});
test('/recover: 4th digit auto-submits when the name is already filled in', async ({ page, guest }) => {
const original = await guest('AutoRecover');
await clearAllStorage(page);
const recover = new RecoverPage(page);
await recover.goto();
await recover.nameInput.fill('AutoRecover');
await recover.pinInput.pressSequentially(original.pin, { delay: 30 });
await page.waitForURL('**/feed', { timeout: 5_000 });
});
});

View File

@@ -0,0 +1,62 @@
/**
* Critical UX fix — delete confirmation is now a branded bottom-sheet, not
* the native window.confirm(). Long-press on an own upload → Löschen
* → ConfirmSheet opens. Cancel keeps the post; Confirm removes it.
*
* The window.confirm path was jarring on mobile and broke the consistent
* bottom-sheet design language; the ConfirmSheet uses the same shell as
* ContextSheet and traps focus while open.
*/
import { test, expect } from '../../fixtures/test';
import { uploadRaw } from '../../helpers/upload-client';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
const SAMPLE_JPG = join(process.cwd(), 'fixtures', 'media', 'sample.jpg');
async function seedUpload(token: string): Promise<{ id: string }> {
const res = await uploadRaw(token, readFileSync(SAMPLE_JPG), {
filename: 'cs.jpg',
contentType: 'image/jpeg',
caption: 'Confirm-sheet fixture',
});
if (res.status !== 201) throw new Error(`Upload seed failed (${res.status})`);
return (await res.json()) as { id: string };
}
test.describe('Feed — ConfirmSheet replaces window.confirm for deletion', () => {
test('Cancel keeps the post; Confirm removes it', async ({ page, guest, signIn }) => {
const g = await guest('CSDelete');
await seedUpload(g.jwt);
await signIn(page, g);
await page.goto('/feed');
const card = page.locator('article').filter({ hasText: g.displayName }).first();
await expect(card).toBeVisible({ timeout: 10_000 });
// Open the desktop kebab (long-press is exercised in 09-mobile; we want
// both code paths covered without depending on touch).
await card.getByRole('button', { name: 'Mehr Aktionen' }).click();
// Context sheet appears. The Löschen action is wired to set pendingDeleteId,
// which opens the ConfirmSheet (data-testid="confirm-sheet").
await page.getByRole('button', { name: /löschen/i }).click();
const confirmSheet = page.getByTestId('confirm-sheet');
await expect(confirmSheet).toBeVisible();
await expect(confirmSheet).toContainText(/beitrag löschen/i);
// Cancel — sheet closes, post stays.
await page.getByTestId('confirm-sheet-cancel').click();
await expect(confirmSheet).not.toBeVisible();
await expect(card).toBeVisible();
// Reopen, confirm — post is removed from the DOM.
await card.getByRole('button', { name: 'Mehr Aktionen' }).click();
await page.getByRole('button', { name: /löschen/i }).click();
await expect(page.getByTestId('confirm-sheet')).toBeVisible();
await page.getByTestId('confirm-sheet-confirm').click();
await expect(page.getByTestId('confirm-sheet')).not.toBeVisible();
await expect(card).not.toBeVisible({ timeout: 5_000 });
});
});

View File

@@ -0,0 +1,53 @@
/**
* The toast store + <Toaster> primitive surfaces ApiError messages on
* user-initiated actions that previously failed silently (catch { ignore }).
* This spec intercepts the like POST and forces a 429 to assert the German
* error message reaches the user via the global toast region.
*/
import { test, expect } from '../../fixtures/test';
import { uploadRaw } from '../../helpers/upload-client';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
const SAMPLE_JPG = join(process.cwd(), 'fixtures', 'media', 'sample.jpg');
async function seedUpload(token: string): Promise<{ id: string }> {
const res = await uploadRaw(token, readFileSync(SAMPLE_JPG), {
filename: 'tf.jpg',
contentType: 'image/jpeg',
caption: 'Toast fixture',
});
if (res.status !== 201) throw new Error(`Upload seed failed (${res.status})`);
return (await res.json()) as { id: string };
}
test.describe('Feed — error toast on user action failures', () => {
test('like POST 429 surfaces a German error toast', async ({ page, guest, signIn }) => {
const author = await guest('ToastAuthor');
const liker = await guest('ToastLiker');
await seedUpload(author.jwt);
await signIn(page, liker);
// Intercept the like endpoint with a forced rate-limit response.
await page.route('**/api/v1/upload/*/like', (route) =>
route.fulfill({
status: 429,
contentType: 'application/json',
body: JSON.stringify({ error: 'rate_limited', message: 'Zu viele Anfragen — bitte kurz warten.' }),
})
);
await page.goto('/feed');
const card = page.locator('article').filter({ hasText: author.displayName }).first();
await expect(card).toBeVisible({ timeout: 10_000 });
// Click the like button in the actions row — first visible match inside the card.
await card.locator('button').filter({ hasText: /\d+/ }).first().click();
// The toast is rendered inside the global Toaster region with aria-live="polite".
const toast = page.getByTestId('toast').first();
await expect(toast).toBeVisible({ timeout: 3_000 });
await expect(toast).toContainText(/Zu viele Anfragen/i);
await expect(toast).toHaveAttribute('data-toast-tone', 'error');
});
});

View File

@@ -0,0 +1,54 @@
/**
* Critical a11y fix — the focusTrap action keeps Tab within open modals
* and lets Escape dismiss them, then restores focus to the originating
* element. This spec covers the LightboxModal, which is the most-used
* focus-trap consumer in the app.
*/
import { test, expect } from '../../fixtures/test';
import { uploadRaw } from '../../helpers/upload-client';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
const SAMPLE_JPG = join(process.cwd(), 'fixtures', 'media', 'sample.jpg');
async function seedUpload(token: string): Promise<{ id: string }> {
const res = await uploadRaw(token, readFileSync(SAMPLE_JPG), {
filename: 'ft.jpg',
contentType: 'image/jpeg',
caption: 'Focus-trap fixture',
});
if (res.status !== 201) throw new Error(`Upload seed failed (${res.status})`);
return (await res.json()) as { id: string };
}
test.describe('Mobile a11y — focus trap on LightboxModal', () => {
test('Escape closes the lightbox and Tab cycles inside', async ({ page, guest, signIn }) => {
const g = await guest('FocusTrap');
await seedUpload(g.jwt);
await signIn(page, g);
await page.goto('/feed');
const card = page.locator('article').filter({ hasText: g.displayName }).first();
const trigger = card.getByRole('button', { name: 'Bild vergrößern' });
await expect(trigger).toBeVisible({ timeout: 10_000 });
await trigger.click();
// Lightbox is role="dialog" aria-modal="true".
const lightbox = page.locator('[role="dialog"][aria-modal="true"]').filter({ has: page.locator('img, video') });
await expect(lightbox).toBeVisible();
// After opening, focus should be inside the lightbox (trap autoFocus moves
// focus to the first focusable). Verify by checking activeElement is
// contained.
await expect.poll(async () => {
return await page.evaluate(() => {
const dlg = document.querySelector('[role="dialog"][aria-modal="true"]');
return !!dlg && dlg.contains(document.activeElement);
});
}, { timeout: 2_000 }).toBe(true);
// Escape dismisses the lightbox.
await page.keyboard.press('Escape');
await expect(lightbox).not.toBeVisible({ timeout: 2_000 });
});
});

View File

@@ -0,0 +1,37 @@
/**
* Critical a11y fix — bottom sheets on /account (data-mode warning and
* leave-confirm) now respond to Escape via the focusTrap action. They were
* previously click-only, blocking keyboard / switch-control users.
*/
import { test, expect } from '../../fixtures/test';
test.describe('Mobile a11y — sheets dismiss on Escape', () => {
test('data-mode warning sheet closes on Escape', async ({ page, guest, signIn }) => {
const g = await guest('SheetEsc');
await signIn(page, g);
await page.goto('/account');
// Click the "Original" radio in the Datennutzung section to open the warning sheet.
const originalRadio = page.getByRole('radio', { name: /Original$/i });
await originalRadio.click();
const sheet = page.locator('[role="dialog"][aria-labelledby="data-mode-title"]');
await expect(sheet).toBeVisible();
await page.keyboard.press('Escape');
await expect(sheet).not.toBeVisible({ timeout: 2_000 });
});
test('leave-confirm sheet (built on ConfirmSheet) closes on Escape', async ({ page, guest, signIn }) => {
const g = await guest('LeaveEsc');
await signIn(page, g);
await page.goto('/account');
await page.getByRole('button', { name: /Event verlassen/i }).click();
const sheet = page.getByTestId('confirm-sheet');
await expect(sheet).toBeVisible();
await page.keyboard.press('Escape');
await expect(sheet).not.toBeVisible({ timeout: 2_000 });
});
});

View File

@@ -0,0 +1,42 @@
/**
* UX fix — tapping X on the upload composer used to silently discard
* staged files + caption. Now opens a ConfirmSheet so a mistap from the
* corner is recoverable.
*/
import { test, expect } from '../../fixtures/test';
test.describe('Mobile — upload composer cancel confirmation', () => {
test('typing a caption then tapping X opens the discard ConfirmSheet', async ({ page, guest, signIn }) => {
const g = await guest('CancelConf');
await signIn(page, g);
// Land on /upload directly (no staged files; the pending-upload-store is
// empty). Typing into the caption flips the dirty flag.
await page.goto('/upload');
const caption = page.getByTestId('upload-caption');
await expect(caption).toBeVisible();
await caption.fill('a meaningful caption that I do not want to lose');
// Tap the close (X) button in the composer header.
await page.getByRole('button', { name: 'Abbrechen' }).click();
const sheet = page.getByTestId('confirm-sheet');
await expect(sheet).toBeVisible();
await expect(sheet).toContainText(/Verwerfen/);
// Cancel — sheet closes, caption is preserved.
await page.getByTestId('confirm-sheet-cancel').click();
await expect(sheet).not.toBeVisible();
await expect(caption).toHaveValue(/a meaningful caption/);
});
test('with no content, tapping X navigates directly to /feed', async ({ page, guest, signIn }) => {
const g = await guest('CancelEmpty');
await signIn(page, g);
await page.goto('/upload');
await page.getByRole('button', { name: 'Abbrechen' }).click();
await page.waitForURL('**/feed', { timeout: 3_000 });
});
});