mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 12:31:54 +00:00
fix(ui): avoid launch scan to be triggered when no correct provider config available
This commit is contained in:
@@ -329,6 +329,51 @@ describe("ScansPageShell", () => {
|
||||
expect(screen.getByRole("dialog")).toHaveTextContent(/launch scan/i);
|
||||
});
|
||||
|
||||
it("does not open the launch scan modal from the URL when no provider is connected", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
searchParamsValue.current = "launchScan=true";
|
||||
|
||||
render(
|
||||
<ScansPageShell
|
||||
providers={disconnectedProviders}
|
||||
hasManageScansPermission
|
||||
>
|
||||
<div>Scans table</div>
|
||||
</ScansPageShell>,
|
||||
);
|
||||
|
||||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("does not open the launch scan modal from client state when no provider is connected", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
useScansStore.getState().openLaunchScanModal();
|
||||
|
||||
render(
|
||||
<ScansPageShell
|
||||
providers={disconnectedProviders}
|
||||
hasManageScansPermission
|
||||
>
|
||||
<div>Scans table</div>
|
||||
</ScansPageShell>,
|
||||
);
|
||||
|
||||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("does not open the launch scan modal from the URL without manage scans permission", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
searchParamsValue.current = "launchScan=true";
|
||||
|
||||
render(
|
||||
<ScansPageShell providers={providers} hasManageScansPermission={false}>
|
||||
<div>Scans table</div>
|
||||
</ScansPageShell>,
|
||||
);
|
||||
|
||||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("strips the launchScan URL param via the History API when closing the URL-opened modal", async () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
searchParamsValue.current = "tab=completed&launchScan=true";
|
||||
|
||||
@@ -75,7 +75,8 @@ export function ScansPageShell({
|
||||
const showProvidersHint = thereAreNoProviders || !hasConnectedProviders;
|
||||
const isCloudEnvironment = isCloud();
|
||||
const launchDisabled = !hasManageScansPermission || !hasConnectedProviders;
|
||||
const launchOpen = isLaunchScanModalOpen || urlLaunchOpen;
|
||||
const launchOpen =
|
||||
!launchDisabled && (isLaunchScanModalOpen || urlLaunchOpen);
|
||||
// When a scan is already running, the tour highlights its row (anchored in
|
||||
// ScanJobsTable); otherwise it falls back to the Launch Scan button + tabs.
|
||||
const hasInProgressScan = activeScanCount > 0;
|
||||
|
||||
Reference in New Issue
Block a user