Date field test cases for "today or later"
Code that checks "the event date must be today or later" often compares something simpler than the rule: only the year, a date with a time attached, or the server's today instead of yours. A date picked from an old year will not catch any of those.
The boundary: yesterday, today, tomorrow
| Date | Expected | What it catches |
|---|---|---|
| Today | Accepted | A check written as "after today" instead of "today or later" |
| Tomorrow | Accepted | The ordinary case |
| Yesterday | Rejected | Missing check |
| A date earlier this year, such as January 1 | Rejected | A check that compares only the year |
| Same day and month, last year | Rejected | A check that compares only day and month |
| A date many years ahead | Depends on the rule | Whether there is an upper limit, and whether anyone decided it |
The year-only check deserves its own line because it is common and invisible: last year's dates are rejected, so a quick test with "a date in the past" picked from an old year passes. Pick past dates from the current year.
Midnight and time zones
"Today" depends on where you are. If the page checks the date in your time zone and the server checks it in UTC, there are hours every day when the two disagree. Test close to midnight, or change your computer's time zone to one far from the server's and try today's date. Expected: the same answer from the page and the server. If they disagree, the user sees the form accept the date and then the order fail, or the reverse.
Input that is not a date
- An empty field when the date is required: a clear message, no order.
- A partly filled field (day and month, no year). Browsers' date pickers allow this, and the value the page receives is then empty.
- Impossible dates typed by hand where the field allows typing: February 30, month 13.
- A different date format, if the field is a plain text box:
03/04/2027is March 4 or April 3 depending on the reader.
Does the date reach the server?
The page can validate the date, show it back to you, and then send an order that does not include it, or includes it under the wrong name. You will not see this on screen. Open the browser's developer tools, go to the Network tab, place an order, and look at the request body. The date you chose should be there, in the format the server expects. Then look at the confirmation: does it show the date you picked?
Error messages
Pick an invalid date, read the error, then correct the date. The error should disappear without you having to submit again. A message that stays on screen after the fix is a small bug that makes people think the form is still broken.
Open the practice form
More guides: email fields · what the server trusts · all guides