From 5a36cc039eacb6c60cea42eced28179aea237cb6 Mon Sep 17 00:00:00 2001 From: Ryan Lewis <93001277+rylew1@users.noreply.github.com> Date: Mon, 8 Apr 2024 15:08:32 -0700 Subject: [PATCH] [Issue #1471]: Tests for search components (#1617) ## Summary Fixes #1471 ## Changes - Tests for most of the search components --- .../SearchFilterSection/SectionLinkLabel.tsx | 16 +- .../components/search/SearchPagination.tsx | 1 + .../src/components/search/SearchSortBy.tsx | 1 + .../components/search/SearchBar.test.tsx | 49 ++++++ .../SearchFilterAccordion.test.tsx | 152 ++++++++++++++++++ .../SearchFilterCheckbox.test.tsx | 74 +++++++++ .../SearchFilterSection.test.tsx | 98 +++++++++++ .../SectionLinkCount.test.tsx | 26 +++ .../SectionLinkLabel.test.tsx | 44 +++++ .../SearchFilterToggleAll.test.tsx | 83 ++++++++++ .../search/SearchPagination.test.tsx | 88 ++++++++++ .../search/SearchResultsHeader.test.tsx | 45 ++++++ .../search/SearchResultsListItem.test.tsx | 37 +++++ .../components/search/SearchSortBy.test.tsx | 65 ++++++++ 14 files changed, 777 insertions(+), 2 deletions(-) create mode 100644 frontend/tests/components/search/SearchBar.test.tsx create mode 100644 frontend/tests/components/search/SearchFilterAccordion/SearchFilterAccordion.test.tsx create mode 100644 frontend/tests/components/search/SearchFilterAccordion/SearchFilterCheckbox.test.tsx create mode 100644 frontend/tests/components/search/SearchFilterAccordion/SearchFilterSection/SearchFilterSection.test.tsx create mode 100644 frontend/tests/components/search/SearchFilterAccordion/SearchFilterSection/SectionLinkCount.test.tsx create mode 100644 frontend/tests/components/search/SearchFilterAccordion/SearchFilterSection/SectionLinkLabel.test.tsx create mode 100644 frontend/tests/components/search/SearchFilterAccordion/SearchFilterToggleAll.test.tsx create mode 100644 frontend/tests/components/search/SearchPagination.test.tsx create mode 100644 frontend/tests/components/search/SearchResultsHeader.test.tsx create mode 100644 frontend/tests/components/search/SearchResultsListItem.test.tsx create mode 100644 frontend/tests/components/search/SearchSortBy.test.tsx diff --git a/frontend/src/components/search/SearchFilterAccordion/SearchFilterSection/SectionLinkLabel.tsx b/frontend/src/components/search/SearchFilterAccordion/SearchFilterSection/SectionLinkLabel.tsx index 1726990eb..a894f3a42 100644 --- a/frontend/src/components/search/SearchFilterAccordion/SearchFilterSection/SectionLinkLabel.tsx +++ b/frontend/src/components/search/SearchFilterAccordion/SearchFilterSection/SectionLinkLabel.tsx @@ -8,12 +8,24 @@ export default function SectionLinkLabel({ childrenVisible: boolean; option: FilterOption; }) { + // When the arrow is down, the section is collapsed, and we can expand the section + // When the arrow is up, the section is expanded, and we can collapse the section + const ariaLabel = childrenVisible ? "Collapse section" : "Expand section"; + return ( {childrenVisible ? ( - + ) : ( - + )} {option.label}{" "} {/* Assuming you want to display the option's label instead of its ID */} diff --git a/frontend/src/components/search/SearchPagination.tsx b/frontend/src/components/search/SearchPagination.tsx index f1ac88144..29dd6389c 100644 --- a/frontend/src/components/search/SearchPagination.tsx +++ b/frontend/src/components/search/SearchPagination.tsx @@ -28,6 +28,7 @@ export default function SearchPagination({ name="currentPage" ref={paginationRef} value={page} + data-testid="hiddenCurrentPage" /> )} = ({ id="search-sort-by-select" onChange={handleChange} value={sortBy} + aria-label="Sort By" > {SORT_OPTIONS.map((option) => (