mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-14 10:52:17 +03:00
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host. Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean. Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
|
|
const root = join(import.meta.dirname, "../..");
|
|
const llmChatCardPath =
|
|
"src/app/(dashboard)/dashboard/media-providers/components/LlmChatCard.tsx";
|
|
const src = readFileSync(join(root, llmChatCardPath), "utf8");
|
|
|
|
const DISABLED_ON_LOADING = /disabled\s*=\s*\{\s*loading\s*\}/;
|
|
const MODELS_LOADING_MARKER = /modelsLoading|Loading…|Loading\.\.\./;
|
|
const ERROR_BRANCH = /error\s*&&/;
|
|
const RETRY_ACTION = /onClick\s*=\s*\{[^}]*retry|retry[A-Za-z]*\s*\(\)|const\s+\[reload/i;
|
|
const NO_MODELS_AFTER_EMPTY = /modelOptions\.length\s*===?\s*0|models\.length\s*===?\s*0/;
|
|
|
|
test("LlmChatCard destructures loading and error from useProviderModels (#9626)", () => {
|
|
const match = src.match(/const\s*\{\s*([^}]+)\s*\}\s*=\s*useProviderModels\(/);
|
|
assert.ok(match, "Expected to find a destructuring of useProviderModels");
|
|
|
|
const destructured = match[1];
|
|
assert.ok(
|
|
destructured.includes("loading"),
|
|
"loading state must be destructured from useProviderModels"
|
|
);
|
|
assert.ok(destructured.includes("error"), "error state must be destructured from useProviderModels");
|
|
});
|
|
|
|
test("LlmChatCard disables the model selector while models are loading (#9626)", () => {
|
|
assert.ok(
|
|
DISABLED_ON_LOADING.test(src),
|
|
"The model <select> must be disabled while the models request is pending"
|
|
);
|
|
});
|
|
|
|
test("LlmChatCard shows a visible loading label while models are pending (#9626)", () => {
|
|
assert.ok(
|
|
MODELS_LOADING_MARKER.test(src),
|
|
"A visible loading text (e.g. 'Loading…') must appear while the models request is pending"
|
|
);
|
|
});
|
|
|
|
test("LlmChatCard surfaces the provider model error in the UI (#9626)", () => {
|
|
assert.ok(
|
|
ERROR_BRANCH.test(src),
|
|
"An error branch that renders the captured error message must exist"
|
|
);
|
|
});
|
|
|
|
test("LlmChatCard offers a retry action when the model request fails (#9626)", () => {
|
|
assert.ok(
|
|
RETRY_ACTION.test(src),
|
|
"A retry action must be offered next to the model error"
|
|
);
|
|
});
|
|
|
|
test("LlmChatCard keeps the empty-state message distinct from an error (#9626)", () => {
|
|
assert.ok(
|
|
NO_MODELS_AFTER_EMPTY.test(src),
|
|
"The empty-state (no models) message must only be shown for a successful empty response"
|
|
);
|
|
});
|