Skip to content

Commit

Permalink
add e2e test and fix some flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-s-nava committed Jan 31, 2025
1 parent 3202931 commit 061fe14
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 4 additions & 1 deletion frontend/src/components/search/ExportSearchResultsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export function ExportSearchResultsButton() {
}, [searchParams]);

return (
<div className="flex-justify-start">
<div
className="flex-justify-start"
data-testid="search-download-button-container"
>
<Button
outline={true}
type={"submit"}
Expand Down
13 changes: 13 additions & 0 deletions frontend/tests/e2e/search/search-download.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect, test } from "@playwright/test";

test.describe("Search results export", () => {
test("should download a csv file when requested", async ({ page }) => {
const downloadPromise = page.waitForEvent("download");
await page.goto("/search");
await page
.locator('div[data-testid="search-download-button-container"] > button')
.click();
const download = await downloadPromise;
expect(download.url()).toBeTruthy();
});
});
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 @@ -54,10 +54,10 @@ test.describe("Search page tests", () => {
"category-agriculture": "agriculture",
};

await selectSortBy(page, "agencyDesc");

await waitForSearchResultsInitialLoad(page);

await selectSortBy(page, "agencyDesc");

if (project.name.match(/[Mm]obile/)) {
await toggleMobileSearchFilters(page);
}
Expand Down Expand Up @@ -156,12 +156,12 @@ test.describe("Search page tests", () => {
page,
}: PageProps) => {
await page.goto("/search");
await waitForSearchResultsInitialLoad(page);

await selectSortBy(page, "opportunityTitleDesc");

await clickLastPaginationPage(page);

await waitForSearchResultsInitialLoad(page);

const lastSearchResultTitle = await getLastSearchResultTitle(page);

await selectSortBy(page, "opportunityTitleAsc");
Expand Down

0 comments on commit 061fe14

Please sign in to comment.