From 6cd5ed0100b06219c07a1cc7f2d8d3728572a27d Mon Sep 17 00:00:00 2001 From: Mischa Date: Thu, 18 Jun 2026 13:50:47 +0200 Subject: [PATCH] Update docs to reflect date+time+title slug format - qa-test-plan: update expected folder, URL, and automation greps in TC-P.5, TC-P.6, TC-P.7; add slug explanation block to test data; rewrite TC-P.10 to cover two posts on the same day (now valid) - bugs-and-fixes: add BUG-003 documenting the silent duplicate-date failure and the slug fix Co-Authored-By: Claude Sonnet 4.6 --- docs/bugs-and-fixes.md | 34 +++++++++++++++++++++++++++++++++- docs/qa-test-plan.md | 31 +++++++++++++++++++------------ 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/docs/bugs-and-fixes.md b/docs/bugs-and-fixes.md index b47843c..d93b94e 100644 --- a/docs/bugs-and-fixes.md +++ b/docs/bugs-and-fixes.md @@ -33,7 +33,7 @@ Wire cache-clear into the form process so it happens automatically on every succ 1. Create a small plugin `user/plugins/cache-on-save/` with one event listener: - Listen on `onFormProcessed` - - When the form name is `new-entry`, call `$this->grav['cache']->clear()` + - When the form name is `new-entry`, call `$this->grav['cache']->deleteAll()` (note: `clear()` does not exist on `Grav\Common\Cache` in Grav 1.7) 2. Enable the plugin in `user/config/plugins/cache-on-save.yaml` This is the cleanest approach: it fires exactly once per successful submission, requires no changes to `post-form.md`, and works for any future forms too. @@ -102,3 +102,35 @@ Acceptable for a single-user dev setup — eliminates both BUG-001's side-effect 2. Reload any page — no 500 error, template works immediately without manual cache flush --- + +## BUG-003 — One post per day limit; silent failure on duplicate date + +**Status:** fixed 2026-06-18 +**Reported:** 2026-06-18 + +### Symptom + +Submitting a second post with the same date as an existing entry shows "Entry posted successfully!" but creates no file. The user's post is silently discarded. + +### Root cause + +The `add-page-by-form` plugin built the page slug from date only (`Y-m-d`), producing folder names like `2026-06-18.entry`. With `overwrite_mode: false`, if that folder already exists the plugin skips page creation but does not abort — the `message` process step runs regardless, showing a false success. + +### Fix + +Change the slug template in `user/pages/02.post/post-form.md` to include time and title: + +```twig +{{ form.value.date|date('Y-m-d-Hi') }}-{{ form.value.title|lower|regex_replace('/[^a-z0-9]+/', '-')|trim('-') }} +``` + +Example: title "Arrived in Tokyo" at 14:30 on 2026-06-18 → `2026-06-18-1430-arrived-in-tokyo` + +The slug is locked at creation time. Renaming the title afterwards does not change the URL. + +### Acceptance criteria + +1. Submit two posts on the same day with different times or titles — both appear in `/tracker` as separate entries +2. Renaming a post's title in the frontmatter does not break its URL + +--- diff --git a/docs/qa-test-plan.md b/docs/qa-test-plan.md index 1116764..c94574e 100644 --- a/docs/qa-test-plan.md +++ b/docs/qa-test-plan.md @@ -336,6 +336,12 @@ These scenarios cover the full round-trip: filling the form → saving → verif | Longitude | `139.691711` | | Photos | none (keep simple for first run) | +**Expected slug:** `2026-06-18-1000-qa-test-entry` +**Expected folder:** `2026-06-18-1000-qa-test-entry.entry/` +**Expected URL:** `/tracker/2026-06-18-1000-qa-test-entry.entry` + +The slug is built from `date(Y-m-d-Hi)` + title lowercased with `[^a-z0-9]+` replaced by hyphens. + --- ### TC-P.1: Post form requires authentication @@ -405,8 +411,8 @@ These scenarios cover the full round-trip: filling the form → saving → verif | Step | Action | Expected Result | |---|---|---| | 1 | After TC-P.4 completes | — | -| 2 | Check directory `user/pages/01.tracker/` | Folder `2026-06-18.entry/` exists (add-page-by-form appends template name per `physical_template_name: true`) | -| 3 | Read `user/pages/01.tracker/2026-06-18.entry/entry.md` | File exists | +| 2 | Check directory `user/pages/01.tracker/` | Folder `2026-06-18-1000-qa-test-entry.entry/` exists (add-page-by-form appends template name per `physical_template_name: true`) | +| 3 | Read `user/pages/01.tracker/2026-06-18-1000-qa-test-entry.entry/entry.md` | File exists | | 4 | Verify frontmatter `title` | Equals `QA Test Entry` | | 5 | Verify frontmatter `date` | Equals `2026-06-18 10:00` | | 6 | Verify frontmatter `location_city` | Equals `Tokyo` | @@ -430,10 +436,10 @@ These scenarios cover the full round-trip: filling the form → saving → verif | 3 | Entry card present | Card with title `QA Test Entry` visible | | 4 | Date shown on card | `18 Jun 2026` | | 5 | Location badge on card | `📍 Tokyo, Japan` visible | -| 6 | Entry card link | `href` points to `/tracker/2026-06-18.entry` | +| 6 | Entry card link | `href` points to `/tracker/2026-06-18-1000-qa-test-entry.entry` | | 7 | Excerpt shown | Partial text of the body content visible | -**Automation:** curl /tracker; grep for "QA Test Entry", "18 Jun 2026", "Tokyo", "Japan", "/tracker/2026-06-18.entry" +**Automation:** curl /tracker; grep for "QA Test Entry", "18 Jun 2026", "Tokyo", "Japan", "/tracker/2026-06-18-1000-qa-test-entry.entry" --- @@ -441,7 +447,7 @@ These scenarios cover the full round-trip: filling the form → saving → verif | Step | Action | Expected Result | |---|---|---| -| 1 | GET http://100.96.115.96:8081/tracker/2026-06-18.entry | Page loads (200) | +| 1 | GET http://100.96.115.96:8081/tracker/2026-06-18-1000-qa-test-entry.entry | Page loads (200) | | 2 | Page title | `QA Test Entry` in `

