diff --git a/frontend/tests/e2e/search/search.spec.ts b/frontend/tests/e2e/search/search.spec.ts index e73cd256c6..993a0ffffb 100644 --- a/frontend/tests/e2e/search/search.spec.ts +++ b/frontend/tests/e2e/search/search.spec.ts @@ -76,7 +76,7 @@ test.describe("Search page tests", () => { const searchTerm = "0resultearch"; await fillSearchInputAndSubmit(searchTerm, page); - + await new Promise((resolve) => setTimeout(resolve, 3250)); expectURLContainsQueryParam(page, "query", searchTerm); // eslint-disable-next-line testing-library/prefer-screen-queries @@ -212,9 +212,9 @@ test.describe("Search page tests", () => { await waitForSearchResultsInitialLoad(page); // Verify that page 1 is highlighted - currentPageButton = page.locator(".usa-pagination__button.usa-current"); + currentPageButton = page.locator(".usa-pagination__button.usa-current").first(); await expect(currentPageButton).toHaveAttribute("aria-label", "Page 1"); - + // It should not have a page query param set expectURLContainsQueryParam(page, "page", "1", false); }); @@ -230,7 +230,7 @@ test.describe("Search page tests", () => { const lastSearchResultTitle = await getLastSearchResultTitle(page); - await selectOppositeSortOption(page); + await selectSortBy(page, "opportunityTitleAsc"); const firstSearchResultTitle = await getFirstSearchResultTitle(page); diff --git a/frontend/tests/e2e/search/searchSpecUtil.ts b/frontend/tests/e2e/search/searchSpecUtil.ts index 63782e6707..6c58a4b6fc 100644 --- a/frontend/tests/e2e/search/searchSpecUtil.ts +++ b/frontend/tests/e2e/search/searchSpecUtil.ts @@ -11,8 +11,7 @@ export function getSearchInput(page: Page) { export async function fillSearchInputAndSubmit(term: string, page: Page) { const searchInput = getSearchInput(page); await searchInput.fill(term); - await page.click(".usa-search >> button[type='submit']"); - expectURLContainsQueryParam(page, "query", term); + await page.click(".usa-search > button[type='submit']"); } export function expectURLContainsQueryParam( @@ -114,6 +113,7 @@ export async function refreshPageWithCurrentURL(page: Page) { export async function selectSortBy(page: Page, sortByValue: string) { await page.locator("#search-sort-by-select").selectOption(sortByValue); + await new Promise((resolve) => setTimeout(resolve, 1000)); } export async function expectSortBy(page: Page, value: string) {