From abd7ca8714bba524c988e341b51cdefebddf85d3 Mon Sep 17 00:00:00 2001 From: acouch Date: Fri, 5 Jul 2024 17:45:07 -0400 Subject: [PATCH] Update tests --- .../services/search/searchfetcher/APISearchFetcher.ts | 2 +- .../SearchFilterAccordion/SearchFilterAccordion.test.tsx | 9 --------- .../SearchFilterAccordion/SearchFilterCheckbox.test.tsx | 1 - .../SearchFilterSection/SearchFilterSection.test.tsx | 2 +- .../components/search/SearchOpportunityStatus.test.tsx | 2 +- .../tests/components/search/SearchPagination.test.tsx | 3 ++- frontend/tests/components/search/SearchSortBy.test.tsx | 6 +++--- frontend/tests/hooks/useSearchParamUpdater.test.ts | 3 +-- 8 files changed, 9 insertions(+), 19 deletions(-) diff --git a/frontend/src/services/search/searchfetcher/APISearchFetcher.ts b/frontend/src/services/search/searchfetcher/APISearchFetcher.ts index 897e0cc174..49212f18c7 100644 --- a/frontend/src/services/search/searchfetcher/APISearchFetcher.ts +++ b/frontend/src/services/search/searchfetcher/APISearchFetcher.ts @@ -18,7 +18,7 @@ export class APISearchFetcher extends SearchFetcher { ): Promise { try { // Keep commented in case we need to simulate a delay to test loaders - await new Promise((resolve) => setTimeout(resolve, 3250)); + // await new Promise((resolve) => setTimeout(resolve, 3250)); const response: SearchAPIResponse = await this.searchApi.searchOpportunities(searchInputs); diff --git a/frontend/tests/components/search/SearchFilterAccordion/SearchFilterAccordion.test.tsx b/frontend/tests/components/search/SearchFilterAccordion/SearchFilterAccordion.test.tsx index d93b1806a7..7be2e69c27 100644 --- a/frontend/tests/components/search/SearchFilterAccordion/SearchFilterAccordion.test.tsx +++ b/frontend/tests/components/search/SearchFilterAccordion/SearchFilterAccordion.test.tsx @@ -88,10 +88,6 @@ describe("SearchFilterAccordion", () => { expect(clearAllButton).toBeInTheDocument(); expect(clearAllButton).toBeDisabled(); - const cooperativeAgreementCheckbox = screen.getByLabelText( - "Cooperative Agreement", - ); - const updatedQuery = new Set(""); updatedQuery.add("Cooperative Agreement"); // after clicking one of the boxes, the page should rerender @@ -155,11 +151,6 @@ describe("SearchFilterAccordion", () => { />, ); - const cooperativeAgreementCheckbox = screen.getByLabelText( - "Cooperative Agreement", - ); - const grantCheckbox = screen.getByLabelText("Grant"); - // Verify the count updates to 2 const countSpan = screen.getByText("2", { selector: ".usa-tag.usa-tag--big.radius-pill.margin-left-1", diff --git a/frontend/tests/components/search/SearchFilterAccordion/SearchFilterCheckbox.test.tsx b/frontend/tests/components/search/SearchFilterAccordion/SearchFilterCheckbox.test.tsx index fd7e9c3e4e..b5e7c2f1fb 100644 --- a/frontend/tests/components/search/SearchFilterAccordion/SearchFilterCheckbox.test.tsx +++ b/frontend/tests/components/search/SearchFilterAccordion/SearchFilterCheckbox.test.tsx @@ -6,7 +6,6 @@ import React from "react"; import SearchFilterCheckbox from "src/components/search/SearchFilterAccordion/SearchFilterCheckbox"; import { axe } from "jest-axe"; -const mockIncrement = jest.fn(); const mockUpdateCheckedOption = jest.fn(); const option = { id: "test-option", diff --git a/frontend/tests/components/search/SearchFilterAccordion/SearchFilterSection/SearchFilterSection.test.tsx b/frontend/tests/components/search/SearchFilterAccordion/SearchFilterSection/SearchFilterSection.test.tsx index 57fdac05bb..52571ed6b4 100644 --- a/frontend/tests/components/search/SearchFilterAccordion/SearchFilterSection/SearchFilterSection.test.tsx +++ b/frontend/tests/components/search/SearchFilterAccordion/SearchFilterSection/SearchFilterSection.test.tsx @@ -1,6 +1,6 @@ import "@testing-library/jest-dom"; -import { fireEvent, render, screen, waitFor } from "@testing-library/react"; +import { fireEvent, render, screen } from "@testing-library/react"; import React from "react"; import SearchFilterSection from "src/components/search/SearchFilterAccordion/SearchFilterSection/SearchFilterSection"; diff --git a/frontend/tests/components/search/SearchOpportunityStatus.test.tsx b/frontend/tests/components/search/SearchOpportunityStatus.test.tsx index 44685a10d5..1be71a5ad4 100644 --- a/frontend/tests/components/search/SearchOpportunityStatus.test.tsx +++ b/frontend/tests/components/search/SearchOpportunityStatus.test.tsx @@ -29,7 +29,7 @@ describe("SearchOpportunityStatus", () => { expect(screen.getByText("Archived")).toBeEnabled(); }); - it("checking a checkbox calls updateQueryParams and requestSubmit", async () => { + it("checking a checkbox calls updateQueryParams and requestSubmit", () => { const query = new Set(""); query.add("test"); const combined = new Set(""); diff --git a/frontend/tests/components/search/SearchPagination.test.tsx b/frontend/tests/components/search/SearchPagination.test.tsx index 5d400bd5df..c4ee7c8e89 100644 --- a/frontend/tests/components/search/SearchPagination.test.tsx +++ b/frontend/tests/components/search/SearchPagination.test.tsx @@ -1,6 +1,7 @@ +/* eslint-disable jest/no-commented-out-tests */ import "@testing-library/jest-dom/extend-expect"; import { axe } from "jest-axe"; -import { fireEvent, render, screen } from "@testing-library/react"; +import { render } from "@testing-library/react"; import React from "react"; import SearchPagination from "src/components/search/SearchPagination"; diff --git a/frontend/tests/components/search/SearchSortBy.test.tsx b/frontend/tests/components/search/SearchSortBy.test.tsx index ed8a22f571..72e63c1b25 100644 --- a/frontend/tests/components/search/SearchSortBy.test.tsx +++ b/frontend/tests/components/search/SearchSortBy.test.tsx @@ -34,18 +34,18 @@ describe("SearchSortBy", () => { }); it("updates sort option and submits the form on change", () => { - const container = render( + render( , ); - fireEvent.change(container.getByRole("combobox"), { + fireEvent.change(screen.getByRole("combobox"), { target: { value: "opportunityTitleDesc" }, }); expect( - container.getByText("Opportunity Title (Z to A)"), + screen.getByText("Opportunity Title (Z to A)"), ).toBeInTheDocument(); }); }); diff --git a/frontend/tests/hooks/useSearchParamUpdater.test.ts b/frontend/tests/hooks/useSearchParamUpdater.test.ts index b9b6830126..a8c4fd1bcd 100644 --- a/frontend/tests/hooks/useSearchParamUpdater.test.ts +++ b/frontend/tests/hooks/useSearchParamUpdater.test.ts @@ -2,8 +2,7 @@ import { renderHook, waitFor } from "@testing-library/react"; import { useSearchParamUpdater } from "src/hooks/useSearchParamUpdater"; - -let mockSearchParams = new URLSearchParams(); +const mockSearchParams = new URLSearchParams(); const routerPush = jest.fn(() => Promise.resolve(true)); jest.mock("next/navigation", () => ({ usePathname: jest.fn(() => "/test") as jest.Mock,