Skip to content

examples(draft-form): server-side formnovalidate recipe + e2e (#239)#91

Open
adnaan wants to merge 2 commits into
mainfrom
feat/formnovalidate-example
Open

examples(draft-form): server-side formnovalidate recipe + e2e (#239)#91
adnaan wants to merge 2 commits into
mainfrom
feat/formnovalidate-example

Conversation

@adnaan

@adnaan adnaan commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Adds the runnable example + docs for livetemplate's server-side formnovalidate honoring (livetemplate#239), the release-pinned follow-up that lights up the documented "Save draft" pattern. Bumps livetemplate to v0.15.0 (the first release containing #239).

What's here

  • examples/draft-form/ — a post editor: a required title with two buttons, Publish (validates) and Save draft (formnovalidate). Both handlers call the same ctx.ValidateForm(); it enforces for Publish and skips for the formnovalidate Save draft, keyed on the submitter. Mounted at /apps/draft-form/ and, WS-disabled, at /apps/draft-form/no-js/ to demonstrate the no-JS native-POST tier — where the kebab-case save-draft button name also routes to the SaveDraft method verbatim.
  • content/recipes/formnovalidate.md — recipe page with the two live embeds, source includes, the all-tiers/no-client-code explanation, and a "convenience, not a security boundary" trust note. Linked from the recipes index. tinkerdown validate content/ passes (95/95).
  • e2e/draft_form_test.go — self-contained chromedp test (boots its own httptest server, no staging dependency) capturing all four debug signals (console, server logs, WS frames, rendered HTML). All three scenarios pass.

Verification

  • GOWORK=off go build ./... && go vet ./examples/draft-form/ ./e2e/ ./cmd/site/ — clean
  • GOWORK=off go test ./examples/... — ok
  • GOWORK=off go test ./e2e/ -run TestDraftForm -vPASS (3 scenarios, ~11s)
  • tinkerdown validate content/ — 95/95 valid

Notable e2e finding

Scenario 1 (Save draft + empty title → saved as draft) is the real server-side proof of #239 — it only succeeds if the framework honored the formnovalidate submitter and skipped validation. Scenario 2 documents a correct HTML subtlety: on the JS tier the browser's native required check blocks an empty Publish before any round-trip, so server enforcement for Publish is observable on the no-JS tier rather than over WS.

Closes the docs/example follow-up for the livetemplate#385 form-handling cluster.

🤖 Generated with Claude Code

adnaan and others added 2 commits June 29, 2026 05:31
Bumps livetemplate to v0.15.0 and adds a runnable example + recipe page for
its server-side formnovalidate honoring.

- examples/draft-form: a post editor with a required title and two buttons —
  "Publish" (validates) and "Save draft" (formnovalidate). Both call the same
  ctx.ValidateForm(); it enforces for Publish and skips for the formnovalidate
  Save draft, on every tier. Mounted at /apps/draft-form/ and (WS-disabled)
  /apps/draft-form/no-js/ to show the no-JS native-POST path, where the
  kebab-case save-draft button name also routes to SaveDraft.
- content/recipes/formnovalidate.md: walks the feature with the live embeds,
  source includes, the all-tiers/no-client-code point, and a trust note
  (convenience, not a security boundary).
- e2e/draft_form_test.go: self-contained chromedp test (own httptest server)
  capturing all four signals — console, server logs, WS frames, rendered HTML.
  Scenario 1 (save-draft + empty title → saved as draft) is the server-side
  proof of #239; scenario 2 documents that the browser's native required check
  blocks an empty Publish before any round-trip on the JS tier.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The hardcoded /run/current-system/sw/bin/chromium path is the local dev box's
binary. CI (ubuntu-latest) has google-chrome-stable on PATH, which chromedp's
default allocator finds — so only apply ExecPath when the local chromium binary
actually exists, otherwise forcing a nonexistent path breaks the CI e2e run.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant