[PR #173·177·180] Three App Record-Entry Screens: Splitting Tests from Code Exposed Where the Tests Disagreed
The three PRs add one kind of input at a time to the same “new record” screen. First a record with photos and an observation (PR 173), then a measurement record with a number per item (PR 177), and finally a record where several samples are measured, plus a help screen and a recent-record card (PR 180). I requested all three, and a team of agents worked with the test writer and the implementer split, so nobody writes the tests for code they will implement themselves.
- What was done:
- PR 173, observation record: takes photos and a measurement time and saves. Only after the server confirms the save does the app put the record in its local store (cache), clear the draft in progress, and show the done screen. Pressing the button repeatedly while saving sends once, and on failure the input and draft are kept and the retry reuses the same request number.
- PR 177, per-item measurement: builds input fields from the item list the server returns. A blank field is not sent, but
0is sent as a value. A value outside the check range goes through a re-check screen before saving, and only rows the user confirmed get a “confirmed” mark. The existing draft store keeps the input across errors and screen changes. - PR 180, multi-sample measurement: takes values measured all at once or one by one. Here too a blank is left out as “not entered”, not turned into
0. If too few samples were measured, it refuses before saving. It also remembers the last input kind chosen, and adds a recent-record card and a help screen for this screen.
- Methods chosen and alternatives dropped:
- Matching the shape the tests set (PR 173): the tests draw the screen from passed-in values (props), so the option of reading them only through hooks (React functions that read a screen’s state) was dropped and both are accepted. The draft button is named “keep draft” rather than “save draft” because a test looking for buttons containing “save” matched two and failed.
- Passing values to the re-check screen (PR 177 tests): passing them through the address was dropped and the screen reads them from the draft. The plan had no such contract, and a test that fixes one would tie the implementation down.
- Saving from the re-check screen (PR 177 implementation): no new save path; it reuses the save function and the request builder from the earlier work. Pre-filling inputs from sensors or earlier values was not adopted.
- Switching input mode (PR 180): instead of a “together / one by one” toggle, both inputs are shown on one screen, because the tests look for both fields as soon as the tab opens. If any one-by-one field has a value, it is treated as a one-by-one record.
- Error names: the names from the earlier work, which the tests already use, were kept.
- Where the tests disagreed (PR 173): the tests had been written first, and Claude did not edit them. Once the implementation existed, some tests contradicted each other.
- A test fixed the clock, but the implementation used the real clock to decide what counts as a “future time”, so two tests could not both pass.
- One test said the save button is off without photos, while two others pressed save without photos and expected a server request.
- A test looked for text right after drawing even though the draft is read asynchronously, and another could not reach the photo upload because the mock (a stand-in object) of the file tools was missing pieces.
- Claude did not edit the tests; it stopped at that point and left the mismatches as a list of questions.
- How it was checked:
- PR 173: type checks and lint passed. All existing app tests passed, and 8 of the new tests failed because of the contradictions above, so the full
npm run verifywas not run. - PR 177, test stage: Claude wrote only tests. Running them, 7 of 8 failed because the feature did not exist yet, and one (future time) already passed as a guard test. The new screen test file could not even open because a required module was missing, so every failure reason was a missing module or feature.
- PR 177, implementation stage: Codex’s work environment could not start the test runner (Jest), so tests were not run. Only type checks and lint passed, and the implementation was built by reading the two specified test files.
- PR 180: in the test stage all 12 new tests failed only because the implementation did not exist, and the 21 existing ones passed. After the implementation, every app test file was run one by one and all passed, with type checks passing. In this environment the process did not exit after the tests, so
--forceExit(an option that forcibly closes the process when tests finish) was used. That problem is covered in a separate post about PR 179.
- PR 173: type checks and lint passed. All existing app tests passed, and 8 of the new tests failed because of the contradictions above, so the full
The three PRs at a glance
| PR | Input kind | Key method |
|---|---|---|
| 173 | Observation record (photo required) | Cache only after the server confirms; repeated presses while saving send once |
| 177 | Per-item measurement | Blank left out, 0 sent as a value; out-of-range values re-checked before saving |
| 180 | Multi-sample measurement | Blank left out, not 0; both inputs on one screen, judged by which has values |
Who did what
- I: requested all three.
- Claude (cloud session, Claude Sonnet 5.5): implemented PR 173, wrote only the tests for PR 177, and implemented PR 180.
- Claude (Claude Code on my Windows computer, Claude Sonnet 5.5): in the PR 180 test stage, wrote the instructions, checked the result and committed.
- Codex (gpt-5.6-luna): implemented PR 177 and wrote the tests for PR 180. After the implementation, Codex updated an old test’s placeholder expectation (“see you in the next update”) to match the new screen. Codex also wrote the tests for PR 173 first, but the model used then is not in the log, so I could not confirm it.
What was not verified
- The photo-picking flow on a real device was not checked.
- The PR 177 implementation was not verified by running its tests.
- For PR 180, a race where pressing help or back extremely fast could overwrite the draft appears in the log only as a risk, and was not reproduced.
What I learned
- The test writer should also check, without any implementation, that the tests do not contradict each other. The clock, the conditions for enabling the button, and the fake setup were the examples.
- When the implementer stops and asks instead of quietly editing the tests, the mismatches come out.
- A blank and 0 are different. Leave a blank out as “not entered” and send 0 as a value.
- For out-of-range values, ask for one more confirmation before saving rather than blocking.
- When a test fixes a contract the plan never made, it ties the implementation down. Do not fix undecided things, like how a value is passed, inside a test.