Stop two stale ids reaching the API, and steer the drag test off free days

Post-merge verification of the six merged branches turned up two real
frontend defects and one stale test expectation.

Settings mounts before WorkspaceContext has populated, so PartnerInvitePanel
asked for invitations with an empty workspace id. The empty path segment
collapses in Vite's proxy, FastAPI matches the single-segment workspace route
with workspace_id="invitations", and the UUID parse 422s. Guarded the same way
useWorkspaceMembers already does.

PlanSyncProvider could sync a workspace id seeded from localStorage before
WorkspaceContext refreshed it — a workspace a reseed had since deleted. It
logged the resulting 404 and kept retrying it on every planVersion bump. A 404
now refreshes the workspace context instead, correcting the id rather than
narrating the failure forever.

The drag-create-delete expectation was simply out of date: vacation-typed saves
correctly exclude free days, and targetRange() only skipped months ending on a
Sunday, so a Monday-ending month put a Sunday in the range. It now skips any
free day, computed independently of the calendar data the backend itself reads.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-21 09:22:30 +02:00
parent 44a18713a5
commit 2c46cf762d
6 changed files with 145 additions and 18 deletions
+17 -7
View File
@@ -29,7 +29,7 @@
*/
import { test, expect } from '@playwright/test'
import { goToCalendarMonth, calendarDayCell, dragSelectDates } from '../support/calendarNav'
import { toIsoDate, addDays } from '../support/dates'
import { toIsoDate, addDays, isSwedishFreeDay } from '../support/dates'
import { uniqueEmail, registerAndReachOnboarding, fillChildStep, continueSoloAndSkipBalances } from '../support/onboarding'
test.use({ storageState: { cookies: [], origins: [] } })
@@ -41,20 +41,30 @@ test.use({ storageState: { cookies: [], origins: [] } })
* all after the "no phantom week" fix; see `Calendar.tsx`'s week-building
* loop). Returns that month plus the last two of its days and the first day
* of the next month — the exact range the drag below crosses.
*
* None of the three dates may be a free day (weekend or red day): the
* first test below saves them with an explicit `vacation` day type, and
* the second lets the planner fund them as a wish — both deliberately drop
* free days from what actually gets persisted (see `handleSavePinnedDay`
* in `src/pages/Calendar.tsx` and the backend's `PlanningService.
* _reject_illegal_free_day`/`is_free_day`). Checking only the month's last
* day for a Sunday missed two cases: (1) that day being a Monday instead,
* which makes `dates[0]` (the day before it) a Sunday, and (2) a red day
* landing on any of the three regardless of weekday (e.g. the month rolls
* into a New Year's Day) — either would silently persist/fund fewer than
* three days, which the assertions below don't expect.
*/
function targetRange(): { month: Date; dates: [string, string, string] } {
const now = new Date()
let month = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth() + 2, 1))
let lastDayOfMonth = new Date(Date.UTC(month.getUTCFullYear(), month.getUTCMonth() + 1, 0))
while (lastDayOfMonth.getUTCDay() === 0 /* Sunday */) {
let candidateDates = [addDays(lastDayOfMonth, -1), lastDayOfMonth, addDays(lastDayOfMonth, 1)]
while (candidateDates.some(isSwedishFreeDay)) {
month = new Date(Date.UTC(month.getUTCFullYear(), month.getUTCMonth() + 1, 1))
lastDayOfMonth = new Date(Date.UTC(month.getUTCFullYear(), month.getUTCMonth() + 1, 0))
candidateDates = [addDays(lastDayOfMonth, -1), lastDayOfMonth, addDays(lastDayOfMonth, 1)]
}
const dates = [addDays(lastDayOfMonth, -1), lastDayOfMonth, addDays(lastDayOfMonth, 1)].map(toIsoDate) as [
string,
string,
string,
]
const dates = candidateDates.map(toIsoDate) as [string, string, string]
return { month, dates }
}