A checkout address form is where every address problem finally has a cost. A field that rejects a legitimate entry, a country switch that quietly discards what was typed, a validation that fires while the user is still typing — each one turns into an abandoned order, and none of them are visible in a unit test that only checks whether a string is parseable.
The test cases below are written against the behaviour of the form as a whole rather than against a validation function. They cover the transitions: switching country, returning to a saved address, pasting, and finishing on a phone. The underlying data rules they depend on are described in address validation and normalization.
The forms are the ones users actually hit
Before the list, a note on why these specific cases. The severe bugs in checkout forms are rarely about a single invalid string. They come from state: the field that was populated for one country and not cleared for the next, the label that still says ZIP code after the country changed, the validation message that stays on screen after the value has been corrected.
Write cases that move through the form the way a person does, and assert what the user can see: whether the order can be completed, what the field labels say, whether the error is attached to the right field.
Test cases for required and optional fields
Start with the shape of the form itself. In most countries the postal code is required; in some it does not exist and must be optional. A district or state field is essential in some markets and meaningless in others. A form that marks every field required is unusable in the countries that do not have them, and a form that marks none of them required will accept an empty address.
Cases worth running: with only the mandatory fields filled; with every field filled; with the optional fields left empty deliberately; with the optional fields populated but whitespace-only; and with a field that exists in the schema but is hidden for the selected country. That last one catches the classic defect where a hidden field is still validated, so the form refuses to submit and shows no error the user can reach.
Also test the country with no postal code end to end. It should be possible to complete the order, and the confirmation should not display an empty postal code line.
What happens when the country changes?
This is the highest-value test on the list, because the country selector changes the meaning of every other field. Run it in both directions: from a country with a postal code to one without, and back again.
Assert that the postal code entered under the first country does not silently persist under the second, that the field label changes to the local term, and that any existing validation error is cleared or recomputed rather than left attached to a field whose rules have changed. Assert too that the subdivision list is replaced rather than filtered, since a filtered list can leave a selection that does not exist in the new country.
A related case: select the country last. Some people fill the address first and set the country afterwards. If validation runs on every keystroke, they will see errors for a format that was correct for a country they had not chosen yet.
| Situation | What the test should assert |
|---|---|
| Country switched, then switched back | The postal code entered under the first country does not silently persist under the second |
| Field label | The label changes to the local term for the newly selected country |
| Existing validation error | It is cleared or recomputed, rather than left attached to a field whose rules have changed |
| Subdivision list | It is replaced rather than filtered, so no stale selection survives |
Do pasting and autofill still work?
Users paste. They paste a whole address block into the first line, they paste a postal code copied from another tab, they paste a phone number with punctuation and an international prefix. They also accept what the browser offers to autofill.
Test each. Pasting a full address into the street line should either be handled gracefully or leave the field editable and unbroken; it must not trigger a validation error that blocks submission with no visible explanation. Pasting a postal code with surrounding whitespace should be accepted after trimming. Autofill should populate the fields the user expects and should not overwrite a country or subdivision that has already been chosen.
Then test the paste that arrives slowly, character by character, as some assistive tools do. Validation that fires on the first keystroke and shows “invalid postal code” while the value is still incomplete is a real defect, not an edge case.
Testing on a phone and with a slow connection
Mobile layouts change what the user can reach. Cases worth running at a narrow width: the country selector opens and can be dismissed; the keyboard does not cover the field being typed into or the submit button; the subdivision list is searchable or scrollable when it is long; and the error message is visible without scrolling away from the field.
Add a slow or interrupted connection. Submit the order, interrupt the response, resubmit. The form should not create two orders because the button stayed enabled, and it should not lose the entered address when the request fails. A saved-address path deserves the same treatment: edit a saved address, abandon the edit, and confirm the original is intact.
For developers: what to assert and what to seed
Assert on outcomes the user can observe — submission succeeds, the right label is shown, the error is attached to the field that caused it — rather than on internal validation calls. That keeps the tests meaningful when the validation library changes.
Seed the form from a fixture set that includes one clean address per market you serve and the deliberate inconsistencies described in address data in test fixtures. Keep the seed data deterministic so a failing case can be reproduced exactly, and generate the clean samples rather than hand-typing them, as the address generator does.
Finally, mark the test orders as test orders in the environment itself. A test order that looks identical to a real one will eventually be fulfilled, and an address that was generated for a test is not a deliverable address.
Next steps
Pick the country-switch case first — it exercises the most shared code for the least setup — and add the no-postal-code path in the same session. Then run the full list once at a mobile width with the network throttled, because that combination finds more checkout defects than any amount of additional input validation. For the field-level rules behind these cases, start with US address structure.