{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import { createElement, type ReactElement } from \"react\";\nimport { invokeAPIRouteEndpoint, matchAPIRoute, type APIRouteParams } from \"./api/route-manager\";\nimport { getFarmDataCache } from \"./cache\";\nimport { resolveFarmRouteContext, withFarmRouteContext } from \"./route-context\";\nimport {\n  createRouteModuleFromProgrammaticPage,\n  type InferProgrammaticRouteData,\n  type ProgrammaticApiRoute,\n  type ProgrammaticPageRoute,\n  type ProgrammaticRouteComponentProps,\n  type ProgrammaticRouteMethod,\n} from \"./routes\";\nimport {\n  buildFarmRoutePath,\n  matchFarmRoute,\n  type FarmRouterPathParams,\n  type FarmRouterQueryValue,\n} from \"./router\";\nimport { runWithServerActionRequest } from \"./server-action-security\";\nimport type { ServerFn } from \"./server-fn\";\nimport { searchParamsToObject } from \"./search-params\";\nimport type { FarmContextFactory, MiddlewareProps, PluginContextProps, RouteModule } from \"./types\";\n\nexport type FarmTestQuery = URLSearchParams | Record<string, FarmRouterQueryValue>;\nexport type FarmTestPathParams = FarmRouterPathParams;\nexport type FarmTestFormValues = Record<string, FormDataEntryValue | readonly FormDataEntryValue[]>;\n\nexport interface FarmTestRequestOptions extends Omit<RequestInit, \"body\" | \"headers\"> {\n  origin?: string;\n  headers?: HeadersInit;\n  query?: FarmTestQuery;\n  cookies?: Record<string, string>;\n  json?: unknown;\n  form?: FormData | FarmTestFormValues;\n  body?: BodyInit | null;\n}\n\nexport interface FarmTestHarnessOptions<TContext = unknown> {\n  origin?: string;\n  headers?: HeadersInit;\n  cookies?: Record<string, string>;\n  context?: FarmContextFactory<TContext>;\n}\n\ntype AnyProgrammaticPageRoute = ProgrammaticPageRoute<any, any, any, any>;\n\nexport type InferFarmTestRouteParams<TRoute> =\n  TRoute extends ProgrammaticPageRoute<infer TParams, any, any, any> ? TParams : never;\n\nexport type InferFarmTestRouteSearch<TRoute> =\n  TRoute extends ProgrammaticPageRoute<any, infer TSearch, any, any> ? TSearch : never;\n\nexport type InferFarmTestRouteData<TRoute> =\n  TRoute extends ProgrammaticPageRoute<any, any, infer TDataHooks, any>\n    ? InferProgrammaticRouteData<TDataHooks>\n    : never;\n\nexport type FarmTestRouteProps<TRoute extends AnyProgrammaticPageRoute> =\n  ProgrammaticRouteComponentProps<\n    InferFarmTestRouteParams<TRoute>,\n    InferFarmTestRouteSearch<TRoute>,\n    InferFarmTestRouteData<TRoute>\n  >;\n\ntype FarmTestRouteParamsInput<TRoute> =\n  InferFarmTestRouteParams<TRoute> extends Record<string, unknown>\n    ? Partial<InferFarmTestRouteParams<TRoute>>\n    : FarmTestPathParams;\n\ntype FarmTestRouteSearchInput<TRoute> =\n  InferFarmTestRouteSearch<TRoute> extends Record<string, unknown>\n    ? Partial<InferFarmTestRouteSearch<TRoute>> | URLSearchParams\n    : FarmTestQuery;\n\nexport interface FarmTestRouteOptions<\n  TRoute extends AnyProgrammaticPageRoute,\n  TContext = unknown,\n> extends Pick<FarmTestRequestOptions, \"origin\" | \"headers\" | \"cookies\" | \"signal\"> {\n  path?: string | URL;\n  params?: FarmTestRouteParamsInput<TRoute>;\n  search?: FarmTestRouteSearchInput<TRoute>;\n  context?: TContext;\n  middleware?: MiddlewareProps;\n  pluginContext?: PluginContextProps;\n}\n\nexport interface FarmTestRouteResult<TRoute extends AnyProgrammaticPageRoute> {\n  route: TRoute;\n  module: RouteModule;\n  request: Request;\n  props: FarmTestRouteProps<TRoute>;\n  element: ReactElement;\n  canonicalPath?: string;\n}\n\nexport interface FarmTestApiOptions extends FarmTestRequestOptions {\n  path?: string | URL;\n  params?: FarmTestPathParams;\n  throwOnError?: boolean;\n}\n\nexport interface FarmTestEndpointOptions extends FarmTestRequestOptions {\n  path?: string | URL;\n  params?: APIRouteParams;\n  throwOnError?: boolean;\n}\n\nexport interface FarmTestServerFnOptions extends Pick<\n  FarmTestRequestOptions,\n  \"origin\" | \"headers\" | \"cookies\" | \"signal\"\n> {\n  path?: string | URL;\n  request?: Request;\n}\n\nexport type FarmTestServerFnArguments<TInput> = [unknown] extends [TInput]\n  ? [input?: TInput | FormData, options?: FarmTestServerFnOptions]\n  : [input: TInput | FormData, options?: FarmTestServerFnOptions];\n\nexport interface FarmTestHarness<TContext = unknown> {\n  request(path?: string | URL, options?: FarmTestRequestOptions): Request;\n  route<TRoute extends AnyProgrammaticPageRoute>(\n    route: TRoute,\n    options?: FarmTestRouteOptions<TRoute, TContext>,\n  ): Promise<FarmTestRouteResult<TRoute>>;\n  api(route: ProgrammaticApiRoute, options?: FarmTestApiOptions): Promise<Response>;\n  endpoint(endpoint: unknown, options?: FarmTestEndpointOptions): Promise<Response>;\n  serverFn<TInput, TResult>(\n    serverFn: ServerFn<TInput, TResult>,\n    ...args: FarmTestServerFnArguments<TInput>\n  ): Promise<TResult>;\n  clearCache(): void;\n}\n\n/** Create a deterministic Web Request without depending on a test runner. */\nexport function createTestRequest(\n  path: string | URL = \"/\",\n  options: FarmTestRequestOptions = {},\n): Request {\n  const url = resolveTestURL(path, options.origin);\n  applyQuery(url.searchParams, options.query);\n\n  const headers = new Headers(options.headers);\n  applyCookies(headers, options.cookies);\n  const { body, hasBody } = resolveRequestBody(options, headers);\n  const method = (options.method ?? (hasBody ? \"POST\" : \"GET\")).toUpperCase();\n\n  if ((method === \"GET\" || method === \"HEAD\") && body != null) {\n    throw new TypeError(`Farm test requests cannot send a body with ${method}`);\n  }\n\n  const {\n    origin: _origin,\n    query: _query,\n    cookies: _cookies,\n    json: _json,\n    form: _form,\n    body: _body,\n    headers: _headers,\n    ...requestInit\n  } = options;\n\n  return new Request(url, {\n    ...requestInit,\n    method,\n    headers,\n    body,\n  });\n}\n\n/**\n * Create test helpers that exercise Farm's real route, API, and server-function runtimes.\n * The harness has no dependency on Vitest, Jest, or a DOM environment.\n */\nexport function createFarmTestHarness<TContext = unknown>(\n  options: FarmTestHarnessOptions<TContext> = {},\n): FarmTestHarness<TContext> {\n  const origin = normalizeOrigin(options.origin);\n\n  const request = (path: string | URL = \"/\", requestOptions: FarmTestRequestOptions = {}) =>\n    createTestRequest(path, mergeRequestDefaults(options, origin, requestOptions));\n\n  return {\n    request,\n\n    async route<TRoute extends AnyProgrammaticPageRoute>(\n      route: TRoute,\n      routeOptions: FarmTestRouteOptions<TRoute, TContext> = {},\n    ): Promise<FarmTestRouteResult<TRoute>> {\n      const requestPath =\n        routeOptions.path ??\n        buildFarmRoutePath(route.path, (routeOptions.params ?? {}) as FarmRouterPathParams);\n      const routeRequest = request(requestPath, {\n        origin: routeOptions.origin,\n        headers: routeOptions.headers,\n        cookies: routeOptions.cookies,\n        signal: routeOptions.signal,\n        query: routeOptions.search as FarmTestQuery | undefined,\n      });\n      const url = new URL(routeRequest.url);\n      const params = resolvePageParams(route.path, url.pathname, routeOptions.params);\n      const search = searchParamsToObject(url.searchParams);\n      const routeContext = Object.prototype.hasOwnProperty.call(routeOptions, \"context\")\n        ? routeOptions.context\n        : await resolveFarmRouteContext(\n            { context: options.context },\n            {\n              request: routeRequest,\n              params,\n              search,\n              path: url.pathname,\n            },\n          );\n      const rawProps = withFarmRouteContext(\n        {\n          params,\n          searchParams: Promise.resolve(search),\n          path: url.pathname,\n          middleware: routeOptions.middleware,\n          context: routeOptions.pluginContext,\n        },\n        routeContext,\n      );\n      const routeModule = createRouteModuleFromProgrammaticPage(route);\n      const resolveProps = (\n        routeModule as RouteModule & {\n          __farmResolveRouteProps?: (props: typeof rawProps) => Promise<Record<string, unknown>>;\n        }\n      ).__farmResolveRouteProps;\n      const resolvedProps = resolveProps\n        ? await resolveProps(rawProps)\n        : { ...rawProps, search, searchParams: Promise.resolve(search) };\n      const canonicalPath = readCanonicalPath(resolvedProps);\n      const componentProps = stripInternalRouteProps(resolvedProps) as FarmTestRouteProps<TRoute>;\n\n      return {\n        route,\n        module: routeModule,\n        request: routeRequest,\n        props: componentProps,\n        element: createElement(route.component, componentProps),\n        canonicalPath,\n      };\n    },\n\n    async api(route, apiOptions = {}) {\n      const requestPath =\n        apiOptions.path ?? buildFarmRoutePath(route.path, apiOptions.params ?? {});\n      const method = apiOptions.method ?? getDefaultApiMethod(route);\n      const apiRequest = request(requestPath, omitApiControlOptions({ ...apiOptions, method }));\n      const match = matchAPIRoute(new Map([[route.path, route]]), new URL(apiRequest.url).pathname);\n\n      if (!match) {\n        return jsonErrorResponse(\"Not Found\", 404);\n      }\n\n      const endpoint = match.route.methods[apiRequest.method as ProgrammaticRouteMethod];\n      if (!endpoint) {\n        return jsonErrorResponse(\"Method Not Allowed\", 405);\n      }\n\n      return invokeTestEndpoint(endpoint, apiRequest, match.params, apiOptions.throwOnError);\n    },\n\n    async endpoint(endpoint, endpointOptions = {}) {\n      const endpointRecord = endpoint as { __method?: string; __path?: string };\n      const endpointPath = endpointOptions.path ?? endpointRecord.__path ?? \"/__farm/test/endpoint\";\n      const endpointRequest = request(endpointPath, {\n        ...omitEndpointControlOptions(endpointOptions),\n        method: endpointOptions.method ?? endpointRecord.__method ?? \"GET\",\n      });\n\n      return invokeTestEndpoint(\n        endpoint,\n        endpointRequest,\n        endpointOptions.params,\n        endpointOptions.throwOnError,\n      );\n    },\n\n    async serverFn<TInput, TResult>(\n      serverFn: ServerFn<TInput, TResult>,\n      ...args: FarmTestServerFnArguments<TInput>\n    ): Promise<TResult> {\n      const [input, serverFnOptions = {}] = args;\n      const actionRequest =\n        serverFnOptions.request ??\n        request(serverFnOptions.path ?? \"/__farm/test/server-fn\", {\n          origin: serverFnOptions.origin,\n          headers: serverFnOptions.headers,\n          cookies: serverFnOptions.cookies,\n          signal: serverFnOptions.signal,\n          method: \"POST\",\n        });\n\n      return await runWithServerActionRequest(actionRequest, () => serverFn(input as TInput));\n    },\n\n    clearCache() {\n      getFarmDataCache().clear();\n    },\n  };\n}\n\nfunction resolveTestURL(path: string | URL, origin: string | undefined): URL {\n  const url = path instanceof URL ? new URL(path) : new URL(path, `${normalizeOrigin(origin)}/`);\n  if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n    throw new TypeError(`Farm test requests require an HTTP(S) URL, received ${url.protocol}`);\n  }\n  return url;\n}\n\nfunction normalizeOrigin(origin = \"http://farm.test\"): string {\n  let url: URL;\n  try {\n    url = new URL(origin);\n  } catch {\n    throw new TypeError(`Invalid Farm test origin: ${JSON.stringify(origin)}`);\n  }\n\n  if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n    throw new TypeError(`Farm test origins must use HTTP(S), received ${url.protocol}`);\n  }\n\n  return url.origin;\n}\n\nfunction mergeRequestDefaults<TContext>(\n  harnessOptions: FarmTestHarnessOptions<TContext>,\n  origin: string,\n  requestOptions: FarmTestRequestOptions,\n): FarmTestRequestOptions {\n  const headers = new Headers(harnessOptions.headers);\n  new Headers(requestOptions.headers).forEach((value, key) => headers.set(key, value));\n\n  return {\n    ...requestOptions,\n    origin: requestOptions.origin ?? origin,\n    headers,\n    cookies: {\n      ...harnessOptions.cookies,\n      ...requestOptions.cookies,\n    },\n  };\n}\n\nfunction applyQuery(searchParams: URLSearchParams, query: FarmTestQuery | undefined): void {\n  if (!query) return;\n\n  if (query instanceof URLSearchParams) {\n    for (const key of new Set(query.keys())) {\n      searchParams.delete(key);\n      for (const value of query.getAll(key)) searchParams.append(key, value);\n    }\n    return;\n  }\n\n  for (const [key, rawValue] of Object.entries(query)) {\n    searchParams.delete(key);\n    const values = Array.isArray(rawValue) ? rawValue : [rawValue];\n    for (const value of values) {\n      if (value == null) continue;\n      if (typeof value !== \"string\" && typeof value !== \"number\" && typeof value !== \"boolean\") {\n        throw new TypeError(`Invalid query value for ${JSON.stringify(key)}`);\n      }\n      searchParams.append(key, String(value));\n    }\n  }\n}\n\nfunction applyCookies(headers: Headers, cookies: Record<string, string> | undefined): void {\n  if (!cookies || Object.keys(cookies).length === 0) return;\n\n  const value = Object.entries(cookies)\n    .map(([name, cookieValue]) => `${encodeURIComponent(name)}=${encodeURIComponent(cookieValue)}`)\n    .join(\"; \");\n  const current = headers.get(\"cookie\");\n  headers.set(\"cookie\", current ? `${current}; ${value}` : value);\n}\n\nfunction resolveRequestBody(\n  options: FarmTestRequestOptions,\n  headers: Headers,\n): { body: BodyInit | null; hasBody: boolean } {\n  const sources = [\n    options.json !== undefined,\n    options.form !== undefined,\n    options.body !== undefined,\n  ];\n  if (sources.filter(Boolean).length > 1) {\n    throw new TypeError(\"Farm test requests accept only one of json, form, or body\");\n  }\n\n  if (options.json !== undefined) {\n    if (!headers.has(\"content-type\")) headers.set(\"content-type\", \"application/json\");\n    return { body: JSON.stringify(options.json), hasBody: true };\n  }\n\n  if (options.form !== undefined) {\n    const formData = options.form instanceof FormData ? options.form : createFormData(options.form);\n    return { body: formData, hasBody: true };\n  }\n\n  return {\n    body: options.body ?? null,\n    hasBody: options.body !== undefined,\n  };\n}\n\nfunction createFormData(values: FarmTestFormValues): FormData {\n  const formData = new FormData();\n  for (const [key, rawValue] of Object.entries(values)) {\n    const entries = Array.isArray(rawValue) ? rawValue : [rawValue];\n    for (const value of entries) formData.append(key, value);\n  }\n  return formData;\n}\n\nfunction resolvePageParams(\n  pattern: string,\n  pathname: string,\n  explicitParams: Record<string, unknown> | undefined,\n): Record<string, string> {\n  const matchedParams = matchFarmRoute(pattern, pathname);\n  if (!matchedParams) {\n    throw new Error(\n      `Path ${JSON.stringify(pathname)} does not match route ${JSON.stringify(pattern)}`,\n    );\n  }\n\n  if (!explicitParams) return matchedParams;\n\n  return Object.fromEntries(\n    Object.entries(explicitParams).map(([key, value]) => [\n      key,\n      Array.isArray(value) ? value.map(String).join(\"/\") : String(value),\n    ]),\n  );\n}\n\nfunction readCanonicalPath(props: Record<string, unknown>): string | undefined {\n  return typeof props.__farmCanonicalPath === \"string\" ? props.__farmCanonicalPath : undefined;\n}\n\nfunction stripInternalRouteProps(props: Record<string, unknown>): Record<string, unknown> {\n  const { __farmRoutePropsResolved, __farmCanonicalPath, ...componentProps } = props;\n  return componentProps;\n}\n\nfunction getDefaultApiMethod(route: ProgrammaticApiRoute): ProgrammaticRouteMethod {\n  if (route.methods.GET) return \"GET\";\n  return (Object.keys(route.methods)[0] as ProgrammaticRouteMethod | undefined) ?? \"GET\";\n}\n\nfunction omitApiControlOptions(options: FarmTestApiOptions): FarmTestRequestOptions {\n  const { path: _path, params: _params, throwOnError: _throwOnError, ...requestOptions } = options;\n  return requestOptions;\n}\n\nfunction omitEndpointControlOptions(options: FarmTestEndpointOptions): FarmTestRequestOptions {\n  const { path: _path, params: _params, throwOnError: _throwOnError, ...requestOptions } = options;\n  return requestOptions;\n}\n\nasync function invokeTestEndpoint(\n  endpoint: unknown,\n  request: Request,\n  params: APIRouteParams = {},\n  throwOnError = false,\n): Promise<Response> {\n  try {\n    return await invokeAPIRouteEndpoint(endpoint, request, params);\n  } catch (error) {\n    if (throwOnError) throw error;\n    return jsonErrorResponse(error instanceof Error ? error.message : \"Internal Server Error\", 500);\n  }\n}\n\nfunction jsonErrorResponse(error: string, status: number): Response {\n  return Response.json({ error }, { status });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAwC;AAuI1C,SAAS,kBACd,OAAqB,KACrB,UAAkC,CAAC,GAC1B;AACT,QAAM,MAAM,eAAe,MAAM,QAAQ,MAAM;AAC/C,aAAW,IAAI,cAAc,QAAQ,KAAK;AAE1C,QAAM,UAAU,IAAI,QAAQ,QAAQ,OAAO;AAC3C,eAAa,SAAS,QAAQ,OAAO;AACrC,QAAM,EAAE,MAAM,QAAQ,IAAI,mBAAmB,SAAS,OAAO;AAC7D,QAAM,UAAU,QAAQ,WAAW,UAAU,SAAS,QAAQ,YAAY;AAE1E,OAAK,WAAW,SAAS,WAAW,WAAW,QAAQ,MAAM;AAC3D,UAAM,IAAI,UAAU,8CAA8C,MAAM,EAAE;AAAA,EAC5E;AAEA,QAAM;AAAA,IACJ,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,SAAS;AAAA,IACT,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,GAAG;AAAA,EACL,IAAI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