A Minimal Test Strategy for a Small Web Project: Two Real Regressions
Reproduce floating-point money and lost anonymous drafts in a local quote form, then turn key inputs, boundaries, recovery, and browser checks into a small runnable test set.

A small web project can have one form and a few lines of calculation code. The difficult question is rarely whether to test. It is which few checks protect people from a wrong result, lost work, or a dead end when recovery matters.
I built a local anonymous quote page with only two inputs: quantity and unit price. It needs no account, and its quote calculation and draft storage make no backend calls. An unfinished draft lives only in localStorage for the current browser. That deliberately narrow scope makes two risks visible: a wrong money display and a draft that disappears when somebody refreshes in the middle of an edit.
Download the complete runnable v1.0.0 lab. It contains the broken and repaired versions, two actual failure logs, six passing behavior contracts, and run instructions. Every quote value is original test data for this experiment.
Start with one real path, then choose risks
I wrote the reader path before naming any test type: open the page anonymously → enter quantity and price → see a subtotal → refresh before calculation → continue editing or correct an error.
That path gives four checks worth making explicit:
| Risk | Smallest check | Actual artifact from this lab |
|---|---|---|
A binary floating-point tail reaches the UI for 0.10 × 3. | The reader must see $0.30. | The broken test exits 1; the repaired page and contract both show $0.30. |
| A refresh erases an anonymous partial draft. | After reload in the same browser, it should restore 7 and 4.25. | The broken page returns to 3 / 0.10; the repaired page retains the edit. |
| A boundary or format error gives the person no way forward. | Keep the submitted input beside an actionable error. | Quantity 0 remains in the field with a readable correction message. |
| Saved data is damaged. | Return to a clean, editable state. | Invalid JSON is removed and the page presents a recovery notice with the default draft. |
This is more useful than beginning with a list of “unit, end-to-end, snapshot.” Every row describes a visible consequence and a reproducible input/output pair.
Regression one: a simple total exposes a floating-point tail
The broken baseline inserts the result of JavaScript Number multiplication straight into a string. Submit quantity 3 with a unit price of 0.10, and the page renders $0.30000000000000004.

Figure 1: The actual binary floating-point tail shown by the broken baseline.
The repair does not depend on adding a final round() call to the display. It parses a price with at most two fractional digits into integer cents, limits quantity to whole values from 1 through 99, multiplies the integers, then formats the result as USD. The valuable contract is not whether an internal helper named parsePriceToCents ran. It is whether the public result remains $0.30.
The same contract set probes two boundaries: 99 × 9999.99 displays $989,999.01, and 0, 1e2, and 1.005 receive precise errors. Those checks begin with input and reader-visible output, so they continue to protect the same promise if the internal money implementation changes later.
Regression two: refresh is part of the ordinary anonymous flow
The broken page keeps edits only in memory. After entering 7 and 4.25, it says those edits exist only in memory; a refresh returns the defaults, 3 and 0.10. A person can reach this path without signing in, making a payment, or seeing a network failure.

Figure 2: The broken baseline cannot restore an anonymous draft after an interrupted edit.
The repaired page writes the small draft to browser-local storage on every input event. In the actual walk-through, I entered 7 and 4.25 before pressing Calculate subtotal, refreshed, and found both values still in the form.

Figure 3: The repaired page restores the same local draft after an interrupted edit.
That decision has a useful boundary: it helps an anonymous person continue work in the same browser profile. It does not create cross-device synchronization or carry order and payment state. Stating that boundary beside the implementation prevents “the form resumes” from being read as “there is now a complete account system.”
Preserve the next action when an error occurs
Validation needs more than a Boolean. In the browser walk-through, I changed quantity to 0 and submitted it. The page showed Quantity must be a whole number from 1 to 99. while retaining 0 and the unit price 4.25, so the next correction was immediately available.

Figure 4: The error stays beside the current operation and does not erase the input.
There is another recovery path that is rarer but harder to explain: a prior saved value cannot be parsed at all. To exercise it, I deliberately stored invalid JSON and refreshed. The page cleared that bad value, returned to 3 and 0.10, and showed Recovered a blank draft after unreadable saved data.

Figure 5: Unreadable local data does not leave the form blank or broken.
Keep proof that the broken behavior really fails
The lab does not quietly remove the broken versions. Run this command:
node scripts/run-evidence.mjs
The first two regressions are expected to return exit status 1; the repaired public-behavior contract is expected to return 0. This run used Node v26.0.0 and produced:
broken-money: status 1 (expected 1)
broken-draft: status 1 (expected 1)
fixed-contract: status 0 (expected 0)
The failure logs retain the actual $0.30000000000000004 value and the post-refresh default draft. The repaired test has six passing checks for money, the maximum boundary, three invalid inputs, anonymous refresh, damaged-data recovery, and preserved completed-draft state while an invalid calculation is considered. This separates “the test script ran” from “the test caught the intended regression.”
A browser walk-through covers what the code contract cannot see
The automated contracts did not replace a page check. I served the repaired page locally at 127.0.0.1:4341 and checked that the anonymous explanation, labels, error text, buttons, and result appear together on the desktop page. I also checked a 390 × 844 narrow viewport, where the inputs, both buttons, and $0.30 result remain in one continuous reading path.

Figure 6: The repaired page during the narrow-screen walk-through.
Playwright’s official best-practices guide recommends assertions about user-visible behavior, isolation where possible, and testing only what you control. This lab applies those ideas but did not install or run Playwright: Node contracts cover the controllable local calculation and draft state, while a browser walk-through checks the actual controls and recovery text. The official guide is the method source; the page, inputs, failure logs, and screenshots here are results from this experiment.
For a small project of your own, choose one path a person will actually take. For each risk that can produce a wrong output, lost progress, or an unrecoverable state, prepare one input that exposes it. Once those small contracts and one real page walk-through are stable, let new flows—not a generic checklist—justify the next expansion of the test set.