A person selects “Within a month” in a fencing planner, reaches the summary, goes back and changes their mind to “Just planning.” The revised summary should display one timing answer. The postcode they already entered should still be there, and moving to the next screen should put keyboard focus somewhere useful.

That is a small interaction with several independent failure modes. An append-only answer list can show duplicates. A form that remounts each step can lose the postcode. A visually correct transition can leave keyboard focus on a button inside a hidden panel. Here’s how the Perth Quotes frontend handles those cases and what its browser suite checks. Live fencing planner

Give each answer a single location in state

Astro renders the panels up front. The client script hides all but the active panel. The flow has four multiple-choice questions, a postcode step and a final screen that displays a summary with contact collection disabled. A fixed question order lets the client key a Map by panel index. The handler updates the answer and the selected state before advancing.

// Excerpt from the client-side answer handler. answers.set(current, button.dataset.answer!); panels[current].querySelectorAll('[data-answer]').forEach(option => { option.setAttribute('aria-pressed', String(option === button)); }); show(current + 1); 

Back navigation changes which panel is visible. It doesn’t reset the Map or recreate the postcode input, so that input keeps its current value. On valid Continue, the script clears the previous summary and builds its rows from the Map. Calling Map.set for the same key replaces the value while preserving that key’s position. If the flow ever gains conditional branches, use stable question IDs and decide explicitly which answers to discard when a branch changes.

Test the trip back from the summary

The repo’s Playwright suite exercises the journey from initial answers through postcode validation to revision. Here’s a standalone version of the revision check for a local dev server. Scoping the last assertions to the summary prevents the test from passing just because the updated button label still exists in a hidden panel.

import { expect, test } from '@playwright/test'; test('fencing summary replaces a revised timing answer', async ({ page }) => { await page.goto('/fencing/'); const choose = (name: string) => page.getByRole('button', { name, exact: true }).click(); await choose('Replace a fence'); await choose('Colorbond steel'); await choose('10–30 metres'); await choose('Within a month'); const postcode = page.getByLabel('WA postcode', { exact: true }); await expect(page.getByRole('heading', { name: 'What is your WA postcode?', })).toBeFocused(); await postcode.fill('6062'); await postcode.press('Enter'); await choose('Back'); await expect(postcode).toHaveValue('6062'); await choose('Back'); await expect(page.getByRole('button', { name: 'Within a month' })) .toHaveAttribute('aria-pressed', 'true'); await choose('Just planning'); await choose('Continue'); const summary = page.locator('[data-answer-summary]'); await expect(summary.getByText('Timing', { exact: true })).toHaveCount(1); await expect(summary.getByText('Just planning', { exact: true })).toBeVisible(); await expect(summary.getByText('Within a month', { exact: true })).toHaveCount(0); await expect(page.getByLabel('Your name', { exact: true })).toBeDisabled(); }); 

To run the repository’s existing fencing checks from the project root:

npm run test:e2e -- frontend/test/services.spec.ts -g "^Fencing:" 

Keep the postcode and contact checks separate

The postcode check accepts four digits beginning with 6. That validates shape only. The browser has neither a postcode directory lookup nor a serviceability check in this flow. The final screen is a preview. Contact inputs live inside a disabled fieldset, and the summary is built from in-memory state. The existing browser test checks that the path issues no non-GET requests and leaves both local and session storage empty in its test configuration. Those assertions give the preview an explicit behavioural contract while enquiries are closed.