mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix(ui): read the preset catalog at runtime in the vitest mock
The autoRouterPresets mock imported litellm/proxy/public_endpoints/autorouter_presets.json as a module. That path sits outside ui/litellm-dashboard, the only directory the UI Dockerfile copies, so `next build` type-checking inside the image failed with "Cannot find module" and the ui-image job went red on every PR that touched an image-scan path. Read the file with fs at runtime instead; vitest still derives expectations from the real bundled catalog. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HqEPCNLDrssxsuezhAaL4j
This commit is contained in:
parent
bcd3e2d94d
commit
099d26204f
1 changed files with 11 additions and 3 deletions
|
|
@ -1,10 +1,18 @@
|
|||
import { readFileSync } from "fs";
|
||||
import { resolve } from "path";
|
||||
import { vi } from "vitest";
|
||||
import bundledPresets from "../../../../litellm/proxy/public_endpoints/autorouter_presets.json";
|
||||
import { hydratePresets, type AutoRouterPresetsResponse } from "@/lib/autorouter_presets";
|
||||
|
||||
// Derived from the real bundled catalog so a preset edit there flows into test expectations
|
||||
// instead of redding on a stale copy. Exported as vi.fn so a test can override the query state.
|
||||
export const BUNDLED_PRESETS = hydratePresets(bundledPresets as AutoRouterPresetsResponse);
|
||||
// instead of redding on a stale copy. Read at runtime rather than imported as a module: the
|
||||
// catalog lives outside ui/litellm-dashboard, so a module import fails `next build`'s type
|
||||
// check inside the UI Docker image, whose build context is only this package.
|
||||
// Exported as vi.fn so a test can override the query state.
|
||||
const CATALOG_PATH = resolve(process.cwd(), "../../litellm/proxy/public_endpoints/autorouter_presets.json");
|
||||
|
||||
export const BUNDLED_PRESETS = hydratePresets(
|
||||
JSON.parse(readFileSync(CATALOG_PATH, "utf8")) as AutoRouterPresetsResponse,
|
||||
);
|
||||
|
||||
export const LOADED_PRESETS_QUERY = {
|
||||
data: BUNDLED_PRESETS,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue