mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 13:23:04 +00:00
feat(costs): let a trip keep its costs as totals only (#1714)
Travellers who track what a trip costs but never split it saw an Unfinished warning on every expense and a settle-up they had no use for. A trip now has a costs mode (appended migration, trips.costs_mode, split by default); totals leaves payers, shares and settling up out of Costs on desktop and phone through the same gate as a trip of one, and saves new expenses without a payer. PUT /api/trips/:id and update_trip take it on budget_edit. The split chips move into their own component.
This commit is contained in:
@@ -18,7 +18,7 @@ import { server } from '../../../helpers/msw/server'
|
||||
import { fireEvent, render, screen, waitFor, within } from '../../../helpers/render'
|
||||
import { setSizeClass } from '../../../helpers/sizeClass'
|
||||
|
||||
// FE-MOB-COSTT-001 to FE-MOB-COSTT-056
|
||||
// FE-MOB-COSTT-001 to FE-MOB-COSTT-057
|
||||
|
||||
// The add/edit expense sheet is the shared desktop-sized form; the panel only
|
||||
// owns when it opens and what happens on save, so it is stubbed here.
|
||||
@@ -982,4 +982,19 @@ describe('MCostsTab', () => {
|
||||
// The souvenirs nobody paid for are an expense like any other here.
|
||||
expect(screen.getByText('Souvenirs')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-COSTT-057: a trip that keeps totals only leaves out what is owed, and its switch turns splitting back on (#1714)', async () => {
|
||||
const updateTrip = vi.fn(async () => TRIP)
|
||||
useTripStore.setState({ updateTrip })
|
||||
render(<MCostsTab planner={planner({ trip: { ...TRIP, costs_mode: 'totals' } as Trip })} shell={buildShell()} />)
|
||||
await waitFor(() => expect(settlementBases).toEqual(['USD']))
|
||||
for (const key of ['costs.youOwe', 'costs.settleUp', 'costs.finalBudget', 'costs.filter.mine', 'costs.unfinished']) {
|
||||
expect(screen.queryByText(key)).not.toBeInTheDocument()
|
||||
}
|
||||
const toggle = screen.getByRole('button', { name: 'costs.mode.label' })
|
||||
expect(toggle).toHaveAttribute('aria-pressed', 'false')
|
||||
expect(screen.getByText('costs.mode.hintTotals')).toBeInTheDocument()
|
||||
fireEvent.click(toggle)
|
||||
await waitFor(() => expect(updateTrip).toHaveBeenCalledWith(7, { costs_mode: 'split' }))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user