mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-31 07:44:21 +00:00
fix(ui): handle pending compliance overview responses (#12366)
Co-authored-by: Alejandro Bailo <59607668+alejandrobailo@users.noreply.github.com> Co-authored-by: alejandrobailo <alejandrobailo94@gmail.com>
This commit is contained in:
11 files changed
+628
-57
No files matched your search
+44
@@ -1174,6 +1174,7 @@ describe("ResourceDetailDrawerContent — CVE recommendation button", () => {
|
||||
describe("ResourceDetailDrawerContent — compliance navigation", () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("should resolve the clicked framework against the selected scan and navigate to compliance detail", async () => {
|
||||
@@ -1377,6 +1378,49 @@ describe("ResourceDetailDrawerContent — compliance navigation", () => {
|
||||
"noopener,noreferrer",
|
||||
);
|
||||
});
|
||||
|
||||
it("should not navigate while compliance data is being generated", async () => {
|
||||
// Given
|
||||
const user = userEvent.setup();
|
||||
const consoleErrorSpy = vi
|
||||
.spyOn(console, "error")
|
||||
.mockImplementation(() => undefined);
|
||||
vi.stubGlobal("open", mockWindowOpen);
|
||||
mockSearchParamsState.value = "filter[scan__in]=scan-selected";
|
||||
mockGetCompliancesOverview.mockResolvedValue({
|
||||
data: {
|
||||
id: "task-1",
|
||||
type: "tasks",
|
||||
attributes: { state: "executing" },
|
||||
},
|
||||
});
|
||||
|
||||
render(
|
||||
<ResourceDetailDrawerContent
|
||||
isLoading={false}
|
||||
isNavigating={false}
|
||||
checkMeta={mockCheckMeta}
|
||||
currentIndex={0}
|
||||
totalResources={1}
|
||||
currentFinding={mockFinding}
|
||||
otherFindings={[]}
|
||||
onNavigatePrev={vi.fn()}
|
||||
onNavigateNext={vi.fn()}
|
||||
onMuteComplete={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
// When
|
||||
await user.click(
|
||||
screen.getByRole("button", {
|
||||
name: "Open PCI-DSS compliance details",
|
||||
}),
|
||||
);
|
||||
|
||||
// Then
|
||||
expect(mockWindowOpen).not.toHaveBeenCalled();
|
||||
expect(consoleErrorSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("ResourceDetailDrawerContent — other findings mute refresh", () => {
|
||||
|
||||
+4
-4
@@ -510,10 +510,10 @@ export function ResourceDetailDrawerContent({
|
||||
const compliancesOverview = await getCompliancesOverview({
|
||||
scanId: complianceScanId,
|
||||
});
|
||||
const complianceMatch = resolveComplianceMatch(
|
||||
compliancesOverview?.data,
|
||||
framework,
|
||||
);
|
||||
const complianceData = Array.isArray(compliancesOverview?.data)
|
||||
? compliancesOverview.data
|
||||
: undefined;
|
||||
const complianceMatch = resolveComplianceMatch(complianceData, framework);
|
||||
|
||||
if (!complianceMatch) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user