test(post-form): retarget suite to redesigned /post + add UX coverage (U7)
- test-form-config.sh: assert parent is NOT hardcoded (injected server-side), active_trip set in site.yaml, and the new fields incl. custom 'photos' type. - helpers.js: resolve active trip from site.active_trip (parent coupling gone); fillEditor() drives EasyMDE via window.postFormEditor; waitForPhotoUpload() waits on the new picker. - post.spec / validation.spec: content via the editor, filepond selectors -> the photo picker, P8 checks editor value, V3/V4 exercise the picker cap + fail-closed non-image. - post-form-ux.spec.js (new): AE3 disclosure, AE1 HEIC->JPEG, AE4 corrupt-HEIC fail-closed, R18 weather gating, R20 draft restore. - fixtures: real + corrupt .heic. - test-post.sh: resolve dailies dir from active_trip. Refs AE1-AE4, R18, R20, U7.
This commit is contained in:
+14
-12
@@ -4,7 +4,7 @@
|
||||
const { test, expect } = require('@playwright/test');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { waitForFilePondUpload, cleanupEntry, findEntry, readEntryMd, TRACKER_DIR, ACTIVE_TRIP_URL } = require('../helpers');
|
||||
const { fillEditor, waitForPhotoUpload, cleanupEntry, findEntry, readEntryMd, TRACKER_DIR, ACTIVE_TRIP_URL } = require('../helpers');
|
||||
|
||||
const TEST_PHOTO = path.join(__dirname, '../../fixtures/test-photo.jpg');
|
||||
|
||||
@@ -22,7 +22,7 @@ test('P1: post text-only entry → created on disk and visible in trip feed', as
|
||||
|
||||
await page.goto('/post');
|
||||
await page.fill('input[name="data[title]"]', title);
|
||||
await page.fill('textarea[name="data[content]"]', 'Text-only test entry. Safe to delete.');
|
||||
await fillEditor(page, 'Text-only test entry. Safe to delete.');
|
||||
await page.fill('input[name="data[location_city]"]', 'Testville');
|
||||
await page.fill('input[name="data[location_country]"]', 'Testland');
|
||||
await page.locator('.btn-post').evaluate(el => el.click());
|
||||
@@ -50,12 +50,12 @@ test.skip('P2: post entry with photo → photo saved in entry folder and visible
|
||||
|
||||
await page.goto('/post');
|
||||
await page.fill('input[name="data[title]"]', title);
|
||||
await page.fill('textarea[name="data[content]"]', 'Photo test entry. Safe to delete.');
|
||||
await fillEditor(page, 'Photo test entry. Safe to delete.');
|
||||
await page.fill('input[name="data[location_city]"]', 'Testville');
|
||||
await page.fill('input[name="data[location_country]"]', 'Testland');
|
||||
|
||||
await page.locator('input.filepond--browser').setInputFiles(TEST_PHOTO);
|
||||
await waitForFilePondUpload(page);
|
||||
await page.locator('input.photo-picker__input').setInputFiles(TEST_PHOTO);
|
||||
await waitForPhotoUpload(page);
|
||||
|
||||
await page.locator('.btn-post').evaluate(el => el.click());
|
||||
await page.waitForSelector('.form-messages, .notices', { timeout: 15_000 });
|
||||
@@ -81,7 +81,7 @@ test('P3: post entry with city/country → frontmatter contains location', async
|
||||
|
||||
await page.goto('/post');
|
||||
await page.fill('input[name="data[title]"]', title);
|
||||
await page.fill('textarea[name="data[content]"]', 'Location test. Safe to delete.');
|
||||
await fillEditor(page, 'Location test. Safe to delete.');
|
||||
await page.fill('input[name="data[location_city]"]', 'Kyoto');
|
||||
await page.fill('input[name="data[location_country]"]', 'Japan');
|
||||
await page.locator('.btn-post').evaluate(el => el.click());
|
||||
@@ -103,7 +103,7 @@ test('P4: post entry with lat/lng → coordinates saved in frontmatter', async (
|
||||
|
||||
await page.goto('/post');
|
||||
await page.fill('input[name="data[title]"]', title);
|
||||
await page.fill('textarea[name="data[content]"]', 'GPS test. Safe to delete.');
|
||||
await fillEditor(page, 'GPS test. Safe to delete.');
|
||||
// lat/lng fields are CSS-hidden (designed to be filled by the Get Location button);
|
||||
// set values directly via JS to simulate what the button would do.
|
||||
await page.evaluate(() => {
|
||||
@@ -142,7 +142,7 @@ test('P6: successful submit shows "Entry posted successfully!" message', async (
|
||||
const tag = `p6-${Date.now()}`;
|
||||
await page.goto('/post');
|
||||
await page.fill('input[name="data[title]"]', `UI Test ${tag}`);
|
||||
await page.fill('textarea[name="data[content]"]', 'P6 test. Safe to delete.');
|
||||
await fillEditor(page, 'P6 test. Safe to delete.');
|
||||
await page.locator('.btn-post').evaluate(el => el.click());
|
||||
await expect(page.locator('.form-messages, .notices')).toContainText(
|
||||
'Entry posted successfully!', { timeout: 15_000 }
|
||||
@@ -158,7 +158,7 @@ test('P7: submitted entry is saved with a date within 5 minutes of now', async (
|
||||
const tag = `p7-${Date.now()}`;
|
||||
await page.goto('/post');
|
||||
await page.fill('input[name="data[title]"]', `UI Test ${tag}`);
|
||||
await page.fill('textarea[name="data[content]"]', 'P7 date test. Safe to delete.');
|
||||
await fillEditor(page, 'P7 date test. Safe to delete.');
|
||||
await page.locator('.btn-post').evaluate(el => el.click());
|
||||
await expect(page.locator('.form-messages, .notices')).toContainText(
|
||||
'Entry posted successfully!', { timeout: 15_000 }
|
||||
@@ -184,13 +184,15 @@ test('P8: title and content fields are empty after a successful submit', async (
|
||||
const tag = `p8-${Date.now()}`;
|
||||
await page.goto('/post');
|
||||
await page.fill('input[name="data[title]"]', `UI Test ${tag}`);
|
||||
await page.fill('textarea[name="data[content]"]', 'P8 reset test. Safe to delete.');
|
||||
await fillEditor(page, 'P8 reset test. Safe to delete.');
|
||||
await page.locator('.btn-post').evaluate(el => el.click());
|
||||
await expect(page.locator('.form-messages, .notices')).toContainText(
|
||||
'Entry posted successfully!', { timeout: 15_000 }
|
||||
);
|
||||
// After reset, the form fields should be empty
|
||||
// After reset, the form fields should be empty. The content textarea is
|
||||
// hidden by EasyMDE, so check the editor value via the exposed instance.
|
||||
await expect(page.locator('input[name="data[title]"]')).toHaveValue('');
|
||||
await expect(page.locator('textarea[name="data[content]"]')).toHaveValue('');
|
||||
await page.waitForFunction(() => window.postFormEditor != null, { timeout: 10_000 });
|
||||
expect(await page.evaluate(() => window.postFormEditor.value())).toBe('');
|
||||
created.push(tag);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user