EveryRole

Wrong, then right: testing form error recovery

Most form tests stop at the error message. The bugs come after, when the person fixes it and sends again. How to test form error recovery.

Make a mistake in a form, read the error, fix the mistake, press the button again. Every real user does this. That is form error recovery, and almost no test checks it.

Tests for the wrong input usually end when the error message appears. The case is marked done and the test moves on. But the person doesn’t move on. They are still on the page, in a form that has now been through an error, and that form is in a state nobody tested.

We call the case “wrong, then right”. One case, two submissions, and the expected result is about the second one.

What it looks like

On our practice app, an editor writes a note, forgets the name, and presses “Create”. The form refuses. They type the name and press “Create” again.

The part that matters is the last frame: one item, and the note typed before the error is on it.

That went well. Here is exactly what “well” means, because each part can fail on its own:

  • The error went away once the field was fixed.
  • The button still worked.
  • The note typed before the error was kept, and was saved with the item.
  • One item was created.

One thing makes this easy: the browser refused, not the app. The name field is marked required, so the form never left the page. Nothing reloaded and nothing could be lost. Three of the four bugs below only happen when the refusal comes from the server.

So we sent the same mistake past the browser (the required attribute removed in the developer tools), with a longer note typed first.

The practice app after an empty name was refused by the server. The page shows only the message "A name of 1 to 60 characters, please". There is no form, and the note that was typed is gone.
Our own practice app failing this case. The refusal is right. The form and the note are gone, so there is nothing to fix and send again.

That is “what was typed is lost” and a dead end in one picture, in an app we wrote ourselves.

The four ways recovery breaks

The button stays dead

Some forms disable the button on submit so people can’t press it twice. Good idea. Then the server answers with an error, and the code path that turns the button back on only exists for success. The person fixes the field and has nothing to press.

This one is invisible in a test that stops at the error message, because at that moment a disabled button looks like part of the error state.

The error stays after the fix

The field is now valid and the red message is still under it. Or the banner at the top still says “Please fix the errors below”, above a form with no errors. People don’t know whether to trust the form or the message. Some give up.

What was typed is lost

The page reloads to show the error and comes back empty. Every field, or only the password, or only the file that was attached. For a short form it is an annoyance. For a long one (an application, a profile, a checkout) people leave.

Check the awkward fields in particular: file inputs, passwords, multi-selects, anything filled by a date picker.

It saves twice

The first attempt was refused by one check and half-accepted by another. The second attempt goes through. Now there are two records, or one record and one orphan row, or two welcome emails. You only see it if you look at the list afterwards.

The practice app's list after the wrong-then-right case: one item called Sample item, and the count says 1 item
The check that closes the case: open the list and count. One, not two.

How to test form error recovery, step by step

A wrong-then-right case has more steps than a normal one, so be exact about them, and about the expected result at the end:

StepWhat you doWhat you look at
1Fill every field except one required fieldNothing yet
2Press the buttonThe error names the field. The other fields kept their values.
3Fill the missing field. Touch nothing else.The error for that field is gone.
4Press the button againThe success page.
5Open the place where the result livesExactly one new record, holding everything from step 1.

“Touch nothing else” in step 3 matters. If you retype everything, you’ll never notice that the form lost it.

Step 5 is the one people drop. It needs a second page and a count. Do it anyway. Doubles are the costliest of the four bugs and the only one you can’t see on the form itself.

Which wrong input to start from

The empty required field is the easy start, and it is enough to catch a dead button or a stale message. Two others find different bugs:

Wrong on the server, not in the browser. An email address that is already registered. A name that is already taken. The browser can’t know, so the refusal comes from the server, and the round trip through the server is where values get lost.

Wrong on the second step. In a wizard, make the mistake on step two, fix it, and then go back to step one. Is the first answer still there? Our practice app’s set-up wizard keeps it. Not every wizard does.

Where it matters most

Anywhere a person is likely to get it wrong the first time: sign-up (password rules), checkout (card details, addresses), anything with a date, anything with a file. Those are also your most valuable forms, which is not a coincidence you get to enjoy.

If you only have time for one wrong-then-right case, do it on sign-up, with a password that breaks your password rule. Then fix the password and see whether you end up with an account.

How EveryRole runs it

EveryRole runs “Wrong, then right” at a form stop once it has seen the form refuse something. Today it is the smaller version of the case above. After the refused cases, it loads the form again, sends the good input, and compares where it ends up with the answer you approved, in a browser of its own, apart from the good-input case.

That catches a form that stops working after a refusal. It doesn’t yet keep the refused form and fix only the wrong field, so a dead button or a lost note is still yours to check by hand.

By hand, the whole thing takes a minute per form. Write the five steps down and do it on your three most important forms today.

Keep reading

Test cases

Happy path vs edge cases: where the bugs are

The happy path is the one route through a feature where everything goes right. Test it first, then test five edge cases per step. Which five, and why those.

5 min read