feat(e2e): seed admin notifications + resume strip for dashboard proofshots
Some checks failed
CI / Unit & Component Tests (push) Has been cancelled
CI / Backend Unit Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Unit & Component Tests (pull_request) Failing after 2m34s
CI / Backend Unit Tests (pull_request) Failing after 2m49s
CI / E2E Tests (pull_request) Failing after 1h24m49s

- captureProofshots() now accepts an optional setup(page) callback that
  runs before each screenshot's page.goto(), so localStorage can be
  injected reliably without loading a backend-dependent page
- dashboard-screenshots.spec.ts seeds 2 notifications (MENTION + REPLY)
  for admin via direct DB insert in beforeAll, cleans up in afterAll
- localStorage.familienarchiv.lastVisited injected directly via
  page.evaluate() — no fragile document page navigation needed
- Updated screenshots committed (all 6 now show all 4 widgets)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-03-29 11:46:39 +02:00
parent 3e76ef5281
commit 7eda0aefcc
8 changed files with 91 additions and 5 deletions

View File

@@ -1,14 +1,23 @@
/**
* Shared proofshot helper for Playwright.
*
* Usage in any spec file:
* Basic usage:
* import { captureProofshots } from './proofshots';
* captureProofshots('/persons', 'persons');
*
* This registers one test per viewport × theme combination.
* With per-test setup (e.g. seed localStorage before navigation):
* captureProofshots('/persons', 'persons', {
* setup: async (page) => {
* await page.goto('/persons/some-id'); // populates any localStorage state
* }
* });
*
* The setup callback runs before each screenshot's page.goto(url), so any
* localStorage values it writes persist into the main navigation.
*
* Screenshots are saved to proofshot-artifacts/{featureName}/.
*/
import { test } from '@playwright/test';
import { type Page, test } from '@playwright/test';
import path from 'path';
import fs from 'fs';
import { fileURLToPath } from 'url';
@@ -21,20 +30,38 @@ const viewports = [
{ name: 'desktop', width: 1440, height: 900 }
];
interface ProofshotOptions {
/**
* Optional async callback that runs before each screenshot's page.goto(url).
* Use it to seed localStorage, visit a prerequisite page, etc.
*/
setup?: (page: Page) => Promise<void>;
}
/**
* Registers Playwright tests that navigate to `url`, apply each theme,
* and capture full-page screenshots at all standard viewports.
*
* @param url The path to screenshot (e.g. '/', '/persons', '/admin')
* @param featureName Used as the output directory name and screenshot file prefix
* @param options Optional setup callback and other options
*/
export function captureProofshots(url: string, featureName: string): void {
export function captureProofshots(
url: string,
featureName: string,
options?: ProofshotOptions
): void {
const outDir = path.join(__dirname, '../../proofshot-artifacts', featureName);
fs.mkdirSync(outDir, { recursive: true });
for (const vp of viewports) {
for (const theme of ['light', 'dark'] as const) {
test(`${featureName} ${vp.name} ${theme}`, async ({ page }) => {
// Run optional setup before main navigation (e.g. seed localStorage)
if (options?.setup) {
await options.setup(page);
}
await page.setViewportSize({ width: vp.width, height: vp.height });
await page.goto(url);