fix(ui): avoid launch scan to be triggered when no correct provider config available

This commit is contained in:
Pablo F.G
2026-07-17 12:19:39 +02:00
parent f2f8bb1358
commit 87637d08a8
2 changed files with 47 additions and 1 deletions
@@ -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";
+2 -1
View File
@@ -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;