Test multi-select combinations before adding them to a single-choice planner
The current turf planner asks for one location, one project type, size and timing. A future use question would be different. An area can be for pets and play. Replacing a set with one chosen value would silently discard
The current turf planner asks for one location, one project type, size and timing. A future use question would be different. An area can be for pets and play. Replacing a set with one chosen value would silently discard a use and any follow-up the app derives from it.
Deduplicate follow-ups while preserving both purposes
For a proposed multi-select, assign each use its own ID and derive visible questions from the entire selection. Shared follow-ups such as drainage need only appear once. Preserve an explicit order so selecting play before pets yields the same experience as choosing them in the reverse order.
type Use = 'pets' | 'play';
const order: Use[] = ['pets', 'play'];
const fields = { pets: ['drainage', 'cleaning'], play: ['drainage', 'shade'] };
const followUps = (uses: ReadonlySet) =>
[...new Set(order.filter(use => uses.has(use)).flatMap(use => fields[use]))];
Test the intersection and the return journey
Unit-test the empty set, each single use and both uses in both insertion orders. With both selected, check that drainage appears once and cleaning and shade are present. At browser level, go back and deselect pets. Assert that questions unique to pets are removed and decide how their previous answers are handled if pets is selected again. Also assert that play remains in the final summary.
The current Turf questions use the shared single-choice controller. This is a proposed extension and would need changes to its navigation and answer model. The combination tests give the new interaction a precise contract without implying the software can judge surface suitability.
Define question identity independently from labels here as well. If two uses share drainage, they should point to a single field ID. A label change or translation should leave the intersection test passing.
Perth Quotes artificial grass planner is the live preview. Online enquiries are closed.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.