mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-09 21:14:22 +00:00
feat(ui): make the Cloud flag a runtime variable (UI_CLOUD_ENABLED) (#12061)
Co-authored-by: Pablo F.G <pablo.fernandez@prowler.com> Co-authored-by: César Arroba <19954079+cesararroba@users.noreply.github.com>
This commit is contained in:
co-authored by
Pablo F.G
César Arroba
parent
bf82e9ff3d
commit
7d2a22c45a
@@ -11,7 +11,7 @@ describe("ProwlerBrand", () => {
|
||||
|
||||
it("should render the Local Server lockups outside Cloud", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
// When
|
||||
render(<ProwlerBrand />);
|
||||
@@ -30,7 +30,7 @@ describe("ProwlerBrand", () => {
|
||||
|
||||
it("should render the Prowler Cloud lockups in Cloud", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
|
||||
// When
|
||||
render(<ProwlerBrand />);
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
import { FormButtons } from "@/components/shadcn/form/form-buttons";
|
||||
import { EnhancedMultiSelect } from "@/components/shadcn/select/enhanced-multi-select";
|
||||
import { getAWSCredentialsTemplateLinks } from "@/lib";
|
||||
import { isCloud } from "@/lib/shared/env";
|
||||
import type { AWSCredentialsRole } from "@/types";
|
||||
import type { IntegrationProps } from "@/types/integrations";
|
||||
import {
|
||||
@@ -77,10 +78,9 @@ export const S3IntegrationForm = ({
|
||||
const isEditingConfig = editMode === "configuration";
|
||||
const isEditingCredentials = editMode === "credentials";
|
||||
|
||||
const defaultCredentialsType =
|
||||
process.env.NEXT_PUBLIC_IS_CLOUD_ENV === "true"
|
||||
? "aws-sdk-default"
|
||||
: "access-secret-key";
|
||||
const defaultCredentialsType = isCloud()
|
||||
? "aws-sdk-default"
|
||||
: "access-secret-key";
|
||||
|
||||
const form = useForm({
|
||||
resolver: zodResolver(
|
||||
|
||||
@@ -65,7 +65,7 @@ describe("AppSidebarContent", () => {
|
||||
|
||||
it("shares the brand, Launch Scan action and Local Server Cloud affordances", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
vi.stubEnv("NEXT_PUBLIC_PROWLER_RELEASE_VERSION", "5.8.0");
|
||||
const user = userEvent.setup();
|
||||
|
||||
@@ -91,7 +91,7 @@ describe("AppSidebarContent", () => {
|
||||
|
||||
it("keeps the existing Lighthouse chat sidebar in Cloud Chat mode", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
useAppSidebarMode.setState({ mode: APP_SIDEBAR_MODE.CHAT });
|
||||
|
||||
// When
|
||||
@@ -109,7 +109,7 @@ describe("AppSidebarContent", () => {
|
||||
|
||||
it("opens the current scan modal instead of navigating from the scans route", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
pathnameValue.current = "/scans";
|
||||
const user = userEvent.setup();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ describe("getNavigationConfig", () => {
|
||||
|
||||
it("groups the Local Server navigation without losing available features", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
// When
|
||||
const sections = getNavigationConfig({
|
||||
@@ -71,7 +71,7 @@ describe("getNavigationConfig", () => {
|
||||
|
||||
it("models Local Server Cloud features as contextual upgrade actions", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
// When
|
||||
const children = getConfigurationChildren();
|
||||
@@ -108,7 +108,7 @@ describe("getNavigationConfig", () => {
|
||||
|
||||
it("uses Cloud destinations and current New badges", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
|
||||
// When
|
||||
const sections = getNavigationConfig({
|
||||
@@ -148,7 +148,7 @@ describe("getNavigationConfig", () => {
|
||||
|
||||
it("keeps the Cloud Billing destination for users with billing permission", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const permissions = {
|
||||
manage_billing: true,
|
||||
} as RolePermissionAttributes;
|
||||
@@ -178,7 +178,7 @@ describe("getNavigationConfig", () => {
|
||||
const permissions = {
|
||||
manage_billing: false,
|
||||
} as RolePermissionAttributes;
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
|
||||
// When
|
||||
const cloudItems = getNavigationConfig({
|
||||
@@ -193,7 +193,7 @@ describe("getNavigationConfig", () => {
|
||||
cloudBillingEnabled: false,
|
||||
permissions: { ...permissions, manage_billing: true },
|
||||
}).flatMap((section) => section.items);
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
const localItems = getNavigationConfig({
|
||||
pathname: "/",
|
||||
apiDocsUrl: null,
|
||||
@@ -211,7 +211,7 @@ describe("getNavigationConfig", () => {
|
||||
|
||||
it("keeps environment-specific API documentation destinations", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
// When
|
||||
const localApiReference = getNavigationConfig({
|
||||
@@ -221,7 +221,7 @@ describe("getNavigationConfig", () => {
|
||||
.flatMap((section) => section.items)
|
||||
.find((item) => item.label === "API Reference");
|
||||
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const cloudApiReference = getNavigationConfig({
|
||||
pathname: "/",
|
||||
apiDocsUrl: "https://ignored.example/docs",
|
||||
@@ -240,7 +240,7 @@ describe("getNavigationConfig", () => {
|
||||
|
||||
it("omits the Local Server API reference when no URL is configured", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
// When
|
||||
const items = getNavigationConfig({
|
||||
@@ -256,7 +256,7 @@ describe("getNavigationConfig", () => {
|
||||
|
||||
it("filters navigation by required permission after visible copy changes", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const sections = getNavigationConfig({
|
||||
pathname: "/integrations",
|
||||
apiDocsUrl: null,
|
||||
@@ -294,7 +294,7 @@ describe("getNavigationConfig", () => {
|
||||
|
||||
it("keeps navigation when the required permission is granted", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const permissions = {
|
||||
manage_integrations: true,
|
||||
} as RolePermissionAttributes;
|
||||
@@ -320,7 +320,7 @@ describe("getNavigationConfig", () => {
|
||||
|
||||
it("matches complete route segments without stealing nested settings routes", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
// When
|
||||
const scanDetails = getNavigationConfig({
|
||||
|
||||
@@ -67,7 +67,7 @@ describe("NavbarClient", () => {
|
||||
navigationMocks.searchParams = new URLSearchParams();
|
||||
window.localStorage.clear();
|
||||
// Replay icon is Cloud-only.
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
// Default: the current route's content has loaded, so the icon is enabled.
|
||||
usePageReadyStore.setState({ readyPath: "/findings" });
|
||||
useSidePanelStore.setState({
|
||||
@@ -223,7 +223,7 @@ describe("NavbarClient", () => {
|
||||
});
|
||||
|
||||
it("hides the replay icon entirely in self-hosted (OSS) deployments", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
render(
|
||||
<NavbarClient
|
||||
@@ -280,7 +280,7 @@ describe("NavbarClient", () => {
|
||||
|
||||
it("hides the Lighthouse AI side-panel trigger in self-hosted (OSS) deployments", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
// When
|
||||
render(<NavbarClient title="Findings" />);
|
||||
|
||||
@@ -84,7 +84,7 @@ describe("OnboardingTrigger", () => {
|
||||
useDriverTourMock.mockClear();
|
||||
capturedOnClosed = undefined;
|
||||
// Trigger only resolves in cloud.
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
searchParamsValue = new URLSearchParams();
|
||||
sliceState = {
|
||||
active: false,
|
||||
@@ -196,7 +196,7 @@ describe("OnboardingTrigger", () => {
|
||||
|
||||
describe("in self-hosted (OSS) deployments", () => {
|
||||
it("renders null and never starts the tour, even with a matching param", async () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
searchParamsValue = new URLSearchParams("onboarding=add-provider");
|
||||
|
||||
const { container } = render(
|
||||
@@ -208,7 +208,7 @@ describe("OnboardingTrigger", () => {
|
||||
});
|
||||
|
||||
it("ignores an active sequence slice in OSS", async () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
setSlice({
|
||||
active: true,
|
||||
currentFlowId: "add-provider",
|
||||
|
||||
@@ -15,7 +15,7 @@ describe("AwsMethodSelector", () => {
|
||||
|
||||
it("opens the AWS Organizations upgrade in Local Server", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
const user = userEvent.setup();
|
||||
const onSelectOrganizations = vi.fn();
|
||||
|
||||
|
||||
@@ -393,7 +393,7 @@ describe("DataTableRowActions", () => {
|
||||
|
||||
it("opens Edit Scan Schedule for Prowler Cloud subscribed provider rows", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
@@ -420,7 +420,7 @@ describe("DataTableRowActions", () => {
|
||||
|
||||
it("hides Edit Scan Schedule for manual-only Cloud provider rows", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
@@ -445,7 +445,7 @@ describe("DataTableRowActions", () => {
|
||||
|
||||
it("hides Edit Scan Schedule for blocked Cloud provider rows", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
@@ -470,7 +470,7 @@ describe("DataTableRowActions", () => {
|
||||
|
||||
it("opens scan config management with the precomputed current config id", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
@@ -500,7 +500,7 @@ describe("DataTableRowActions", () => {
|
||||
|
||||
it("shows scan config management as unavailable when scan configs failed to load", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
@@ -528,7 +528,7 @@ describe("DataTableRowActions", () => {
|
||||
|
||||
it("hides Edit Scan Configuration for dynamic providers in Prowler Cloud", async () => {
|
||||
// Given a dynamic provider in a Cloud tenant with scan configs available.
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
|
||||
@@ -47,7 +47,7 @@ describe("useProviderWizardController", () => {
|
||||
sessionStorage.clear();
|
||||
localStorage.clear();
|
||||
// Checkpoint is Cloud-only.
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
useProviderWizardStore.getState().reset();
|
||||
useOrgSetupStore.getState().reset();
|
||||
});
|
||||
@@ -118,7 +118,7 @@ describe("useProviderWizardController", () => {
|
||||
});
|
||||
|
||||
it("does not request the onboarding checkpoint in self-hosted (OSS) deployments", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
const onOpenChange = vi.fn();
|
||||
const { result } = renderHook(() =>
|
||||
useProviderWizardController({
|
||||
|
||||
@@ -76,7 +76,7 @@ describe("LaunchStep", () => {
|
||||
|
||||
describe("Prowler OSS (non-Cloud)", () => {
|
||||
beforeEach(() => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
scanOnDemandMock.mockResolvedValue({ data: { id: "scan-1" } });
|
||||
});
|
||||
|
||||
@@ -174,7 +174,7 @@ describe("LaunchStep", () => {
|
||||
|
||||
describe("Prowler Cloud subscribed", () => {
|
||||
beforeEach(() => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
updateScheduleMock.mockResolvedValue({ data: { id: "provider-1" } });
|
||||
});
|
||||
|
||||
@@ -370,7 +370,7 @@ describe("LaunchStep", () => {
|
||||
|
||||
describe("Prowler Cloud trial/onboarding (manual scan only)", () => {
|
||||
beforeEach(() => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
scanOnDemandMock.mockResolvedValue({ data: { id: "scan-1" } });
|
||||
});
|
||||
|
||||
|
||||
+2
-1
@@ -14,6 +14,7 @@ import {
|
||||
} from "@/components/shadcn/select/select";
|
||||
import { Separator } from "@/components/shadcn/separator/separator";
|
||||
import { ProviderCredentialFields } from "@/lib/provider-credentials/provider-credential-fields";
|
||||
import { isCloud } from "@/lib/shared/env";
|
||||
import { AWSCredentialsRole } from "@/types";
|
||||
import { IntegrationType } from "@/types/integrations";
|
||||
|
||||
@@ -36,7 +37,7 @@ export const AWSRoleCredentialsForm = ({
|
||||
type?: "providers" | "integrations";
|
||||
integrationType?: IntegrationType;
|
||||
}) => {
|
||||
const isCloudEnv = process.env.NEXT_PUBLIC_IS_CLOUD_ENV === "true";
|
||||
const isCloudEnv = isCloud();
|
||||
const defaultCredentialsType = isCloudEnv
|
||||
? "aws-sdk-default"
|
||||
: "access-secret-key";
|
||||
|
||||
@@ -96,7 +96,7 @@ describe("AddRoleForm", () => {
|
||||
|
||||
it("shows Manage Alerts in Prowler Cloud", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
|
||||
// When
|
||||
render(<AddRoleForm groups={[]} />);
|
||||
@@ -108,7 +108,7 @@ describe("AddRoleForm", () => {
|
||||
|
||||
it("hides Manage Alerts outside Prowler Cloud", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
// When
|
||||
render(<AddRoleForm groups={[]} />);
|
||||
|
||||
@@ -6,6 +6,7 @@ import { DefaultValues } from "react-hook-form";
|
||||
import { addRole } from "@/actions/roles/roles";
|
||||
import { useToast } from "@/components/shadcn";
|
||||
import { getErrorMessage } from "@/lib";
|
||||
import { isCloud } from "@/lib/shared/env";
|
||||
import { RoleFormValues } from "@/types";
|
||||
|
||||
import { RoleForm, RoleFormSubmitContext, RoleGroupOption } from "./role-form";
|
||||
@@ -13,7 +14,7 @@ import { RoleForm, RoleFormSubmitContext, RoleGroupOption } from "./role-form";
|
||||
export const AddRoleForm = ({ groups }: { groups: RoleGroupOption[] }) => {
|
||||
const { toast } = useToast();
|
||||
const router = useRouter();
|
||||
const isCloudEnvironment = process.env.NEXT_PUBLIC_IS_CLOUD_ENV === "true";
|
||||
const isCloudEnvironment = isCloud();
|
||||
|
||||
const defaultValues: DefaultValues<RoleFormValues> = {
|
||||
name: "",
|
||||
|
||||
@@ -6,6 +6,7 @@ import { DefaultValues } from "react-hook-form";
|
||||
import { updateRole } from "@/actions/roles/roles";
|
||||
import { useToast } from "@/components/shadcn";
|
||||
import { getErrorMessage } from "@/lib";
|
||||
import { isCloud } from "@/lib/shared/env";
|
||||
import { RoleFormValues } from "@/types";
|
||||
|
||||
import { RoleForm, RoleFormSubmitContext, RoleGroupOption } from "./role-form";
|
||||
@@ -30,7 +31,7 @@ export const EditRoleForm = ({
|
||||
}) => {
|
||||
const { toast } = useToast();
|
||||
const router = useRouter();
|
||||
const isCloudEnvironment = process.env.NEXT_PUBLIC_IS_CLOUD_ENV === "true";
|
||||
const isCloudEnvironment = isCloud();
|
||||
|
||||
const defaultValues: DefaultValues<RoleFormValues> = {
|
||||
...roleData.data.attributes,
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
getUnlimitedVisibilityField,
|
||||
getVisiblePermissionFormFields,
|
||||
} from "@/lib/role-permissions";
|
||||
import { isCloud } from "@/lib/shared/env";
|
||||
import { roleFormSchema, RoleFormValues } from "@/types";
|
||||
|
||||
import { UnlimitedVisibilityField } from "./unlimited-visibility-section";
|
||||
@@ -74,7 +75,7 @@ export const RoleForm = ({
|
||||
defaultValues,
|
||||
});
|
||||
|
||||
const isCloudEnvironment = process.env.NEXT_PUBLIC_IS_CLOUD_ENV === "true";
|
||||
const isCloudEnvironment = isCloud();
|
||||
const visiblePermissionFormFields =
|
||||
getVisiblePermissionFormFields(isCloudEnvironment);
|
||||
const showUnlimitedVisibilityField = !!getUnlimitedVisibilityField();
|
||||
|
||||
@@ -154,7 +154,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("does not render an imported findings tab", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
render(
|
||||
<ScansPageShell providers={providers} hasManageScansPermission>
|
||||
@@ -172,7 +172,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("uses the shared scan filter bar for scan filters", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
render(
|
||||
<ScansPageShell providers={providers} hasManageScansPermission>
|
||||
@@ -190,7 +190,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("clears the active sort when switching tabs", async () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
searchParamsValue.current = "tab=active&sort=trigger";
|
||||
const user = userEvent.setup();
|
||||
|
||||
@@ -209,7 +209,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("uses a generic type filter label in Cloud", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
|
||||
render(
|
||||
<ScansPageShell providers={providers} hasManageScansPermission>
|
||||
@@ -221,7 +221,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("shows the CLI import banner in Cloud", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
|
||||
render(
|
||||
<ScansPageShell providers={providers} hasManageScansPermission>
|
||||
@@ -239,7 +239,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("hides the CLI import banner outside Cloud", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
render(
|
||||
<ScansPageShell providers={providers} hasManageScansPermission>
|
||||
@@ -251,7 +251,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("keeps launch scan with filters and mutelist with tabs", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
render(
|
||||
<ScansPageShell providers={providers} hasManageScansPermission>
|
||||
@@ -273,7 +273,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("shows the active scans count in the in progress tab", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
render(
|
||||
<ScansPageShell
|
||||
@@ -292,7 +292,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("opens the launch scan modal from the URL", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
searchParamsValue.current = "launchScan=true";
|
||||
|
||||
render(
|
||||
@@ -305,7 +305,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
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");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
searchParamsValue.current = "tab=completed&launchScan=true";
|
||||
const replaceStateSpy = vi.spyOn(window.history, "replaceState");
|
||||
const user = userEvent.setup();
|
||||
@@ -333,7 +333,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("opens and closes the launch scan modal from client state without navigation", async () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
const user = userEvent.setup();
|
||||
useScansStore.getState().openLaunchScanModal();
|
||||
|
||||
@@ -352,7 +352,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("shows the status filter only on the completed tab", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
searchParamsValue.current = "tab=completed";
|
||||
|
||||
render(
|
||||
@@ -367,7 +367,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("hides the status filter outside of the completed tab", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
searchParamsValue.current = "tab=active";
|
||||
|
||||
render(
|
||||
@@ -382,7 +382,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("clears status filter when switching scan tabs", async () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
searchParamsValue.current = "tab=completed&filter%5Bstate__in%5D=failed";
|
||||
const user = userEvent.setup();
|
||||
|
||||
@@ -400,7 +400,7 @@ describe("ScansPageShell", () => {
|
||||
});
|
||||
|
||||
it("clears type filter when switching to scheduled scans", async () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
searchParamsValue.current = "tab=completed&filter%5Btrigger%5D=manual";
|
||||
const user = userEvent.setup();
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ describe("ScanJobsRowActions", () => {
|
||||
|
||||
it("opens Edit Scan Schedule for Prowler Cloud subscribed scan rows", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(<ScanJobsRowActions scan={makeScan()} tab="scheduled" />);
|
||||
@@ -173,7 +173,7 @@ describe("ScanJobsRowActions", () => {
|
||||
|
||||
it("hides Edit Scan Schedule outside Prowler Cloud (OSS)", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(<ScanJobsRowActions scan={makeScan()} tab="scheduled" />);
|
||||
@@ -191,7 +191,7 @@ describe("ScanJobsRowActions", () => {
|
||||
|
||||
it("hides Edit Scan Schedule outside the Scheduled tab even on Cloud", async () => {
|
||||
// Given - advanced capability (Cloud) but rendered in the Completed tab.
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
@@ -214,7 +214,7 @@ describe("ScanJobsRowActions", () => {
|
||||
|
||||
it("hides Edit Scan Schedule for manual-only Cloud scan rows", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
@@ -238,7 +238,7 @@ describe("ScanJobsRowActions", () => {
|
||||
|
||||
it("hides Edit Scan Schedule for blocked Cloud scan rows", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
|
||||
@@ -47,7 +47,7 @@ describe("CloudUpgradeModal", () => {
|
||||
|
||||
it("renders the active contextual upgrade in Local Server", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
useCloudUpgradeStore
|
||||
.getState()
|
||||
.openCloudUpgrade(CLOUD_UPGRADE_FEATURE.ALERTS);
|
||||
@@ -76,7 +76,7 @@ describe("CloudUpgradeModal", () => {
|
||||
|
||||
it("uses the standard equal-width CTA layout", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
useCloudUpgradeStore
|
||||
.getState()
|
||||
.openCloudUpgrade(CLOUD_UPGRADE_FEATURE.AWS_ORGANIZATIONS);
|
||||
@@ -118,7 +118,7 @@ describe("CloudUpgradeModal", () => {
|
||||
|
||||
it("closes the active upgrade and returns focus to its trigger", async () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
@@ -189,7 +189,7 @@ describe("CloudUpgradeModal", () => {
|
||||
|
||||
it("does not render upgrade UI in Prowler Cloud", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
useCloudUpgradeStore
|
||||
.getState()
|
||||
.openCloudUpgrade(CLOUD_UPGRADE_FEATURE.ALERTS);
|
||||
|
||||
@@ -34,7 +34,7 @@ describe("RoleItem", () => {
|
||||
|
||||
it("shows Manage Alerts in Prowler Cloud role details", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
|
||||
// When
|
||||
render(<RoleItem role={role} roleDetail={roleDetail} />);
|
||||
@@ -45,7 +45,7 @@ describe("RoleItem", () => {
|
||||
|
||||
it("hides Manage Alerts outside Prowler Cloud role details", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "false");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
|
||||
// When
|
||||
render(<RoleItem role={role} roleDetail={roleDetail} />);
|
||||
@@ -56,7 +56,7 @@ describe("RoleItem", () => {
|
||||
|
||||
it("displays the permission state as a badge", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
|
||||
// When
|
||||
render(<RoleItem role={role} roleDetail={roleDetail} />);
|
||||
@@ -67,7 +67,7 @@ describe("RoleItem", () => {
|
||||
|
||||
it("does not render the details toggle", () => {
|
||||
// Given
|
||||
vi.stubEnv("NEXT_PUBLIC_IS_CLOUD_ENV", "true");
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
|
||||
// When
|
||||
render(<RoleItem role={role} roleDetail={roleDetail} />);
|
||||
|
||||
Reference in New Issue
Block a user