fix(ui): gate import scan copy gated by cloud

This commit is contained in:
Pablo F.G
2026-07-17 12:11:08 +02:00
parent bd6da1926f
commit f2f8bb1358
2 changed files with 36 additions and 2 deletions
@@ -1,11 +1,15 @@
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { afterEach, describe, expect, it, vi } from "vitest";
import { ADD_PROVIDER_HREF } from "@/lib/providers-navigation";
import { ScansProvidersEmptyState } from "./scans-providers-empty-state";
describe("ScansProvidersEmptyState", () => {
afterEach(() => {
vi.unstubAllEnvs();
});
it("shows the add-provider hint with a providers page CTA when there are no providers", () => {
render(<ScansProvidersEmptyState thereIsNoProviders />);
@@ -24,6 +28,30 @@ describe("ScansProvidersEmptyState", () => {
expect(cta.tagName).toBe("A");
});
it("mentions imported scans in the disconnected hint only in Cloud", () => {
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
render(<ScansProvidersEmptyState thereIsNoProviders={false} />);
expect(
screen.getByText(/imported scans still appear below/i),
).toBeInTheDocument();
});
it("omits the imported-scans copy in the disconnected hint outside Cloud", () => {
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
render(<ScansProvidersEmptyState thereIsNoProviders={false} />);
expect(
screen.queryByText(/imported scans still appear below/i),
).not.toBeInTheDocument();
// The base guidance still shows so the hint stays actionable.
expect(
screen.getByText(/connect one to launch on-demand scans/i),
).toBeInTheDocument();
});
it("does not render the provider wizard dialog in Scans", () => {
render(<ScansProvidersEmptyState thereIsNoProviders />);
@@ -1,5 +1,6 @@
import { CustomBanner } from "@/components/shadcn/custom/custom-banner";
import { ADD_PROVIDER_HREF } from "@/lib/providers-navigation";
import { isCloud } from "@/lib/shared/env";
interface ScansProvidersEmptyStateProps {
thereIsNoProviders: boolean;
@@ -8,6 +9,11 @@ interface ScansProvidersEmptyStateProps {
export function ScansProvidersEmptyState({
thereIsNoProviders,
}: ScansProvidersEmptyStateProps) {
// Imported scans are Cloud-only, so only Cloud mentions that they stay visible.
const disconnectedMessage = isCloud()
? "None of your providers are connected yet. Connect one to launch on-demand scans — imported scans still appear below."
: "None of your providers are connected yet. Connect one to launch on-demand scans.";
return thereIsNoProviders ? (
<CustomBanner
title="No Providers Configured"
@@ -18,7 +24,7 @@ export function ScansProvidersEmptyState({
) : (
<CustomBanner
title="No Connected Providers"
message="None of your providers are connected yet. Connect one to launch on-demand scans — imported scans still appear below."
message={disconnectedMessage}
buttonLabel="Review Providers"
buttonLink="/providers"
/>