Files
F-r-ldraledigplannerare/frontend/e2e/tests/onboarding.spec.ts
T
jacobh2 bcc93e5c03 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.
2026-09-18 00:50:01 +02:00

63 lines
3.0 KiB
TypeScript

/**
* The other authoring gesture nothing end-to-end covers yet: registering a
* brand-new account and walking the 3-step onboarding wizard (child ->
* solo/couple -> balances). Runs with an empty `storageState` — deliberately
* NOT the shared demo session `auth.setup.ts` produces for the rest of the
* suite — since registering a fresh account is exactly what's under test.
*
* Every date used here is derived from "today", never a hardcoded year (see
* `support/dates.ts`'s module doc for why).
*/
import { test, expect } from '@playwright/test'
import {
uniqueEmail,
registerAndReachOnboarding,
fillChildStep,
continueSoloAndSkipBalances,
} from '../support/onboarding'
test.use({ storageState: { cookies: [], origins: [] } })
test.describe('onboarding wizard', () => {
test('skipping the balances step still reaches the dashboard with the estimated badge', async ({ page }) => {
await registerAndReachOnboarding(page, uniqueEmail('onboarding-skip'), 'Alex Testsson')
await fillChildStep(page, 'Nova')
// Solo is the wizard's default planning mode — nothing to change here.
await continueSoloAndSkipBalances(page)
await expect(page.getByTestId('dashboard-estimate-badge')).toHaveText('Uppskattat')
})
test('a partner added mid-wizard shows their name on Översikt with no navigation in between', async ({ page }) => {
await registerAndReachOnboarding(page, uniqueEmail('onboarding-couple'), 'Sam Testsson')
await fillChildStep(page, 'Nova')
await page.getByTestId('planning-mode-couple').check()
await expect(page.getByTestId('onboarding-partner-section')).toBeVisible()
await page.getByLabel('Partnerns namn').fill('Kim')
await page.getByRole('button', { name: 'Lägg till partner' }).click()
await expect(page.getByTestId('onboarding-partner-added')).toHaveText('Partner tillagd: Kim')
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()
// The regression this guards: finishing the wizard flips
// WorkspaceContext's `children` from empty to non-empty, which
// re-renders this SAME Dashboard mount straight past the onboarding
// branch — there is no `navigate()` call in between. A previously
// fetched, now-stale members list used to leave the partner showing as
// the generic "Förälder N" fallback until a manual navigation away and
// back refetched it (see Dashboard.tsx's `wasAwaitingFirstChildRef`
// effect, and `nameResolver`/`parentDisplayName`). Asserting
// immediately — no reload, no extra navigation — is what would have
// caught that.
await expect(page.getByTestId('dashboard')).toBeVisible({ timeout: 15_000 })
const age4Bars = page.getByTestId('age4-bars')
await expect(age4Bars).toBeVisible()
await expect(age4Bars).toContainText('Kim')
await expect(age4Bars).not.toContainText('Förälder')
})
})