diff --git a/tests/ui/post/post-form-ux.spec.js b/tests/ui/post/post-form-ux.spec.js index f2b9f68..f1768b0 100644 --- a/tests/ui/post/post-form-ux.spec.js +++ b/tests/ui/post/post-form-ux.spec.js @@ -116,6 +116,29 @@ test('uploaded photos are renamed photo-1..N and the order field never hits fron expect(md).not.toContain('photo_order'); }); +// ── Date field is a native datetime-local picker, prefilled, and required ───── +test('date field renders as a datetime-local picker, prefilled with now and required', async ({ page }) => { + await page.goto('/post'); + const date = page.locator('input[name="data[date]"]'); + + // Grav's deprecated datetime field used to fall back to a plain text box; + // the theme override renders a real picker instead. + await expect(date).toHaveAttribute('type', 'datetime-local'); + // post-form.js prefills the current local time in the value format the + // native input expects (YYYY-MM-DDTHH:MM). + await expect(date).toHaveValue(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/); + + // Clearing it and submitting must be blocked client-side (this is what keeps + // an invalid/empty date from round-tripping to the server and wiping the + // FilePond photo list on a re-render). + await date.fill(''); + await page.fill('input[name="data[title]"]', `UI date-${Date.now()}`); + await fillEditor(page, 'datetime picker validation test'); + await page.locator('.btn-post').evaluate(el => el.click()); + await expect(date).toHaveClass(/field-invalid/); + await expect(page.locator('.notices.success, .notices.green')).toHaveCount(0); +}); + // ── 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']);