Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
acouch committed Jul 5, 2024
1 parent abd7ca8 commit 1db5ed3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions frontend/tests/e2e/search/search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
});
Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions frontend/tests/e2e/search/searchSpecUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 1db5ed3

Please sign in to comment.