Let the planner fund a hand-drawn period, and remove one at a time
Three changes to calendar editing, too interleaved in the same files to land separately. Giving the same days to the second parent rewrote the first parent's days instead of adding their own. The save looked the existing day up against whoever was logged in rather than the parent being saved for, so parent A's leave turned into parent B's vacation. The parent choice now lives with the lookup, and two parents on the same dates produce two rows and two bands. Drawing a period by hand meant naming a day type up front. It now asks who is off and lets the planner fund it, as a one-off period the sync places, with double days offered when both parents are off and priced honestly in the hint. Pinning an exact day type is still there, moved behind Advanced, and editing a pinned day goes straight back to it. Removing a period offered only the two extremes. There are now three choices: this day, this year's period, or every year. Taking one year out of a repeating period narrows it, or splits it in two when the year is in the middle; where a scope cannot be expressed it is disabled with a reason rather than doing something surprising. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ei7gCZzdd751uZtPzb1Pep
This commit is contained in:
@@ -5,10 +5,14 @@
|
||||
* specs only check rendering (bands, red days, age-4 figures) of state the
|
||||
* API seeded directly.
|
||||
*
|
||||
* A drag no longer creates a `LeaveWish`/synced period on its own — it opens
|
||||
* the day popover pre-selected on every dragged date, and saving writes
|
||||
* exactly those days (ad-hoc `planned_leave_day` rows, no wish). See
|
||||
* `Calendar.tsx`'s pointerup handler and `handleSavePlannedDay`.
|
||||
* A drag opens the day popover pre-selected on every dragged date, same as
|
||||
* before. What that popover does on save changed (todo.md #10/#11): by
|
||||
* default it now creates a fixed, one-off `LeaveWish` and lets the planner
|
||||
* fund it (a `calendar-band-wish:` band, not `adhoc:`) — see
|
||||
* `Calendar.tsx`'s `handleSaveWish`. The old "write exact ad-hoc
|
||||
* `planned_leave_day` rows" behaviour still exists, behind the modal's
|
||||
* "Advanced" disclosure (`handleSavePinnedDay`) — the first test below
|
||||
* opens it explicitly to keep exercising that path.
|
||||
*
|
||||
* The drag deliberately crosses a month boundary (the last two days of one
|
||||
* month into the first day of the next) — a regression guard for the
|
||||
@@ -53,7 +57,7 @@ function targetRange(): { month: Date; dates: [string, string, string] } {
|
||||
return { month, dates }
|
||||
}
|
||||
|
||||
test('dragging a range across a month boundary plans every day, and deleting it removes the days for good', async ({
|
||||
test('dragging a range and pinning it through Advanced plans every day exactly, and deleting it removes the days for good', async ({
|
||||
page,
|
||||
}) => {
|
||||
await registerAndReachOnboarding(page, uniqueEmail('drag-delete'), 'Robin Testsson')
|
||||
@@ -75,6 +79,10 @@ test('dragging a range across a month boundary plans every day, and deleting it
|
||||
// A multi-day drag opens the day popover pre-selected on every dragged
|
||||
// date — it does not create a period/wish by itself.
|
||||
await expect(page.getByTestId('modal-title')).toHaveText('Planera 3 dagar')
|
||||
// The default save path would create a fixed wish instead (see the next
|
||||
// test) — opening "Advanced" keeps this test on the exact-pinned-days
|
||||
// path todo.md #10/#11 kept as an escape hatch.
|
||||
await page.getByTestId('advanced-toggle').click()
|
||||
await page.getByTestId('save-button').click()
|
||||
await expect(page.getByTestId('planned-day-modal__content')).not.toBeVisible()
|
||||
|
||||
@@ -104,7 +112,11 @@ test('dragging a range across a month boundary plans every day, and deleting it
|
||||
await expect(page.getByTestId('period-adhoc-notice')).toBeVisible()
|
||||
await expect(page.getByTestId('period-popover__content')).toContainText(`${firstDate} – ${lastDate}`)
|
||||
|
||||
await page.getByTestId('period-delete-button').click()
|
||||
// todo.md #9 — an ad-hoc band has no recurring plan, so "every year" is
|
||||
// disabled; "this day"/"this period" are the only meaningful choices, and
|
||||
// "this period" removes the whole ad-hoc range (today's only behaviour).
|
||||
await expect(page.getByTestId('period-delete-all-years-button')).toBeDisabled()
|
||||
await page.getByTestId('period-delete-year-button').click()
|
||||
await expect(page.getByTestId('period-delete-confirm')).toBeVisible()
|
||||
|
||||
// Regression guard for the "Yes, delete" footer bug: the confirm button's
|
||||
@@ -137,3 +149,47 @@ test('dragging a range across a month boundary plans every day, and deleting it
|
||||
await calendarDayCell(page, dates[1]).click()
|
||||
await expect(page.getByTestId('modal-title')).toHaveText('Planera en dag')
|
||||
})
|
||||
|
||||
test('a drag saved without opening Advanced creates a planner-funded wish, and the three-way remove deletes it', async ({
|
||||
page,
|
||||
}) => {
|
||||
// todo.md #10/#11 — the default path no longer writes pinned days
|
||||
// directly: it creates a fixed, one-off `LeaveWish` and lets the sync
|
||||
// fund it, so the resulting band is wish-linked (`calendar-band-wish:`),
|
||||
// not `adhoc:`.
|
||||
await registerAndReachOnboarding(page, uniqueEmail('drag-wish'), 'Robin Testsson')
|
||||
await fillChildStep(page, 'Nova')
|
||||
await continueSoloAndSkipBalances(page)
|
||||
|
||||
const { month, dates } = targetRange()
|
||||
|
||||
await goToCalendarMonth(page, month)
|
||||
|
||||
const wishBand = page.locator('[data-testid^="calendar-band-wish:"]')
|
||||
await expect(wishBand).toHaveCount(0)
|
||||
|
||||
await dragSelectDates(page, dates)
|
||||
await expect(page.getByTestId('modal-title')).toHaveText('Planera 3 dagar')
|
||||
// A solo account has no parent-mode selector to touch — save directly.
|
||||
await page.getByTestId('save-button').click()
|
||||
await expect(page.getByTestId('planned-day-modal__content')).not.toBeVisible()
|
||||
|
||||
await expect(wishBand.first()).toBeVisible()
|
||||
|
||||
// Open the wish-linked band. Its own three-way remove: "this day" cannot
|
||||
// be expressed for a wish (it would just reappear on the next sync) and
|
||||
// is disabled; "this period" on a `recurrence: 'once'` wish (there is
|
||||
// only one occurrence) removes the whole thing, same as "every year".
|
||||
await wishBand.first().click()
|
||||
await expect(page.getByTestId('period-popover__content')).toBeVisible()
|
||||
await expect(page.getByTestId('period-delete-day-button')).toBeDisabled()
|
||||
|
||||
await page.getByTestId('period-delete-year-button').click()
|
||||
await expect(page.getByTestId('period-delete-confirm')).toBeVisible()
|
||||
await page.getByTestId('period-delete-confirm-button').click()
|
||||
await expect(page.getByTestId('period-popover__overlay')).not.toBeVisible()
|
||||
|
||||
await page.reload()
|
||||
await goToCalendarMonth(page, month)
|
||||
await expect(page.locator('[data-testid^="calendar-band-wish:"]')).toHaveCount(0)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user