DEV Community

Cover image for Keep existing equipment separate from replacement intent in a form schema
The Doctor
The Doctor

Posted on

Keep existing equipment separate from replacement intent in a form schema

“Explore a heat pump” and “Gas” can both be correct answers in the same hot water brief. One describes what the homeowner wants to investigate. The other describes equipment already on site. The current Astro flow collects them as Project and Existing system, two independent questions that remain separate in the summary.

Make an intent change without rewriting history

A future structured payload should preserve both dimensions. Using one systemType field invites accidental overwrites, especially if a client preselects an option on the next screen. The type below is an example of an API contract for a future version. The current preview uses in-memory labels and issues no enquiry.

type Present = 'electric' | 'gas' | 'solar' | 'heat-pump' | 'unknown';
type Intent = 'replace' | 'explore-heat-pump' | 'new' | 'advice';
type Brief = { existing: Present; intent: Intent };
const current: Brief = { existing: 'gas', intent: 'explore-heat-pump' };
const revised: Brief = { ...current, intent: 'advice' };
Enter fullscreen mode Exit fullscreen mode

Use two assertions in the browser

Open the hot water page, select Explore a heat pump and Gas, then finish the household, timing and postcode steps. Check the summary contains those values under their corresponding labels. Return to the first question, choose I would like advice, and advance. The Gas button should still be pressed. Complete the remaining steps and check that only the Project row changed.

That browser check tests the actual navigation and state retention. If the typed payload is implemented later, add a schema-level test that rejects equipment strings used as intent values. It should accept unknown equipment without inventing a target capacity, efficiency number or installation recommendation.

A component-level test should also check that a change to the display label leaves a future stable semantic value alone. The current client records labels, so this would be a behaviour change and needs explicit mapping.

Perth Quotes hot water planner is the live preview. Online enquiries are closed.

Top comments (0)