// Build a real `ApiContext` for an integration test.
//
// `ContextForActiveAccount()` / `ContextForAccount(id)` from `api-context.ts`
// already do exactly what we want — read the registry, read the token, hand
// back an `ApiContext`. This module is a thin convenience that pairs the
// builder with `seedAccountFromRig` so the typical "seed + build context"
// boilerplate collapses to one call.
//
// The point of this tier is to exercise the *real* request path, so we use
// the production `ApiContext` class as-is. Node 18+ has global `fetch`;
// jest-expo's Node test environment exposes it.

import { ContextForAccount } from 'src/lib/api-context'
import type { RigAccount } from '../../_helpers/loadTestRig'
import { seedAccountFromRig } from './seedAccount'

/** Seed the rig entry and return a real `ApiContext` for it. */
export function buildLiveContext(entry: RigAccount) {
  const summary = seedAccountFromRig(entry)
  return ContextForAccount(summary.accountId)
}
