import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { ExploitabilityChart } from "./exploitability-chart";
describe("ExploitabilityChart", () => {
it("leads with exploitable + likely and links each verdict into the list", () => {
render(
,
);
expect(screen.getByText("12 issues")).toBeInTheDocument();
expect(
screen.getByRole("link", { name: "3 exploitable or likely issues" }),
).toHaveAttribute(
"href",
"/issues?filter%5Bprovider_type__in%5D=aws&filter%5Bverdict__in%5D=exploitable%2Clikely",
);
expect(screen.getByText("0 exploitable ยท 3 likely")).toBeInTheDocument();
expect(
screen.getByRole("link", { name: "4 not exploitable issues" }),
).toHaveAttribute(
"href",
"/issues?filter%5Bprovider_type__in%5D=aws&filter%5Bverdict%5D=not_exploitable",
);
expect(
screen.getByRole("link", { name: "4 conditional issues" }),
).toHaveAttribute(
"href",
"/issues?filter%5Bprovider_type__in%5D=aws&filter%5Bverdict%5D=conditional",
);
expect(
screen.getByText("37 failed findings folded into 12 issues"),
).toBeInTheDocument();
});
it("draws each verdict's share and names the findings a control covers", () => {
render(
,
);
// Sized by share, so the bar reads the same whatever the estate's size.
expect(screen.getByTitle("4 not exploitable")).toHaveStyle({
width: "50%",
});
expect(screen.getByTitle("1 exploitable")).toHaveAttribute(
"href",
"/issues?filter%5Bverdict%5D=exploitable",
);
// A verdict with no issues gets no segment.
expect(screen.queryByTitle("0 conditional")).not.toBeInTheDocument();
expect(screen.getByRole("link", { name: "9 findings" })).toHaveAttribute(
"href",
"/issues?filter%5Bverdict%5D=not_exploitable",
);
});
});