test(forms): run the starter's form client against the public forms routes - #400
Merged
Merged
Conversation
…outes The client every delivered site ships (copied as a fixture) now runs against the real config and submit handlers: rendered field names, honeypot, Turnstile token, success, validation and captcha errors, and 402.
Member
Author
|
ONAY (t6) — 1815918
|
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.
E6 gap 1: nothing ran the browser client every Migrate-delivered site ships against Studio's public forms routes. Each side was tested alone, so a drift in field names, the honeypot, the Turnstile token or the response shape would only show up on a live site.
What this adds
tests/integration/starter-form-contract.integration.test.tsruns the starter'sembed.ts(copied totests/fixtures/starter/, byte-identical, excluded from eslint so it stays so) against the realconfig.getandsubmit.posthandlers. Only the database, Git and Turnstile's siteverify are mocked.It walks the visitor's chain: config → the controls the client renders (names, honeypot, Turnstile widget) → the form data → the request body → Studio's answer.
{ data, captchaToken, _hp }; only exposed fields are stored (internal_notenever appears); success message returnedsuccess: falsewithcaptchaerror; siteverify is not called without a tokensuccess: falsewith{ field, message }entriespayment_required(widget hidden)Refreshing the fixture
Copy the starter's
embed.tsagain when it changes (README in the fixture folder). A change that breaks the contract failspnpm test:ci.Tests
pnpm exec vitest run --project integration tests/integration/starter-form-contract.integration.test.ts: 5 passed.