Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue #3646] Better Agency display and sort in Search #3686

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test and lint fixes
  • Loading branch information
doug-s-nava committed Jan 29, 2025
commit 4f50389dad3ee5ed1a931d10b2d79f7961de9898
4 changes: 2 additions & 2 deletions frontend/src/components/search/SearchResultsListItem.tsx
Original file line number Diff line number Diff line change
@@ -2,14 +2,14 @@

import { Opportunity } from "src/types/search/searchResponseTypes";
import { formatDate } from "src/utils/dateUtil";
import { AgencyNamyLookup } from "src/utils/search/generateAgencyNameLookup";
import { AgencyNameLookup } from "src/utils/search/generateAgencyNameLookup";

import { useTranslations } from "next-intl";
import Link from "next/link";

interface SearchResultsListItemProps {
opportunity: Opportunity;
agencyNameLookup?: AgencyNamyLookup;
agencyNameLookup?: AgencyNameLookup;
}

export default function SearchResultsListItem({
Original file line number Diff line number Diff line change
@@ -64,5 +64,5 @@ export const useGlobalState = <T extends Partial<GlobalState>>(
throw new Error("useGlobalState must be used within GlobalStateProvider");
}

return useStore(globalStateStore, useShallow(selector)) as T;
return useStore(globalStateStore, useShallow(selector));
};
Original file line number Diff line number Diff line change
@@ -14,13 +14,13 @@ jest.mock("next-intl", () => ({
jest.mock("src/hooks/useSearchParamUpdater", () => ({
useSearchParamUpdater: () => ({
searchParams: new ReadonlyURLSearchParams(),
updateQueryParams: () => {},
updateQueryParams: () => undefined,
}),
}));

jest.mock("src/services/globalState/GlobalStateProvider", () => ({
useGlobalState: () => ({
setAgencyOptions: () => {},
setAgencyOptions: () => undefined,
}),
}));

Original file line number Diff line number Diff line change
@@ -41,6 +41,12 @@ jest.mock("src/hooks/useSearchParamUpdater", () => ({
}),
}));

jest.mock("src/services/globalState/GlobalStateProvider", () => ({
useGlobalState: () => ({
setAgencyOptions: () => undefined,
}),
}));

describe("SearchFilterAccordion", () => {
const title = "Test Accordion";
const queryParamKey = "fundingInstrument";
6 changes: 6 additions & 0 deletions frontend/tests/components/search/SearchFilters.test.tsx
Original file line number Diff line number Diff line change
@@ -23,6 +23,12 @@ jest.mock("next-intl", () => ({
useTranslations: () => useTranslationsMock(),
}));

jest.mock("src/services/globalState/GlobalStateProvider", () => ({
useGlobalState: () => ({
setAgencyOptions: () => undefined,
}),
}));

// otherwise we have to deal with mocking suspense
jest.mock(
"src/components/search/SearchFilterAccordion/AgencyFilterAccordion",
6 changes: 6 additions & 0 deletions frontend/tests/pages/search/page.test.tsx
Original file line number Diff line number Diff line change
@@ -57,6 +57,12 @@ jest.mock("react", () => ({
use: jest.fn((e: { [key: string]: string }) => e),
}));

jest.mock("src/services/globalState/GlobalStateProvider", () => ({
useGlobalState: () => ({
agencyOptions: [],
}),
}));

const fetchMock = jest.fn().mockResolvedValue({
json: jest.fn().mockResolvedValue({ data: [], errors: [], warnings: [] }),
ok: true,
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { deepStrictEqual } from "assert";
import {
agenciesToFilterOptions,
getAgenciesForFilterOptions,
@@ -39,11 +38,11 @@ const mockfetchAgencies = jest
const mockSortFilterOptions = jest.fn();

jest.mock("src/services/fetch/fetchers/fetchers", () => ({
fetchAgencies: (arg: unknown) => mockfetchAgencies(arg),
fetchAgencies: (arg: unknown): unknown => mockfetchAgencies(arg),
}));

jest.mock("src/utils/search/searchUtils", () => ({
sortFilterOptions: (arg: unknown) => mockSortFilterOptions(arg),
sortFilterOptions: (arg: unknown): unknown => mockSortFilterOptions(arg),
}));

describe("obtainAgencies", () => {