test(tours): align assignment coverage with row action

This commit is contained in:
elmocito
2026-10-06 15:09:50 +02:00
parent 99f3bbfb09
commit a05855ee2b
3 changed files with 25 additions and 9 deletions
@@ -72,7 +72,7 @@ describe('CustomSelect consumer contracts', () => {
expect(setDifficulty).toHaveBeenLastCalledWith(4)
})
it('keeps the post-save day menu resolving numeric day ids', async () => {
it('routes post-save assignment through the Tour-row menu and resolves numeric day ids', async () => {
const user = userEvent.setup()
const onAssignToDay = vi.fn().mockResolvedValue(undefined)
render(<TranslationProvider><TourPlannerToursRail
@@ -80,8 +80,13 @@ describe('CustomSelect consumer contracts', () => {
planner={planner({ saveOutcome: tour, editingPlaceId: 42 })}
tours={[tour]} days={days} loading={false} onAssignToDay={onAssignToDay} onViewGpxTour={vi.fn()}
/></TranslationProvider>)
await user.click(screen.getByRole('button', { name: 'Assign to a day' }))
await user.click(screen.getByRole('button', { name: /Day 1/ }))
const saveBanner = screen.getByText('Tour saved').closest('[role="status"]')!
expect(within(saveBanner).getByRole('button', { name: 'Plan another' })).toBeInTheDocument()
expect(within(saveBanner).queryByRole('button', { name: 'Assign to a day' })).not.toBeInTheDocument()
await user.click(screen.getByRole('button', { name: 'Add to day: Ridge walk' }))
const dayOption = screen.getByRole('button', { name: /Summit day/ })
expect(dayOption).toHaveTextContent(/Day 1/)
await user.click(dayOption)
expect(onAssignToDay).toHaveBeenCalledWith(42, 7)
})