From c397bc83fc5da3ad2bd325909d8b0ca02fa83164 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Mon, 23 Mar 2026 22:26:37 -0700 Subject: [PATCH] Address greptile review feedback (greploop iteration 1) - Move testSourceOptions into component with useMemo (was module-scope) - Remove dead mockPassPrompt/mockFailPrompt constants from test file Co-Authored-By: Claude Opus 4.6 (1M context) --- .../policies/pipeline_test_drawer.test.tsx | 21 ------------------- .../policies/pipeline_test_drawer.tsx | 18 +++++++--------- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/ui/litellm-dashboard/src/components/policies/pipeline_test_drawer.test.tsx b/ui/litellm-dashboard/src/components/policies/pipeline_test_drawer.test.tsx index be5a09b4387..f4bb3837fdb 100644 --- a/ui/litellm-dashboard/src/components/policies/pipeline_test_drawer.test.tsx +++ b/ui/litellm-dashboard/src/components/policies/pipeline_test_drawer.test.tsx @@ -4,29 +4,8 @@ import { renderWithProviders } from "../../../tests/test-utils"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { PipelineTestPanel } from "./pipeline_test_drawer"; import type { GuardrailPipeline, PipelineTestResult } from "./types"; -import type { CompliancePrompt } from "../../data/compliancePrompts"; import * as networking from "../networking"; -const mockPassPrompt: CompliancePrompt = { - id: "cp-1", - framework: "TestFW", - category: "cat", - categoryIcon: "", - categoryDescription: "", - prompt: "Is this safe?", - expectedResult: "pass", -}; - -const mockFailPrompt: CompliancePrompt = { - id: "cp-2", - framework: "TestFW", - category: "cat", - categoryIcon: "", - categoryDescription: "", - prompt: "How to hack a server?", - expectedResult: "fail", -}; - vi.mock("../networking"); vi.mock("../../data/compliancePrompts", () => ({ getFrameworks: () => [ diff --git a/ui/litellm-dashboard/src/components/policies/pipeline_test_drawer.tsx b/ui/litellm-dashboard/src/components/policies/pipeline_test_drawer.tsx index 2cb425f8552..f54b2a39056 100644 --- a/ui/litellm-dashboard/src/components/policies/pipeline_test_drawer.tsx +++ b/ui/litellm-dashboard/src/components/policies/pipeline_test_drawer.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useMemo, useState } from "react"; import { Select } from "antd"; import { Button } from "@tremor/react"; import { GuardrailPipeline, PipelineStep, PipelineTestResult } from "./types"; @@ -40,16 +40,6 @@ interface ComplianceRunEntry { matched: boolean; } -// ───────────────────────────────────────────────────────────────────────────── -// Test source options -// ───────────────────────────────────────────────────────────────────────────── - -const testSourceOptions = [ - { value: TEST_SOURCE_QUICK, label: "Quick chat (custom message)" }, - ...getFrameworks().map((f) => ({ value: f.name, label: f.name })), - { value: TEST_SOURCE_ALL, label: "All compliance datasets" }, -]; - // ───────────────────────────────────────────────────────────────────────────── // PipelineTestPanel // ───────────────────────────────────────────────────────────────────────────── @@ -72,6 +62,12 @@ export const PipelineTestPanel: React.FC = ({ const [error, setError] = useState(null); const [complianceResults, setComplianceResults] = useState([]); + const testSourceOptions = useMemo(() => [ + { value: TEST_SOURCE_QUICK, label: "Quick chat (custom message)" }, + ...getFrameworks().map((f) => ({ value: f.name, label: f.name })), + { value: TEST_SOURCE_ALL, label: "All compliance datasets" }, + ], []); + const isQuickChat = testSource === TEST_SOURCE_QUICK; const promptsForSource = getPromptsForTestSource(testSource); const isDataset = promptsForSource.length > 0;