Files
F-r-ldraledigplannerare/frontend/tests/fixtures/scraper.ts
T
jacobh2 ae6db7e16f Redesign the setup flow and consolidate the CSS into one primitives layer
Onboarding asks explicitly for one or two parents and shows one card per
parent for balances; the balance form is per parent with inline
validation; the partner can be filled from the FK deduction or added
from it. Settings and Dashboard reuse the same form.

CSS: bare buttons carry no colour any more; buttons, cards, choice
cards, fields, alerts, badges, eyebrow and modal chrome are defined once
in primitives.css. Media queries live only in responsive.css. A style
guard test blocks hex, !important and stray media queries. Bilingual
fixes: calendar selects size by content, header no longer wraps. Vitest
is capped at four workers.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-19 12:27:29 +02:00

66 lines
2.2 KiB
TypeScript

/**
* Shared test fixtures — the FK scraper session lifecycle
* (`startScraperSession` / `pollScraperSession`, and the `useScraperFetch`
* hook that polls it).
*
* `pollScraperSession`'s declared return type is `Promise<unknown>` (the
* hook casts it internally), so there is nothing to derive a poll-response
* type from at the API layer. `PollResponse` is exported from
* `useScraperFetch.ts` for exactly this reason — see the comment there.
*/
import type { startScraperSession } from '@/services/api'
import type { PollResponse, RawPartnerDeduction } from '@/hooks/useScraperFetch'
import type { PartnerDeduction } from '@/types'
export type ScraperSessionStartResponse = Awaited<ReturnType<typeof startScraperSession>>
export function makeScraperSessionStartResponse(
overrides: Partial<ScraperSessionStartResponse> = {},
): ScraperSessionStartResponse {
return {
session_id: 'sess-123',
status: 'launching',
workspace_id: 'ws-1',
personal_data_uuid: 'pd-a',
child_id: 'child-1',
...overrides,
}
}
/** One factory taking the `status` discriminant, rather than one factory per
* variant — `PollResponse` isn't a discriminated union in the type system
* (every field besides `status` is optional regardless of status), and every
* real call site only varies `status` plus one or two of the optional
* fields. */
export function makePollResponse(overrides: Partial<PollResponse> = {}): PollResponse {
return { status: 'launching', ...overrides }
}
/** Raw (snake_case) wire shape of `partner_deduction`, as it arrives nested
* inside a poll response — pair with `makePartnerDeduction` for the
* camelCase value `useScraperFetch` derives from it. */
export function makeRawPartnerDeduction(
overrides: Partial<RawPartnerDeduction> = {},
): RawPartnerDeduction {
return {
total_days: 240,
days_left: 140,
sjukpenning_left: 100,
lagsta_niva_left: 40,
dubbeldagar_left: 20,
...overrides,
}
}
export function makePartnerDeduction(overrides: Partial<PartnerDeduction> = {}): PartnerDeduction {
return {
totalDays: 240,
daysLeft: 140,
sjukpenningLeft: 100,
lagstaNivaLeft: 40,
dubbeldagarLeft: 20,
...overrides,
}
}