test(post): share createPhotoEntry helper and fix cleanup leak
Hoist the duplicated per-spec createEntry photo-fixture into a single createPhotoEntry() in helpers.js (used by delete-flow, edit-mode, and the anon-view draft). Register the tag for cleanup BEFORE the awaited 15s success-toast assertion, so a create that lands on disk but whose toast assertion times out no longer leaks an untracked entry. Add AE3b covering the disclosure deviation branch (a non-default toggle auto-expands More options). Code review F2 (leak), F3 (duplication), F6 (coverage). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mpdu3Dt1iVoozHwAMyjrbn
This commit is contained in:
@@ -9,35 +9,20 @@
|
||||
// (404 "no longer exists" vs a transient "couldn't be loaded") — the copy
|
||||
// that tells the owner whether a retry is worthwhile. These had zero coverage.
|
||||
const { test, expect } = require('@playwright/test');
|
||||
const path = require('path');
|
||||
const {
|
||||
fillEditor, waitForPhotoUpload, cleanupEntry, findEntry, readEntryMd, ACTIVE_TRIP_URL,
|
||||
fillEditor, createPhotoEntry, cleanupEntry, findEntry, readEntryMd, ACTIVE_TRIP_URL,
|
||||
} = require('../helpers');
|
||||
|
||||
const TEST_PHOTO = path.join(__dirname, '../../fixtures/test-photo.jpg');
|
||||
// Synthetic route for the mocked error tests — never has to exist on disk.
|
||||
const MISSING_ROUTE = '/trips/italy-2026-demo/dailies/does-not-exist';
|
||||
|
||||
const created = [];
|
||||
test.afterAll(() => created.forEach(cleanupEntry));
|
||||
|
||||
/** Post a fresh entry through the create form (photo included, gate satisfied). */
|
||||
async function createEntry(page, tag) {
|
||||
await page.goto('/post');
|
||||
await page.fill('input[name="data[title]"]', `UI Test ${tag}`);
|
||||
await fillEditor(page, `Fixture for ${tag}. Safe to delete.`);
|
||||
await page.locator('input.filepond--browser').setInputFiles(TEST_PHOTO);
|
||||
await waitForPhotoUpload(page);
|
||||
await page.locator('.btn-post').evaluate(el => el.click());
|
||||
await expect(page.locator('.form-messages, .notices')).toContainText(
|
||||
'Entry posted successfully!', { timeout: 15_000 });
|
||||
}
|
||||
|
||||
// ── ES1: edit-mode save writes the changed title + body back to disk ──────────
|
||||
test('ES1: editing an entry saves the changed title and body back in place', async ({ page }) => {
|
||||
const tag = `es1-${Date.now()}`;
|
||||
await createEntry(page, tag);
|
||||
created.push(tag);
|
||||
await createPhotoEntry(page, tag, { created });
|
||||
|
||||
// Reach edit mode the way the owner does: via the feed card's Edit link.
|
||||
await page.goto(ACTIVE_TRIP_URL);
|
||||
|
||||
Reference in New Issue
Block a user