Let a day removed from a period stay removed
Taking one day out of a period the planner placed did nothing that lasted: the period still asked for a full week, so the next sync put the day straight back. The option was disabled rather than lying about it. A removed day is now recorded as its own thing — no leave for this parent, this child, this date — and the planner honours it on every later sync. It is kept apart from the working-day overrides, which answer a different question about the calendar rather than about the plan. The day belongs to the parent whose band was clicked, so removing one parent's day leaves their partner's alone; where both parents were to be off on one funding arrangement, the partner is simply funded on their own instead. A removed day shortens what the period is asking for rather than counting as a day the plan failed to find, so the advice about closing a shortfall does not start arguing for a day nobody wants. Nothing is removed without a way back: the toast undoes it, and the day itself is marked in the calendar and offers to restore. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ei7gCZzdd751uZtPzb1Pep
This commit is contained in:
@@ -388,17 +388,52 @@ describe('PeriodPopover', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('disables "this day" and shows why, for a wish-linked band (would just reappear on the next sync)', () => {
|
||||
// Intent changed (was: '"this day" is disabled for a wish-linked band').
|
||||
// A single day removed from a planner-placed period is now recorded as a
|
||||
// `PlannedDayExclusion`, so it no longer reappears on the next sync and
|
||||
// the option is live — see Calendar.tsx's `excludeDay`.
|
||||
it('enables "this day" for a wish-linked band and explains what it does', () => {
|
||||
render(<PeriodPopover {...defaultProps} wish={wish} />)
|
||||
expect(screen.getByTestId('period-delete-day-button')).toBeDisabled()
|
||||
expect(screen.getByTestId('period-delete-day-button')).not.toBeDisabled()
|
||||
expect(screen.getByTestId('period-delete-day-button')).toHaveAttribute(
|
||||
'title',
|
||||
"Går inte att ta bort en enskild dag från en återkommande plan — planeraren lägger tillbaka den vid nästa synk. Ta bort perioden istället.",
|
||||
'Bara den dagen tas bort. Resten av perioden ligger kvar, och planeraren lägger inte tillbaka dagen.',
|
||||
)
|
||||
expect(screen.getByTestId('period-delete-year-button')).not.toBeDisabled()
|
||||
expect(screen.getByTestId('period-delete-all-years-button')).not.toBeDisabled()
|
||||
})
|
||||
|
||||
it('calls onDelete with the "day" scope for a wish-linked band after confirmation', async () => {
|
||||
mockOnDelete.mockResolvedValue(undefined)
|
||||
render(<PeriodPopover {...defaultProps} wish={wish} />)
|
||||
fireEvent.click(screen.getByTestId('period-delete-day-button'))
|
||||
fireEvent.click(screen.getByTestId('period-delete-confirm-button'))
|
||||
await waitFor(() => expect(mockOnDelete).toHaveBeenCalledWith('day'))
|
||||
})
|
||||
|
||||
it('names the date and the parent in the "this day" confirmation', () => {
|
||||
render(
|
||||
<PeriodPopover
|
||||
{...defaultProps}
|
||||
wish={wish}
|
||||
removeDayLabel="17 juni 2028"
|
||||
removeDayParentName="Alex"
|
||||
/>,
|
||||
)
|
||||
fireEvent.click(screen.getByTestId('period-delete-day-button'))
|
||||
expect(screen.getByTestId('period-delete-confirm')).toHaveTextContent(
|
||||
'Ta bort 17 juni 2028 för Alex?',
|
||||
)
|
||||
})
|
||||
|
||||
it('falls back to the generic confirmation when the parent is unknown', () => {
|
||||
render(<PeriodPopover {...defaultProps} wish={wish} removeDayLabel="17 juni 2028" />)
|
||||
fireEvent.click(screen.getByTestId('period-delete-day-button'))
|
||||
expect(screen.getByTestId('period-delete-confirm')).toHaveTextContent(
|
||||
'Är du säker på att du vill ta bort den här dagen?',
|
||||
)
|
||||
})
|
||||
|
||||
it('displays a generic local error when onDelete rejects with a non-Error value', async () => {
|
||||
mockOnDelete.mockRejectedValue('boom')
|
||||
render(<PeriodPopover {...defaultProps} wish={wish} />)
|
||||
|
||||
Reference in New Issue
Block a user