epic(legibility): pre-flight — make tests trustworthy (#402) #430

Merged
marcel merged 11 commits from worktree-test-issue-402-legibility-preflight into main 2026-05-05 20:36:15 +02:00
Showing only changes of commit 3f25f1fd73 - Show all commits

View File

@@ -633,24 +633,30 @@ test.describe('Document editing — tags (J3)', () => {
// ── J4: Create a brand-new tag via TagInput ────────────────────────────────
//
// Types a tag name that does not exist yet, confirms creation with Enter, and
// verifies the tag chip persists after save.
// verifies the tag chip persists after save AND after a full page reload.
test.describe('Document editing — new tag creation (J4)', () => {
const baseURL = process.env.E2E_BASE_URL ?? 'http://localhost:3000';
let newTagDocHref: string;
const newTagName = `E2E-Tag-${Date.now().toString(36)}`;
let newTagDocId: string;
const stamp = Date.now().toString(36);
const newTagName = `E2E-Tag-${stamp}`;
test.beforeAll(async ({ request }) => {
const createRes = await request.post('/api/documents', {
multipart: { title: 'E2E New Tag Test' }
multipart: { title: `E2E New Tag Test ${stamp}` }
});
if (!createRes.ok()) throw new Error(`Create document failed: ${createRes.status()}`);
const doc = await createRes.json();
newTagDocHref = `${baseURL}/documents/${doc.id}`;
newTagDocId = doc.id;
});
test('user types a new tag name, presses Enter, saves, and sees the chip', async ({ page }) => {
await page.goto(`${newTagDocHref}/edit`);
test.afterAll(async ({ request }) => {
if (newTagDocId) await request.delete(`/api/documents/${newTagDocId}`);
});
test('user types a new tag name, presses Enter, saves, and tag persists after reload', async ({
page
}) => {
await page.goto(`/documents/${newTagDocId}/edit`);
await page.waitForSelector('[data-hydrated]');
const tagInput = page.getByPlaceholder('Schlagworte hinzufügen...');
@@ -665,8 +671,19 @@ test.describe('Document editing — new tag creation (J4)', () => {
await page.getByRole('button', { name: 'Speichern', exact: true }).click();
// Detail page after redirect — tag link must be visible.
await expect(page).toHaveURL(/\/documents\/[^/]+$/);
await expect(page.getByText(newTagName)).toBeVisible({ timeout: 5_000 });
await expect(page.locator('a[href*="?tag="]', { hasText: newTagName })).toBeVisible({
timeout: 5_000
});
// Reload to verify the tag survived the round-trip (not just client-side state).
await page.reload();
await page.waitForSelector('[data-hydrated]');
await expect(page.locator('a[href*="?tag="]', { hasText: newTagName })).toBeVisible({
timeout: 5_000
});
await page.screenshot({ path: 'test-results/e2e/document-new-tag-created.png' });
});
});