The Playwright suite had no linter and no formatter — only tsc. Add flat-config ESLint
(typescript-eslint, type-aware) and Prettier (2-space, matching the suite's style).
Rules keep the ones that catch real TEST bugs and drop the noise:
- no-floating-promises KEPT — an un-awaited request/assertion can let a test end before it runs,
passing vacuously. It caught one: the SSE reader loop in sse-listener is now explicitly `void`.
- no-unused-vars KEPT — caught three dead bindings (an unused adminToken fixture arg, an unused
`api` arg, an unused JPEG_MAGIC import), all removed.
- no-explicit-any OFF — all test code; `any` is the honest type for an untyped res.json() body or
a page.evaluate() return.
- no-empty-pattern OFF — Playwright's dependency-free fixtures are `async ({}, use) => {}`.
Refactor: `const BASE = process.env.E2E_FRONTEND_URL ?? '...'` was redeclared verbatim in 23
files — extracted to helpers/env.ts and imported, so a port/scheme change is one edit not a sweep.
Then `prettier --write`. Verified: eslint clean, tsc clean, prettier clean, desktop suite 210
passed / 1 skipped. (One mobile spec flaked once under retries:0 — a pre-existing cross-test
reflow-timing vector from the flakiness audit, not this change: the each-key edit is stable across
16 isolated runs and a clean full mobile re-run.)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
88 lines
3.3 KiB
TypeScript
88 lines
3.3 KiB
TypeScript
/**
|
|
* USER_JOURNEYS.md §9 — host locks/unlocks the event. We use the API for
|
|
* the host action so the test isn't blocked on the host dashboard UI being
|
|
* complete, but assert the SSE-driven "uploads gesperrt" banner appears
|
|
* for a guest who's already viewing the feed.
|
|
*/
|
|
import { test, expect } from '../../fixtures/test';
|
|
import { BASE } from '../../helpers/env';
|
|
|
|
test.describe('Host — event lock', () => {
|
|
test('closing the event via API sets uploads_locked_at; opening clears it', async ({
|
|
host,
|
|
api,
|
|
}) => {
|
|
// The frontend doesn't (yet) render a per-guest "uploads locked" banner on
|
|
// the feed — that's the journey §9 banner, currently a UX gap. We assert
|
|
// the API + DB contract here and leave the banner check for once it ships.
|
|
|
|
await api.closeEvent(host.jwt);
|
|
const evRes = await fetch(`${BASE}/api/v1/host/event`, {
|
|
headers: { Authorization: `Bearer ${host.jwt}` },
|
|
});
|
|
expect(evRes.status).toBe(200);
|
|
const body: any = await evRes.json();
|
|
expect(body.uploads_locked).toBe(true);
|
|
|
|
await api.openEvent(host.jwt);
|
|
const evRes2 = await fetch(`${BASE}/api/v1/host/event`, {
|
|
headers: { Authorization: `Bearer ${host.jwt}` },
|
|
});
|
|
const body2: any = await evRes2.json();
|
|
expect(body2.uploads_locked).toBe(false);
|
|
});
|
|
|
|
test.fixme('event-closed SSE renders a "uploads gesperrt" banner in the feed (planned UX)', async () => {
|
|
// Currently no UI consumes the event-closed SSE on /feed. Add this banner
|
|
// and flip fixme to test once it lands.
|
|
});
|
|
|
|
// Locking is uploads-only: likes, comments and browsing stay open on a closed
|
|
// event (USER_JOURNEYS §9.3, FEATURES capability matrix). Only new uploads are
|
|
// rejected. (An earlier revision froze social interaction too; that contradicted
|
|
// the documented behavior and was reverted.)
|
|
test('a closed event still allows likes and comments, but blocks new uploads', async ({
|
|
api,
|
|
host,
|
|
guest,
|
|
}) => {
|
|
const g = await guest('SocialLocked');
|
|
|
|
// Upload while still open so there's a target to interact with.
|
|
const { uploadRaw } = await import('../../helpers/upload-client');
|
|
const { readFileSync } = await import('node:fs');
|
|
const { join } = await import('node:path');
|
|
const sample = join(process.cwd(), 'fixtures', 'media', 'sample.jpg');
|
|
const upRes = await uploadRaw(g.jwt, readFileSync(sample), {
|
|
filename: 'x.jpg',
|
|
contentType: 'image/jpeg',
|
|
});
|
|
expect(upRes.status).toBe(201);
|
|
const { id } = await upRes.json();
|
|
|
|
await api.closeEvent(host.jwt);
|
|
|
|
// Likes stay open on a locked event.
|
|
const likeRes = await fetch(`${BASE}/api/v1/upload/${id}/like`, {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${g.jwt}` },
|
|
});
|
|
expect(likeRes.status).toBe(200);
|
|
|
|
// Comments stay open on a locked event.
|
|
const commentRes = await fetch(`${BASE}/api/v1/upload/${id}/comments`, {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${g.jwt}`, 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ body: 'darf durchgehen' }),
|
|
});
|
|
expect(commentRes.status).toBe(201);
|
|
|
|
// New uploads, however, are rejected while locked.
|
|
const blockedUpload = await uploadRaw(g.jwt, readFileSync(sample), {
|
|
filename: 'y.jpg',
|
|
contentType: 'image/jpeg',
|
|
});
|
|
expect(blockedUpload.status).toBe(403);
|
|
});
|
|
});
|