Test the two gestures the rework is actually about

The browser suite checked what the app renders but nothing about authoring,
which is the part that changed. It now registers a fresh account and walks
the wizard, including the case where a partner added mid-wizard has to appear
by name without navigating away first, and it drags a range on the calendar,
deletes the period, and reloads to confirm the days really went. Both are
regressions that were found by hand within the last day and would have been
found here instead.

Doing this surfaced that the age-four spec had been asserting on figures that
moved inside a collapsed section, so it had stopped checking anything. The
stale note about the retired tips page went too.
This commit is contained in:
2026-09-18 00:50:01 +02:00
parent c5587c5b46
commit bcc93e5c03
6 changed files with 257 additions and 9 deletions
+41
View File
@@ -21,3 +21,44 @@ export async function goToCalendarMonth(page: Page, date: Date): Promise<void> {
export function calendarDayCell(page: Page, isoDate: string) {
return page.locator(`[data-testid="calendar-day"][aria-label^="${isoDate}"]`)
}
/**
* Drives a real drag-select across the given ISO dates (in order), the way
* `Calendar.tsx` expects it: `CalendarDay` wires plain `onPointerDown`/
* `onPointerEnter` handlers (see `CalendarWeek.tsx`), and the page only
* treats the gesture as a multi-day drag if `pointerenter` actually fired
* for every intermediate cell before `pointerup` — see the `dates.length
* === 1` branch in `Calendar.tsx`'s `pointerup` handler, which opens the
* single-day modal instead of creating a period.
*
* A single fast `mouse.move` (or Playwright's default `hover()`/`dragTo()`)
* can collapse into one native pointer event and skip the intermediate
* cells entirely, which reads as a click on the anchor date. Moving in
* several steps per cell, with a short pause between cells, is what
* reliably fires a `pointerenter` on each one.
*/
export async function dragSelectDates(page: Page, isoDates: string[]): Promise<void> {
if (isoDates.length < 2) {
throw new Error('dragSelectDates needs at least two dates to actually drag across')
}
const centerOf = async (isoDate: string): Promise<{ x: number; y: number }> => {
const box = await calendarDayCell(page, isoDate).boundingBox()
if (!box) throw new Error(`calendar day cell not visible for ${isoDate} — is it in the current month view?`)
return { x: box.x + box.width / 2, y: box.y + box.height / 2 }
}
const [firstDate, ...restDates] = isoDates
if (!firstDate) throw new Error('dragSelectDates needs at least two dates to actually drag across')
const start = await centerOf(firstDate)
await page.mouse.move(start.x, start.y)
await page.mouse.down()
for (const isoDate of restDates) {
const point = await centerOf(isoDate)
await page.mouse.move(point.x, point.y, { steps: 10 })
await page.waitForTimeout(50)
}
await page.mouse.up()
}
+54
View File
@@ -0,0 +1,54 @@
/**
* Shared registration/onboarding steps for specs that need a brand-new,
* empty account rather than the shared demo workspace (`global-setup.ts`'s
* seeded data) — e.g. because the gesture under test needs a clean
* calendar, or because the demo user's own balance is deliberately drained
* (see `backend/scripts/seed_demo.py`'s "near-drained FP pool" for Alex,
* which a fresh drag-created period pinned to the logged-in parent would
* otherwise fail to fund).
*
* Every date here is derived from "today", never a hardcoded year.
*/
import type { Page } from '@playwright/test'
import { expect } from '@playwright/test'
import { toIsoDate, addDays } from './dates'
export function uniqueEmail(tag: string): string {
return `e2e-${tag}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}@example.com`
}
export const ONBOARDING_PASSWORD = 'E2ePassOnboard123!'
/** Registers a brand-new account through the real UI and waits for the
* onboarding wizard's first step. */
export async function registerAndReachOnboarding(page: Page, email: string, displayName: string): Promise<void> {
await page.goto('/auth')
await page.getByRole('button', { name: 'Skapa konto' }).click()
await page.getByPlaceholder('Namn').fill(displayName)
await page.getByTestId('auth-email').fill(email)
await page.getByTestId('auth-password').fill(ONBOARDING_PASSWORD)
await page.getByTestId('auth-submit').click()
await expect(page.getByTestId('onboarding')).toBeVisible({ timeout: 15_000 })
await expect(page.getByTestId('onboarding-step-child')).toBeVisible()
}
/** Step 1 of the wizard: add the child, landing on step 2 (family). */
export async function fillChildStep(page: Page, childName: string): Promise<void> {
// Safely in the past relative to "today", regardless of when this runs.
const birthDate = toIsoDate(addDays(new Date(), -400))
await page.getByLabel('Barnets namn').fill(childName)
await page.getByTestId('birth-date-input').fill(birthDate)
await page.getByRole('button', { name: 'Lägg till barn' }).click()
await expect(page.getByTestId('onboarding-step-family')).toBeVisible()
}
/** From step 2 (family), keeps the default "solo" planning mode, continues
* to step 3 (balances) and skips it — landing on the Dashboard with the
* statutory-assumption balance (no manual fetch, no drained pool). */
export async function continueSoloAndSkipBalances(page: Page): Promise<void> {
await page.getByRole('button', { name: 'Fortsätt' }).click()
await expect(page.getByTestId('onboarding-step-balances')).toBeVisible()
await page.getByRole('button', { name: 'Hoppa över för nu' }).click()
await expect(page.getByTestId('dashboard')).toBeVisible({ timeout: 15_000 })
}
+6 -9
View File
@@ -8,18 +8,15 @@ export interface MainPage {
* The authenticated pages scanned by the "no raw UUIDs" and "no console
* errors" guards.
*
* TODO(tips-wire-format): Tips (`/tips`, root testid `tips-page`) is
* deliberately left out. Its wire-format mapping (backend snake_case ->
* frontend camelCase) was never written, so today it renders blank — a fix
* is in flight in a parallel task and touching it here would collide. Once
* that fix lands, add:
* { path: '/tips', testId: 'tips-page', name: 'Tips' }
* to this list. Both `no-uuids.spec.ts` and `console-errors.spec.ts`
* iterate this array, so nothing else needs to change.
* Plan and Tips were removed as standalone pages/tabs (leave is now
* authored directly on the calendar, and Översikt carries the headline
* figures); `/plan` and `/tips` now fall through App.tsx's catch-all route
* and redirect to `/` instead of rendering a page. That redirect is covered
* at the unit level in `src/App.test.tsx` ("retired /plan and /tips
* routes"), so neither belongs in this list.
*/
export const MAIN_PAGES: MainPage[] = [
{ path: '/', testId: 'dashboard', name: 'Dashboard' },
{ path: '/calendar', testId: 'calendar', name: 'Calendar' },
{ path: '/plan', testId: 'plan-page', name: 'Plan' },
{ path: '/settings', testId: 'settings-page', name: 'Settings' },
]