A signup form sends its verification result and gets a timeout. When it redraws, it has cleared the email and checkbox. That forces a legitimate user to repeat work before they can try again. For a form you operate that relies on a verification dependency such as xCaptcha, test failure recovery separately from the protection decision.
Written with AI. The locally run state-machine fixture uses synthetic form data. The cover illustration is AI-generated.
Make the retry safe and explicit
After a timeout, show a specific message and keep only the ordinary fields that the user can reasonably expect to remain on the page. Passwords and verification artifacts have different handling requirements. This example deliberately carries neither in the recovered state. The original form does not become submitted just because the user has to retry.
Use localized error text at the presentation layer. The state model can return a small reason code, the fields to keep and a focus target. A test can then assert that focus moves to an error summary and that the user can continue with fields they already filled in.
SAFE_FORM_FIELDS = {"email", "agreed_to_terms"}
def apply_check_result(form, check):
if check == "accepted":
return {"mode": "continue_to_server_validation"}
recovery = {key: value for key, value in form.items() if key in SAFE_FORM_FIELDS}
reasons = {"timeout": "verification_unavailable", "rejected": "verification_rejected"}
if check not in reasons:
raise ValueError("Unknown check outcome")
return {"mode": "retry", "reason": reasons[check], "focus": "error-summary",
"fields": recovery}
sample = {"email": "person@example.test", "agreed_to_terms": True,
"password": "fictional-secret", "verification_token": "fixture-only"}
after = apply_check_result(sample, "timeout")
assert after["mode"] == "retry" and after["focus"] == "error-summary"
assert after["fields"] == {"email": "person@example.test", "agreed_to_terms": True}
assert apply_check_result(sample, "rejected")["reason"] == "verification_rejected"
assert apply_check_result(sample, "accepted")["mode"] == "continue_to_server_validation"
print("The timeout retains safe fields and returns the user to the form")
The four local assertions passed. Follow them with a keyboard test on your own form to check the rendered focus, announcement and resubmission behavior. The code above is a presentation-state example. Your server still decides whether required verification and other signup checks are satisfied before creating an account.
The first time someone encounters a timeout is often through support. Include one timeout fixture in release tests so form recovery is a behavior you can check before that message arrives.
Check the state in two browser sessions
Run the retry test in two different sessions with distinct fictional field values. If the application uses server-side staging for the form, each session must receive its own safe fields. A test that runs one browser at a time can miss temporary state accidentally associated with the whole deployment. Also reuse the reload and Back actions in the test. Recovering from an error in a live page and restoring a previously displayed form on navigation are different lifecycle events.
Further reading
- An xCaptcha review for site operators to understand the context in which a signup check is used.
- Keeping account request URLs out of logs to test that failure diagnostics avoid exposing sensitive inputs.
Top comments (0)