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) <noreply@anthropic.com>
This commit is contained in:
yuneng-jiang 2026-03-23 22:26:37 -07:00
parent 1c611c4d6b
commit c397bc83fc
2 changed files with 7 additions and 32 deletions

View file

@ -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: () => [

View file

@ -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<PipelineTestPanelProps> = ({
const [error, setError] = useState<string | null>(null);
const [complianceResults, setComplianceResults] = useState<ComplianceRunEntry[]>([]);
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;