Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions frontend/src/app/[locale]/(base)/saved-opportunities/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const savedOpportunities = jest.fn().mockResolvedValue([]);
const opportunity = jest.fn().mockResolvedValue({ data: [] });
const mockUseSearchParams = jest.fn().mockReturnValue(new URLSearchParams());
const clientFetchMock = jest.fn().mockResolvedValue([]);
const mockBreadcrumbs = jest.fn();

jest.mock("src/hooks/useClientFetch", () => ({
useClientFetch: () => ({
Expand Down Expand Up @@ -56,6 +57,14 @@ jest.mock("src/services/fetch/fetchers/savedOpportunityFetcher", () => ({
savedOpportunities(statusFilter) as Promise<MinimalOpportunity[]>,
}));

jest.mock("src/components/Breadcrumbs", () => ({
__esModule: true,
default: (props: { breadcrumbList: { title: string; path: string }[] }) => {
mockBreadcrumbs(props);
return <nav data-testid="mock-breadcrumbs" />;
},
}));

const defaultSearchParams = Promise.resolve({});

describe("Saved Opportunities page", () => {
Expand All @@ -76,6 +85,29 @@ describe("Saved Opportunities page", () => {
await waitFor(() => expect(content).toBeInTheDocument());
});

it("passes the correct breadcrumbs", async () => {
const component = await SavedOpportunities({
params: localeParams,
searchParams: defaultSearchParams,
});
render(component);

expect(screen.getByTestId("mock-breadcrumbs")).toBeInTheDocument();

expect(mockBreadcrumbs).toHaveBeenCalledWith({
breadcrumbList: [
{
title: "SavedOpportunities.breadcrumbWorkspace",
path: "/dashboard",
},
{
title: "SavedOpportunities.breadcrumbSavedOpportunities",
path: "/saved-opportunities",
},
],
});
});

it("does not render status filter when there are no saved opportunities", async () => {
const component = await SavedOpportunities({
params: localeParams,
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/app/[locale]/(base)/saved-opportunities/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { SAVED_OPPORTUNITIES_CRUMBS } from "src/constants/breadcrumbs";
import { getOpportunityDetails } from "src/services/fetch/fetchers/opportunityFetcher";
import { fetchSavedOpportunities } from "src/services/fetch/fetchers/savedOpportunityFetcher";
import { LocalizedPageProps } from "src/types/intl";
Expand Down Expand Up @@ -72,7 +71,18 @@ export default async function SavedOpportunities({
return (
<>
<GridContainer>
<Breadcrumbs breadcrumbList={SAVED_OPPORTUNITIES_CRUMBS} />
<Breadcrumbs
breadcrumbList={[
{
title: t("SavedOpportunities.breadcrumbWorkspace"),
path: `/dashboard`,
},
{
title: t("SavedOpportunities.breadcrumbSavedOpportunities"),
path: `/saved-opportunities`,
},
]}
/>
<h1 className="margin-top-0">{t("SavedOpportunities.heading")}</h1>
</GridContainer>
<div className="grid-container padding-y-5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function ManageUsersPageContent({
path: `/organizations/${organizationId}`,
},
{
title: `${t("pageHeading")}`,
title: t("pageHeading"),
path: `/organizations/${organizationId}/manage-users`,
},
]}
Expand Down
8 changes: 0 additions & 8 deletions frontend/src/constants/breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ const SEARCH: Breadcrumb = {
title: "Search",
path: "/search",
};
const SAVED_OPPORTUNITIES: Breadcrumb = {
title: "Saved opportunities",
path: "/saved-opportunities/",
};

// page breadcrumbs
export const SEARCH_CRUMBS: Breadcrumb[] = [HOME, SEARCH];
export const SAVED_OPPORTUNITIES_CRUMBS: Breadcrumb[] = [
HOME,
SAVED_OPPORTUNITIES,
];
2 changes: 2 additions & 0 deletions frontend/src/i18n/messages/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,8 @@ export const messages = {
SavedOpportunities: {
metaDescription: "View your saved funding opportunities.",
heading: "Saved opportunities",
breadcrumbWorkspace: "Workspace",
breadcrumbSavedOpportunities: "Saved opportunities",
noSavedCTAParagraphOne:
"To add an opportunity to your list, use the Save button next to its title on the listing's page.",
noSavedCTAParagraphTwo:
Expand Down
Loading