test(post-form): assert datetime-local picker, prefill, and required-date gate
Covers the theme datetime override: the date field renders as <input type="datetime-local">, is prefilled with the current local time in the native value format, and clearing it blocks submit client-side (no success notice) — the guard that keeps an invalid date from wiping the FilePond photo list on a server re-render. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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');
|
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 ──────────────────────────────────
|
// ── R18: Get Weather is gated on coordinates ──────────────────────────────────
|
||||||
test('R18: Get Weather is disabled until Get Location provides coordinates', async ({ page, context }) => {
|
test('R18: Get Weather is disabled until Get Location provides coordinates', async ({ page, context }) => {
|
||||||
await context.grantPermissions(['geolocation']);
|
await context.grantPermissions(['geolocation']);
|
||||||
|
|||||||
Reference in New Issue
Block a user