mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-16 23:41:43 +00:00
test(ui): hoist not_run guardrail fixtures out of inline call args
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
e41faf54a8
commit
b1a006ea66
1 changed files with 22 additions and 24 deletions
|
|
@ -3,6 +3,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
|
|||
import userEvent from "@testing-library/user-event";
|
||||
import { renderWithProviders, screen, waitFor } from "../../../../tests/test-utils";
|
||||
import {
|
||||
GuardrailInformation,
|
||||
makeBedrockResponse,
|
||||
makeEntity,
|
||||
makeGuardrailInformation,
|
||||
|
|
@ -14,6 +15,24 @@ import GuardrailViewer from "@/components/view_logs/GuardrailViewer/GuardrailVie
|
|||
const PresidioPath = "@/components/view_logs/GuardrailViewer/PresidioDetectedEntities";
|
||||
const BedrockPath = "@/components/view_logs/GuardrailViewer/BedrockGuardrailDetails";
|
||||
|
||||
const skippedPreCall: Partial<GuardrailInformation> = {
|
||||
guardrail_status: "not_run",
|
||||
guardrail_mode: "pre_call",
|
||||
guardrail_response: "no scannable content after message scoping",
|
||||
start_time: null,
|
||||
end_time: null,
|
||||
duration: null,
|
||||
};
|
||||
|
||||
const ranPostCall: Partial<GuardrailInformation> = {
|
||||
guardrail_name: "ran-rail",
|
||||
guardrail_status: "success",
|
||||
guardrail_mode: "post_call",
|
||||
start_time: 1_700_000_000,
|
||||
end_time: 1_700_000_000.25,
|
||||
duration: 0.25,
|
||||
};
|
||||
|
||||
describe("GuardrailViewer", () => {
|
||||
beforeEach(() => {
|
||||
vi.resetModules();
|
||||
|
|
@ -51,14 +70,7 @@ describe("GuardrailViewer", () => {
|
|||
|
||||
it("renders not_run as NOT RUN (muted) and keeps it out of the evaluated and passed counts", async () => {
|
||||
const user = userEvent.setup();
|
||||
const data = makeGuardrailInformation({
|
||||
guardrail_status: "not_run",
|
||||
guardrail_mode: "pre_call",
|
||||
guardrail_response: "no scannable content after message scoping",
|
||||
start_time: null,
|
||||
end_time: null,
|
||||
duration: null,
|
||||
});
|
||||
const data = makeGuardrailInformation(skippedPreCall);
|
||||
renderWithProviders(<GuardrailViewer data={data} />);
|
||||
|
||||
expect(screen.getByText(/0 guardrails evaluated/)).toBeInTheDocument();
|
||||
|
|
@ -74,22 +86,8 @@ describe("GuardrailViewer", () => {
|
|||
});
|
||||
|
||||
it("anchors the lifecycle timeline on timed entries when an untimed not_run entry sorts first", () => {
|
||||
const skipped = makeGuardrailInformation({
|
||||
guardrail_name: "skipped-rail",
|
||||
guardrail_status: "not_run",
|
||||
guardrail_mode: "pre_call",
|
||||
start_time: null,
|
||||
end_time: null,
|
||||
duration: null,
|
||||
});
|
||||
const ran = makeGuardrailInformation({
|
||||
guardrail_name: "ran-rail",
|
||||
guardrail_status: "success",
|
||||
guardrail_mode: "post_call",
|
||||
start_time: 1_700_000_000,
|
||||
end_time: 1_700_000_000.25,
|
||||
duration: 0.25,
|
||||
});
|
||||
const skipped = makeGuardrailInformation({ ...skippedPreCall, guardrail_name: "skipped-rail" });
|
||||
const ran = makeGuardrailInformation(ranPostCall);
|
||||
renderWithProviders(<GuardrailViewer data={[skipped, ran]} />);
|
||||
|
||||
expect(screen.getByText(/1 guardrail evaluated/)).toBeInTheDocument();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue