The existing retaining wall planner asks about project type, location, length and timing. Build, replace and assess all follow the same four-step route. The shared browser script uses panel indexes for answers and builds a summary at a fixed final index. That simpler rule is visible in the UI and the tests.
Why a branch changes the contract
If a future design adds a movement question for existing walls only, changing an earlier choice could make an old answer irrelevant. Keeping it in the summary would silently change the scope of a new wall. A discriminated union gives the application a way to express which information is valid for each path.
type Draft =
| { project: 'new'; location: string }
| { project: 'existing'; location: string; movement?: 'yes' | 'no' | 'unknown' };
function startNew(previous: Draft): Draft {
return { project: 'new', location: previous.location };
}
Test the transition, not just each destination
The example illustrates a proposed design, not current branching. For an implementation, start in the existing-wall branch and record movement. Go back and choose new. Verify that the hidden answer is absent both from the DOM summary and from whatever value would be submitted. Switch back again and assert an explicit choice about whether the previous answer should be restored.
For the current release, a browser check can confirm the shared linear contract by exercising both Replace a retaining wall and Build a new retaining wall, then comparing the summary labels. They should contain the same dimensions and remain a brief. A choice in the Project field supplies no engineering result, approval decision or height assessment.
A useful invariant test checks that the total panel count and the final index agree. The present script calls show(5). Introducing an extra panel without changing that assumption would make postcode continuation land in the wrong place.
Perth Quotes retaining wall planner is the live preview. Online enquiries are closed.
Top comments (0)