/** * Shared test fixtures — the FK scraper session lifecycle * (`startScraperSession` / `pollScraperSession`, and the `useScraperFetch` * hook that polls it). * * `pollScraperSession`'s declared return type is `Promise` (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> export function makeScraperSessionStartResponse( overrides: Partial = {}, ): 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 { 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 { return { total_days: 240, days_left: 140, sjukpenning_left: 100, lagsta_niva_left: 40, dubbeldagar_left: 20, ...overrides, } } export function makePartnerDeduction(overrides: Partial = {}): PartnerDeduction { return { totalDays: 240, daysLeft: 140, sjukpenningLeft: 100, lagstaNivaLeft: 40, dubbeldagarLeft: 20, ...overrides, } }