Skip to content

The platform for continuously improving AI agents.

1.7 KB
Raw Blame
// @vitest-environment jsdom
// covers: console-logic
import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, expect, it } from "vitest";

import { type ComparisonEvidence, ComparisonReport } from "./comparison-report";

afterEach(cleanup);
const evidence: ComparisonEvidence = {
  baseline: 0.82,
  coverage: { candidates: 2, complete: true, measured: 2 },
  data: "cohort",
  delta: 0.022,
  direction: "maximize",
  fingerprint: "fingerprint",
  metric: "/report/accuracy",
  outcome: "candidate_selected",
  phase: "development",
  policy: {},
  protocol: "protocol",
  reports: [
    { baseline: true, eligible: true, input: {}, reason: "", value: 0.82 },
    { baseline: false, eligible: true, input: {}, reason: "", value: 0.842 },
  ],
  selected: { baseline: false, eligible: true, input: {}, reason: "", value: 0.842 },
};
it("shows percentage-point improvement without a relative-percent claim", () => {
  render(<ComparisonReport evidence={evidence} />);
  expect(screen.getAllByText("84.2%").length).toBeGreaterThan(0);
  expect(screen.getByText("+2.2 pp")).toBeTruthy();
  expect(screen.getByText(/Baseline 82.0%/)).toBeTruthy();
});
it("withholds a headline winner for incomplete evidence while preserving measured bars", () => {
  render(
    <ComparisonReport
      evidence={{
        ...evidence,
        coverage: { candidates: 2, complete: false, measured: 2 },
        outcome: "insufficient_evidence",
        selected: null,
      }}
    />
  );
  expect(screen.getByText("Insufficient comparable evidence")).toBeTruthy();
  expect(screen.queryByText("+2.2 pp")).toBeNull();
  expect(screen.getByRole("button", { name: "Candidate 2: 84.2%" })).toBeTruthy();
});