` | | 3 | Date header | `Thursday, 18 June 2026` (or locale equivalent) | | 4 | Location badge | `📍 Tokyo, Japan` | @@ -449,7 +455,7 @@ These scenarios cover the full round-trip: filling the form → saving → verif | 6 | No gallery | Photo gallery section absent (no photos were uploaded) | | 7 | Back link | `← Back to journal` link present, points to /tracker | -**Automation:** curl /tracker/2026-06-18.entry; grep for "QA Test Entry", "Tokyo", "Japan", "This is the QA test body", "Back to journal" +**Automation:** curl /tracker/2026-06-18-1000-qa-test-entry.entry; grep for "QA Test Entry", "Tokyo", "Japan", "This is the QA test body", "Back to journal" --- @@ -478,17 +484,18 @@ These scenarios cover the full round-trip: filling the form → saving → verif --- -### TC-P.10: Duplicate date handling +### TC-P.10: Two posts on the same day | Step | Action | Expected Result | |---|---|---| -| 1 | Submit a second post with the same date `2026-06-18 10:00` | — | -| 2 | Observe result | Either: error shown, OR new entry created at a different slug | -| 3 | Check filesystem | No silent data loss — original entry intact | +| 1 | Submit a first post: date `2026-06-18 10:00`, title `Morning Update` | Success message shown | +| 2 | Submit a second post: date `2026-06-18 14:30`, title `Afternoon Update` | Success message shown | +| 3 | Check filesystem | Two separate folders exist: `2026-06-18-1000-morning-update.entry/` and `2026-06-18-1430-afternoon-update.entry/` | +| 4 | Visit /tracker | Both entries visible as separate cards | -**Note:** `overwrite_mode: false` on add-page-by-form plugin should prevent overwrite. Behavior on conflict is to be documented here after first run. +**Note:** The slug encodes date + time + title, so same-day posts are fully supported as long as they have different times or titles. A true collision (same date, same time, same title) would silently fail — treat this as acceptable given solo use. -**Manual verification required:** Requires two submissions with same date +**Manual verification required:** Requires two browser submissions ---