examples(draft-form): server-side formnovalidate recipe + e2e (#239)#91
Open
adnaan wants to merge 2 commits into
Open
examples(draft-form): server-side formnovalidate recipe + e2e (#239)#91adnaan wants to merge 2 commits into
adnaan wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the runnable example + docs for livetemplate's server-side
formnovalidatehonoring (livetemplate#239), the release-pinned follow-up that lights up the documented "Save draft" pattern. Bumpslivetemplateto v0.15.0 (the first release containing #239).What's here
examples/draft-form/— a post editor: arequiredtitle with two buttons, Publish (validates) and Save draft (formnovalidate). Both handlers call the samectx.ValidateForm(); it enforces for Publish and skips for theformnovalidateSave 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-casesave-draftbutton name also routes to theSaveDraftmethod 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 ownhttptestserver, 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/— cleanGOWORK=off go test ./examples/...— okGOWORK=off go test ./e2e/ -run TestDraftForm -v— PASS (3 scenarios, ~11s)tinkerdown validate content/— 95/95 validNotable 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
formnovalidatesubmitter and skipped validation. Scenario 2 documents a correct HTML subtlety: on the JS tier the browser's nativerequiredcheck 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