diff --git a/tests/fixtures/test-photo-b.jpg b/tests/fixtures/test-photo-b.jpg new file mode 100644 index 0000000..ff333a8 Binary files /dev/null and b/tests/fixtures/test-photo-b.jpg differ diff --git a/tests/ui/post/post-form-ux.spec.js b/tests/ui/post/post-form-ux.spec.js index 1122676..f2b9f68 100644 --- a/tests/ui/post/post-form-ux.spec.js +++ b/tests/ui/post/post-form-ux.spec.js @@ -8,6 +8,8 @@ const { fillEditor, waitForPhotoUpload, cleanupEntry, findEntry } = require('../ const TEST_HEIC = path.join(__dirname, '../../fixtures/test-photo.heic'); const TEST_CORRUPT_HEIC = path.join(__dirname, '../../fixtures/test-corrupt.heic'); +const TEST_JPG = path.join(__dirname, '../../fixtures/test-photo.jpg'); +const TEST_JPG_B = path.join(__dirname, '../../fixtures/test-photo-b.jpg'); const DRAFT_KEY = 'intotheeast:new-entry-draft'; const created = []; @@ -87,6 +89,33 @@ test('photo section auto-collapses to a summary after upload and re-expands on t await expect(details).toHaveJSProperty('open', true); }); +// ── Reorder: uploaded photos are renamed photo-1..N; no order field leaks ────── +test('uploaded photos are renamed photo-1..N and the order field never hits frontmatter', async ({ page }) => { + const tag = `rename-${Date.now()}`; + await page.goto('/post'); + await page.fill('input[name="data[title]"]', `UI Test ${tag}`); + await fillEditor(page, `photo rename test ${tag}`); + + await page.locator('input.filepond--browser').setInputFiles([TEST_JPG, TEST_JPG_B]); + await waitForPhotoUpload(page, 2); + + await page.locator('.btn-post').evaluate(el => el.click()); + await expect(page.locator('.notices')).toContainText('Entry posted successfully!', { timeout: 15_000 }); + created.push(tag); + + const dir = findEntry(tag); + expect(dir, 'Entry folder should exist').toBeTruthy(); + const files = fs.readdirSync(dir); + // Server renamed both uploads to the deterministic photo-N scheme (drag order). + expect(files).toContain('photo-1.jpg'); + expect(files).toContain('photo-2.jpg'); + + // The order is sent as a top-level POST key, so it must not appear in frontmatter. + const mdName = files.find(f => /\.md$/.test(f)); + const md = fs.readFileSync(path.join(dir, mdName), 'utf-8'); + expect(md).not.toContain('photo_order'); +}); + // ── R18: Get Weather is gated on coordinates ────────────────────────────────── test('R18: Get Weather is disabled until Get Location provides coordinates', async ({ page, context }) => { await context.grantPermissions(['geolocation']);