diff --git a/ui/components/providers/wizard/steps/launch-step.test.tsx b/ui/components/providers/wizard/steps/launch-step.test.tsx index 62a9e15d13..1f33955849 100644 --- a/ui/components/providers/wizard/steps/launch-step.test.tsx +++ b/ui/components/providers/wizard/steps/launch-step.test.tsx @@ -3,6 +3,7 @@ import type { ComponentProps } from "react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { useProviderWizardStore } from "@/store/provider-wizard/store"; +import { SCAN_JOBS_TAB } from "@/types"; import { LaunchStep } from "./launch-step"; @@ -81,5 +82,9 @@ describe("LaunchStep", () => { title: "Scan Launched", }), ); + const toastPayload = toastMock.mock.calls[0]?.[0]; + expect(toastPayload.action.props.children.props.href).toBe( + `/scans?tab=${SCAN_JOBS_TAB.ACTIVE}`, + ); }); }); diff --git a/ui/components/providers/wizard/steps/launch-step.tsx b/ui/components/providers/wizard/steps/launch-step.tsx index bbefb717d8..1e63f6700d 100644 --- a/ui/components/providers/wizard/steps/launch-step.tsx +++ b/ui/components/providers/wizard/steps/launch-step.tsx @@ -15,6 +15,7 @@ import { Spinner } from "@/components/shadcn/spinner/spinner"; import { TreeStatusIcon } from "@/components/shadcn/tree-view/tree-status-icon"; import { ToastAction, useToast } from "@/components/ui"; import { useProviderWizardStore } from "@/store/provider-wizard/store"; +import { SCAN_JOBS_TAB } from "@/types"; import { TREE_ITEM_STATUS } from "@/types/tree"; import { @@ -81,7 +82,7 @@ export function LaunchStep({ : "Single scan launched successfully.", action: ( - Go to scans + Go to scans ), }); diff --git a/ui/components/scans/scans-filter-bar.test.tsx b/ui/components/scans/scans-filter-bar.test.tsx new file mode 100644 index 0000000000..f629e0291b --- /dev/null +++ b/ui/components/scans/scans-filter-bar.test.tsx @@ -0,0 +1,66 @@ +import { render, screen } from "@testing-library/react"; +import { describe, expect, it, vi } from "vitest"; + +import { SCAN_JOBS_TAB } from "@/types"; + +import { ScansFilterBar } from "./scans-filter-bar"; + +vi.mock("@/components/filters/provider-account-selectors", () => ({ + ProviderAccountSelectors: () =>
Provider account selectors
, +})); + +vi.mock("@/components/shadcn", () => ({ + Select: ({ children }: { children: React.ReactNode }) => ( +
{children}
+ ), + SelectContent: ({ children }: { children: React.ReactNode }) => ( +
{children}
+ ), + SelectItem: ({ + children, + value, + }: { + children: React.ReactNode; + value: string; + }) =>
{children}
, + SelectTrigger: ({ children, ...props }: React.ComponentProps<"button">) => ( + + ), + SelectValue: ({ placeholder }: { placeholder: string }) => ( + {placeholder} + ), +})); + +const defaultProps = { + providers: [], + scheduleType: "all", + scanStatus: "all", + showStatusFilter: false, + onScheduleTypeChange: vi.fn(), + onScanStatusChange: vi.fn(), +}; + +describe("ScansFilterBar", () => { + it("hides the type filter on the scheduled tab", () => { + // Given + render( + , + ); + + // Then + expect( + screen.queryByRole("button", { name: /all types/i }), + ).not.toBeInTheDocument(); + expect(screen.getByText("Provider account selectors")).toBeInTheDocument(); + }); + + it("shows the type filter outside the scheduled tab", () => { + // Given + render( + , + ); + + // Then + expect(screen.getByRole("button", { name: /all types/i })).toBeVisible(); + }); +}); diff --git a/ui/components/scans/scans-filter-bar.tsx b/ui/components/scans/scans-filter-bar.tsx index 89ac753345..8ab48a8f9c 100644 --- a/ui/components/scans/scans-filter-bar.tsx +++ b/ui/components/scans/scans-filter-bar.tsx @@ -8,7 +8,7 @@ import { SelectTrigger, SelectValue, } from "@/components/shadcn"; -import type { ScanJobsTab } from "@/types"; +import { SCAN_JOBS_TAB, type ScanJobsTab } from "@/types"; import type { ProviderProps } from "@/types/providers"; import { @@ -40,6 +40,7 @@ export function ScansFilterBar({ const isCloudEnvironment = process.env.NEXT_PUBLIC_IS_CLOUD_ENV === "true"; const triggerFilterOptions = getScanTriggerFilterOptions(isCloudEnvironment); const statusFilterOptions = getScanStatusFilterOptions(activeTab); + const showScheduleTypeFilter = activeTab !== SCAN_JOBS_TAB.SCHEDULED; return ( <> @@ -52,18 +53,20 @@ export function ScansFilterBar({ accountSelectorClassName={filterItemClass} /> - + {showScheduleTypeFilter && ( + + )} {showStatusFilter && (