mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-11-08 20:33:41 +00:00
Co-authored-by: alejandrobailo <alejandrobailo94@gmail.com>
84 lines
2.5 KiB
TypeScript
84 lines
2.5 KiB
TypeScript
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(
|
|
<ExploitabilityChart
|
|
counts={{
|
|
exploitable: 0,
|
|
likely: 3,
|
|
conditional: 4,
|
|
not_exploitable: 4,
|
|
unknown: 1,
|
|
}}
|
|
issues={12}
|
|
findings={37}
|
|
actionable={3}
|
|
coveredFindings={0}
|
|
scope={{ "filter[provider_type__in]": "aws" }}
|
|
/>,
|
|
);
|
|
|
|
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(
|
|
<ExploitabilityChart
|
|
counts={{
|
|
exploitable: 1,
|
|
likely: 2,
|
|
conditional: 0,
|
|
not_exploitable: 4,
|
|
unknown: 1,
|
|
}}
|
|
issues={8}
|
|
findings={30}
|
|
actionable={3}
|
|
coveredFindings={9}
|
|
scope={{}}
|
|
/>,
|
|
);
|
|
|
|
// 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",
|
|
);
|
|
});
|
|
});
|