chore(e2e): add ESLint + Prettier; fix real findings; dedupe BASE
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>
This commit is contained in:
@@ -26,12 +26,18 @@ async function seedUpload(token: string, caption = 'Doubletap fixture'): Promise
|
||||
contentType: 'image/jpeg',
|
||||
caption,
|
||||
});
|
||||
if (res.status !== 201) throw new Error(`Upload seed failed (${res.status}): ${await res.text()}`);
|
||||
if (res.status !== 201)
|
||||
throw new Error(`Upload seed failed (${res.status}): ${await res.text()}`);
|
||||
return (await res.json()) as { id: string };
|
||||
}
|
||||
|
||||
test.describe('Mobile — double-tap gesture', () => {
|
||||
test('double-tap on a feed card image button registers a like', async ({ api, page, guest, signIn }) => {
|
||||
test('double-tap on a feed card image button registers a like', async ({
|
||||
api,
|
||||
page,
|
||||
guest,
|
||||
signIn,
|
||||
}) => {
|
||||
const author = await guest('DtAuthor');
|
||||
const liker = await guest('DtLiker');
|
||||
const { id: uploadId } = await seedUpload(author.jwt, 'Double-tap me');
|
||||
@@ -40,7 +46,8 @@ test.describe('Mobile — double-tap gesture', () => {
|
||||
await page.goto('/feed');
|
||||
|
||||
// Locate the image button inside the card. The aria-label is "Bild vergrößern".
|
||||
const imageButton = page.locator('article')
|
||||
const imageButton = page
|
||||
.locator('article')
|
||||
.filter({ hasText: author.displayName })
|
||||
.first()
|
||||
.getByRole('button', { name: 'Bild vergrößern' });
|
||||
@@ -50,16 +57,26 @@ test.describe('Mobile — double-tap gesture', () => {
|
||||
|
||||
// Wait for the optimistic increment OR the SSE-confirmed count. We assert via the
|
||||
// API to avoid coupling to specific DOM markup for the like badge.
|
||||
await expect.poll(async () => {
|
||||
const feed = await api.getFeed(liker.jwt);
|
||||
// Backend returns { uploads: [...], next_cursor }.
|
||||
const list: any[] = feed.uploads ?? feed.items ?? feed;
|
||||
const row = Array.isArray(list) ? list.find((u: any) => u.id === uploadId) : undefined;
|
||||
return row?.like_count ?? row?.likes ?? 0;
|
||||
}, { timeout: 5_000 }).toBeGreaterThanOrEqual(1);
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const feed = await api.getFeed(liker.jwt);
|
||||
// Backend returns { uploads: [...], next_cursor }.
|
||||
const list: any[] = feed.uploads ?? feed.items ?? feed;
|
||||
const row = Array.isArray(list) ? list.find((u: any) => u.id === uploadId) : undefined;
|
||||
return row?.like_count ?? row?.likes ?? 0;
|
||||
},
|
||||
{ timeout: 5_000 }
|
||||
)
|
||||
.toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
test('double-tap inside the lightbox triggers the heart-burst (like recorded)', async ({ api, page, guest, signIn }) => {
|
||||
test('double-tap inside the lightbox triggers the heart-burst (like recorded)', async ({
|
||||
api,
|
||||
page,
|
||||
guest,
|
||||
signIn,
|
||||
}) => {
|
||||
const author = await guest('LbAuthor');
|
||||
const liker = await guest('LbLiker');
|
||||
const { id: uploadId } = await seedUpload(author.jwt, 'Lightbox heart');
|
||||
@@ -68,7 +85,8 @@ test.describe('Mobile — double-tap gesture', () => {
|
||||
await page.goto('/feed');
|
||||
|
||||
// Open the lightbox by clicking the image button.
|
||||
const imageButton = page.locator('article')
|
||||
const imageButton = page
|
||||
.locator('article')
|
||||
.filter({ hasText: author.displayName })
|
||||
.first()
|
||||
.getByRole('button', { name: 'Bild vergrößern' });
|
||||
@@ -88,12 +106,17 @@ test.describe('Mobile — double-tap gesture', () => {
|
||||
|
||||
await doubleTap(page, media);
|
||||
|
||||
await expect.poll(async () => {
|
||||
const feed = await api.getFeed(liker.jwt);
|
||||
// Backend returns { uploads: [...], next_cursor }.
|
||||
const list: any[] = feed.uploads ?? feed.items ?? feed;
|
||||
const row = Array.isArray(list) ? list.find((u: any) => u.id === uploadId) : undefined;
|
||||
return row?.like_count ?? row?.likes ?? 0;
|
||||
}, { timeout: 5_000 }).toBeGreaterThanOrEqual(1);
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const feed = await api.getFeed(liker.jwt);
|
||||
// Backend returns { uploads: [...], next_cursor }.
|
||||
const list: any[] = feed.uploads ?? feed.items ?? feed;
|
||||
const row = Array.isArray(list) ? list.find((u: any) => u.id === uploadId) : undefined;
|
||||
return row?.like_count ?? row?.likes ?? 0;
|
||||
},
|
||||
{ timeout: 5_000 }
|
||||
)
|
||||
.toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user