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

Commit

Permalink
test for all status checkboxes result count
Browse files Browse the repository at this point in the history
  • Loading branch information
rylew1 committed May 16, 2024
1 parent b01350e commit 51ffccc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
29 changes: 27 additions & 2 deletions frontend/tests/e2e/search/search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getFirstSearchResultTitle,
getLastSearchResultTitle,
getMobileMenuButton,
getNumberOfOpportunitySearchResults,
getSearchInput,
hasMobileMenu,
refreshPageWithCurrentURL,
Expand All @@ -21,6 +22,8 @@ import {
} from "./searchSpecUtil";
import { expect, test } from "@playwright/test";

import page from "../../../src/app/search/page";

test("should navigate from index to search page", async ({ page }) => {
// Start from the index page with feature flag set
await page.goto("/?_ff=showSearchV0:true");
Expand Down Expand Up @@ -202,10 +205,8 @@ test.describe("Search page tests", () => {
}) => {
await clickLastPaginationPage(page);

// Wait for the search results to load again
await waitForSearchResultsInitialLoad(page);

// Note the last result on the last page
const lastSearchResultTitle = await getLastSearchResultTitle(page);

await selectOppositeSortOption(page);
Expand All @@ -214,4 +215,28 @@ test.describe("Search page tests", () => {

expect(firstSearchResultTitle).toBe(lastSearchResultTitle);
});

test("number of results is the same with none or all opportunity status checked", async ({
page,
}) => {
const initialNumberOfOpportunityResults =
await getNumberOfOpportunitySearchResults(page);

// check all 4 boxes
const statusCheckboxes = {
"status-forecasted": "forecasted",
"status-posted": "posted",
"status-closed": "closed",
"status-archived": "archived",
};

await toggleCheckboxes(page, statusCheckboxes, "status");

const updatedNumberOfOpportunityResults =
await getNumberOfOpportunitySearchResults(page);

expect(initialNumberOfOpportunityResults).toBe(
updatedNumberOfOpportunityResults,
);
});
});
17 changes: 17 additions & 0 deletions frontend/tests/e2e/search/searchSpecUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,20 @@ export async function selectOppositeSortOption(page: Page) {

await sortByDropdown.selectOption(oppositeValue);
}

export async function waitForLoaderToBeHidden(page: Page) {
await page.waitForSelector(
".display-flex.flex-align-center.flex-justify-center.margin-bottom-15.margin-top-15",
{ state: "hidden" },
);
}

export async function getNumberOfOpportunitySearchResults(page: Page) {
await waitForLoaderToBeHidden(page);
const opportunitiesText = await page
.locator("h2.tablet-lg\\:grid-col-fill")
.textContent();
return opportunitiesText
? parseInt(opportunitiesText.replace(/\D/g, ""), 10)
: 0;
}

0 comments on commit 51ffccc

Please sign in to comment.