From c5f7835a3a2e7a8499eed53f69995f71e9478efa Mon Sep 17 00:00:00 2001 From: Rehan Sanjay Date: Thu, 27 Aug 2026 12:55:24 +0530 Subject: [PATCH] test(ui): cover the third semantic-cache detection signal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CacheSettings opens the semantic section when any of three things is present in the saved config: redis_type === "semantic", similarity_threshold, or redis_semantic_cache_embedding_model. The first two had tests; the third did not. A config saved with only an embedding model set — no similarity_threshold, and redis_type left as a deployment topology rather than "semantic" — is the case that goes uncovered. If that clause were ever dropped, such a config would come back with the semantic section closed and the user would silently lose the model they had configured. Verified as a mutation test rather than assumed: deleting the redis_semantic_cache_embedding_model clause from index.tsx fails this test, and only this test (1 failed, 12 passed). With the clause present, 13 pass. Co-Authored-By: Claude Opus 5 --- .../_components/cache_settings/index.test.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_settings/index.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_settings/index.test.tsx index 7eac3dcfd1d..ac2ffd6533e 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_settings/index.test.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_settings/index.test.tsx @@ -78,6 +78,19 @@ describe("CacheSettings", () => { expect(screen.getByText("Embedding Model")).toBeInTheDocument(); }); + it("should reveal the semantic fields when redis_semantic_cache_embedding_model is present", async () => { + // The third signal the component detects on. A config saved with only an + // embedding model set — no similarity_threshold, and redis_type left as a + // deployment topology rather than "semantic" — must still come back with the + // semantic section open, or the user silently loses the model they configured. + getCacheSettingsCall.mockResolvedValue({ + current_values: { redis_semantic_cache_embedding_model: "text-embedding-3-small" }, + }); + renderSettings(); + expect(await screen.findByText("Similarity Threshold")).toBeInTheDocument(); + expect(screen.getByText("Embedding Model")).toBeInTheDocument(); + }); + it("should NOT reveal the semantic fields when similarity_threshold is null", async () => { getCacheSettingsCall.mockResolvedValue({ current_values: { similarity_threshold: null } }); renderSettings();