fix(roadtrip): a stop added by hand opens on the kind being looked for

The button carried nothing and the form hard-wired the kind, so the categories
sitting directly above it had no way through and every manual stop started life
as a fuel stop with ten minutes on it. The click now carries what the corridor
is looking for, dwell included. The picker is multi-select, so the first kind
the panel lists wins rather than a fallback nobody switched on; with nothing
selected the form falls back on its own, because a stop without a kind is a
numbered destination that counts in every total.

This also closes the case it was noticed on: an electric car seeds the panel to
charging, so the picker said Charging over a form that said Fuel.
This commit is contained in:
Maurice
2026-09-18 13:17:59 +02:00
parent e9742e9322
commit 5ef8bf31f4
8 changed files with 119 additions and 13 deletions
@@ -1772,6 +1772,16 @@ describe('PlaceFormModal as a road trip service stop', () => {
expect(screen.getAllByText('Add as a stop').length).toBeGreaterThan(0);
});
it('FE-PLANNER-PLACEFORM-085: it opens on the kind the corridor was looking for, dwell and all', () => {
// The panel seeds itself to charging on an electric car, and a form opening on a
// fuel pump under a picker that says Charging is the fault this carries the answer to.
render(<PlaceFormModal {...defaultProps} serviceStop={serviceStop({ defaultKind: 'charging' })} />);
expect(screen.getByRole('button', { name: 'Charging' })).toHaveAttribute('aria-pressed', 'true');
expect(screen.getByRole('button', { name: /30 min/ })).toHaveAttribute('aria-pressed', 'true');
expect(screen.getByRole('button', { name: 'Fuel' })).toHaveAttribute('aria-pressed', 'false');
});
it('FE-PLANNER-PLACEFORM-076: picking a kind also picks how long that kind takes', async () => {
const onSave = vi.fn().mockResolvedValue({ id: 9 });
render(<PlaceFormModal {...defaultProps} onSave={onSave} serviceStop={serviceStop()} />);