fix(ui): allow selecting failed scans when graph data is available (#10531)

This commit is contained in:
Josema Camacho
2026-04-01 11:08:34 +02:00
committed by GitHub
parent 4f86667433
commit dfe06a1077
3 changed files with 43 additions and 6 deletions
@@ -162,4 +162,45 @@ describe("ScanListTable", () => {
"/attack-paths?scanPage=1&scanPageSize=5&scanId=scan-1",
);
});
it("enables the select button for a failed scan when graph data is ready", async () => {
const user = userEvent.setup();
const failedScan: AttackPathScan = {
...createScan(1),
attributes: {
...createScan(1).attributes,
state: "failed",
graph_data_ready: true,
},
};
render(<ScanListTable scans={[failedScan]} />);
const button = screen.getByRole("button", { name: "Select scan" });
expect(button).toBeEnabled();
expect(button).toHaveTextContent("Select");
await user.click(button);
expect(pushMock).toHaveBeenCalledWith(
"/attack-paths?scanPage=1&scanPageSize=5&scanId=scan-1",
);
});
it("disables the select button for a failed scan when graph data is not ready", () => {
const failedScan: AttackPathScan = {
...createScan(1),
attributes: {
...createScan(1).attributes,
state: "failed",
graph_data_ready: false,
},
};
render(<ScanListTable scans={[failedScan]} />);
const button = screen.getByRole("button", { name: "Select scan" });
expect(button).toBeDisabled();
expect(button).toHaveTextContent("Failed");
});
});
@@ -42,11 +42,7 @@ const isSelectDisabled = (
scan: AttackPathScan,
selectedScanId: string | null,
) => {
return (
!scan.attributes.graph_data_ready ||
scan.attributes.state === SCAN_STATES.FAILED ||
selectedScanId === scan.id
);
return !scan.attributes.graph_data_ready || selectedScanId === scan.id;
};
const getSelectButtonLabel = (
@@ -38,7 +38,7 @@ const BADGE_CONFIG: Record<
[SCAN_STATES.FAILED]: {
className: "bg-bg-fail-secondary text-text-error-primary",
label: "Failed",
showGraphDot: false,
showGraphDot: true,
},
};