A form can look ready before it works properly. You can type into the fields, click the button and see a result. But what happens if you enter only spaces? Can you use it without a mouse? Does the information survive a page refresh?
These are useful questions when AI helps you write the code. The result still needs to match what you intended to build.
My Support Request Tracker is a small React and TypeScript project with a title field, description and priority. Its first version creates requests and displays them in a list. I will use that form as an example of what to check, including the checks that go beyond a successful build.
Decide what “working” means first
Before testing, write down what should happen. This gives you something to compare the application against.
For my tracker’s first version, a successful submission should:
- Accept a title, description and priority.
- Reject empty titles and descriptions, including values containing only spaces.
- Add the request to the top of the list with an Open status.
- Clear the text fields and reset the priority to Medium.
- Show a confirmation message.
The first version keeps requests in React state, which holds information while the page is running. There is no database yet, so requests disappear on refresh. That limitation is part of the demo and needs to be explained.
1. Submit something other than perfect input
It is easy to test a form once with a short title and a sensible description. Start there, but try the unfinished versions too.
Leave both fields empty. Fill in only one. Then enter a few spaces instead of words.
An HTML input with required cannot be submitted empty through normal browser validation. However, spaces can still count as a value. If the field needs actual text, check for that separately.
In my form, the values are trimmed before creating a request:
const trimmedTitle = title.trim();
const trimmedDescription = description.trim();
if (!trimmedTitle || !trimmedDescription) {
setMessage('Enter a title and description containing more than spaces.');
return;
}
trim() returns a string with whitespace removed from its beginning and end. A value containing only spaces becomes an empty string.
The condition checks whether either trimmed value is empty. If so, the form displays a message and stops before adding a request.
Use the trimmed values when saving the request as well. Otherwise, you would check one version of the text and store another.
Once a backend is added, it must validate incoming data too. Browser validation helps people complete a form, but it can be bypassed.
2. Follow the result after clicking Submit
Create a fictional request with a title you can recognise, such as “Update the contact page”. Choose High priority so you can check that the selection carries through.
After submitting, look at the list and the form together. The new request should contain the right details, appear once and have an Open status. The count should increase, and the fields should reset as expected.
Then create another request. Check that it appears above the first and that the first has not disappeared.
This matters because the form is doing more than accepting text. It is also updating a list and preparing itself for the next entry.
In React, this update adds the new request before the existing ones:
setRequests(previousRequests => [
newRequest,
...previousRequests
]);
previousRequests is the previous list. The three dots copy its entries into the new list, after newRequest.
The code explains the intended order. Submitting two requests lets you check the result in the browser.
3. Try the form without your mouse
Use Tab to move forwards through the controls and Shift + Tab to move backwards.
You should be able to reach the title, description, priority and submit button in a sensible order. You should also be able to see which control currently has focus.
Focus is the control that will receive your keyboard input. A visible outline helps you keep track of it:
:focus-visible {
outline: 3px solid #287e71;
outline-offset: 3px;
}
Check that the outline is visible against the surrounding colours and is not cut off by another element.
Use the keyboard to change the priority and submit. In the description field, check that Enter creates a new line rather than unexpectedly submitting the form.
Standard HTML controls already provide useful keyboard behaviour. Using an actual <button> for submission is a better starting point than making a clickable <div> and rebuilding that behaviour yourself.
4. Check labels and messages
Each field needs a label that remains visible while someone types. A placeholder alone disappears as soon as the field has a value.
Here is the title field in React:
<label htmlFor="request-title">Title</label>
<input
id="request-title"
name="title"
value={title}
onChange={event => setTitle(event.target.value)}
required
/>
The label’s htmlFor matches the input’s id. Clicking the label should focus the input, and the connection gives assistive technology a name for the field.
After submission, the message should explain what happened. “Request created: Update the contact page” tells someone more than a button briefly changing colour.
For a confirmation message, the form can keep an existing status element on the page and update its text:
<p role="status">{message}</p>
role="status" allows assistive technology to announce changes to that message without moving keyboard focus.
Error messages need their own attention. They should explain what to correct and make clear which field has the problem. Test the experience with a screen reader as well; adding an attribute does not tell you whether the whole interaction works.
5. Use long text and a smaller window
A card containing “Test request” is unlikely to reveal much about the layout.
Try a longer title, several lines of description and a long string without spaces. Then narrow the browser window and increase the zoom.
Look for text escaping its card, fields becoming wider than the page or buttons disappearing from view. You should still be able to read the content and complete the form.
These styles help with two specific cases:
.request-card {
overflow-wrap: anywhere;
}
.request-card > p {
white-space: pre-wrap;
}
overflow-wrap: anywhere allows long strings to wrap when needed. white-space: pre-wrap preserves line breaks in the description while still allowing wrapping.
After changing the CSS, repeat the same input that exposed the problem. That is how you check whether the change helped.
6. Refresh after creating a request
A request appearing on the screen does not necessarily mean it has been saved permanently.
My tracker’s first version stores its list in React state. Refreshing starts the page again, so the list is cleared.
For this demo, a notice near the form explains that behaviour:
Demo in progress. Requests are stored in memory and disappear
when you refresh. Please use fictional information.
If your application is supposed to save records, refresh and check that they are still available from the intended storage.
When an API is added, test what happens while a request is being sent and when it fails. People need to know whether their submission is still processing, has succeeded or needs another attempt.
7. Run the project checks
For my project, these commands run from the frontend folder:
npm run lint
npm run build
The lint command checks the code against the configured ESLint rules. The build command runs the project’s TypeScript checks and creates the files used for deployment.
Both passed for the tracker’s first version. That was a useful milestone, but those results do not confirm that someone can complete the form with a keyboard or understand an error message.
After deploying, check the live form too. Confirm that the page loads and that the main submission flow still works at the published address.
What should become an automated test?
An automated test runs a check in code, so you can repeat it after making changes.
For this form, I would start with a few behaviours worth protecting:
- A whitespace-only title does not create a request.
- A valid submission displays the entered details.
- A second submission keeps the first request in the list.
- The fields reset after a successful submission.
These are proposed tests, not tests already included in the first version.
If AI helps write them, read what each test actually checks. Does it describe the required behaviour, and would it fail if that behaviour broke?
Record what you checked
A short, specific note is more useful than “all tested”. Record the behaviour checked, the result and anything still outstanding.
For example, “Two requests appeared in the correct order” tells you what was observed. “Screen-reader testing still outstanding” makes the gap clear.
My tracker has passed build and lint checks, and creating and displaying a request has been confirmed. The other checks in this article describe a review to carry out; they are not a claim that every check has already passed.
AI can help write a form and suggest improvements. Before you ship it, you still need to understand what the code does and check what happens when someone uses it.
You can explore the current prototype here:
Further reading:
No comments