This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
forked from HHS/simpler-grants-gov
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
113 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Page, expect, test } from "@playwright/test"; | ||
import { | ||
expectURLContainsQueryParam, | ||
fillSearchInputAndSubmit, | ||
} from "./searchSpecUtil"; | ||
|
||
import { BrowserContextOptions } from "playwright-core"; | ||
|
||
interface PageProps { | ||
page: Page; | ||
browserName?: string; | ||
contextOptions?: BrowserContextOptions; | ||
} | ||
|
||
test.describe("Search page tests", () => { | ||
test.beforeEach(async ({ page }: PageProps) => { | ||
// Navigate to the search page with the feature flag set | ||
await page.goto("/search?_ff=showSearchV0:true"); | ||
}); | ||
|
||
test("should return 0 results when searching for obscure term", async ({ | ||
page, | ||
browserName, | ||
}: PageProps) => { | ||
// TODO (Issue #2005): fix test for webkit | ||
test.skip( | ||
browserName === "webkit", | ||
"Skipping test for WebKit due to a query param issue.", | ||
); | ||
|
||
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 | ||
const resultsHeading = page.getByRole("heading", { | ||
name: /0 Opportunities/i, | ||
}); | ||
await expect(resultsHeading).toBeVisible(); | ||
|
||
await expect(page.locator("div.usa-prose h2")).toHaveText( | ||
"Your search did not return any results.", | ||
); | ||
}); | ||
|
||
test("should show and hide loading state", async ({ | ||
page, | ||
browserName, | ||
}: PageProps) => { | ||
// TODO (Issue #2005): fix test for webkit | ||
test.skip( | ||
browserName === "webkit", | ||
"Skipping test for WebKit due to a query param issue.", | ||
); | ||
const searchTerm = "advanced"; | ||
await fillSearchInputAndSubmit(searchTerm, page); | ||
|
||
const loadingIndicator = page.locator("text='Loading results...'"); | ||
await expect(loadingIndicator).toBeVisible(); | ||
await expect(loadingIndicator).toBeHidden(); | ||
|
||
const searchTerm2 = "agency"; | ||
await fillSearchInputAndSubmit(searchTerm2, page); | ||
await expect(loadingIndicator).toBeVisible(); | ||
await expect(loadingIndicator).toBeHidden(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Page, expect, test } from "@playwright/test"; | ||
import { | ||
clickMobileNavMenu, | ||
clickSearchNavLink, | ||
expectCheckboxIDIsChecked, | ||
expectURLContainsQueryParam, | ||
getMobileMenuButton, | ||
hasMobileMenu, | ||
} from "./searchSpecUtil"; | ||
|
||
import { BrowserContextOptions } from "playwright-core"; | ||
|
||
interface PageProps { | ||
page: Page; | ||
browserName?: string; | ||
contextOptions?: BrowserContextOptions; | ||
} | ||
|
||
test("should navigate from index to search page", async ({ | ||
page, | ||
}: PageProps) => { | ||
// Start from the index page with feature flag set | ||
await page.goto("/?_ff=showSearchV0:true"); | ||
|
||
// Mobile chrome must first click the menu button | ||
if (await hasMobileMenu(page)) { | ||
const menuButton = getMobileMenuButton(page); | ||
await clickMobileNavMenu(menuButton); | ||
} | ||
|
||
await clickSearchNavLink(page); | ||
|
||
// Verify that the new URL is correct | ||
expectURLContainsQueryParam(page, "status", "forecasted,posted"); | ||
|
||
// Verify the presence of "Search" content on the page | ||
await expect(page.locator("h1")).toContainText( | ||
"Search funding opportunities", | ||
); | ||
|
||
// Verify that the 'forecasted' and 'posted' are checked | ||
await expectCheckboxIDIsChecked(page, "#status-forecasted"); | ||
await expectCheckboxIDIsChecked(page, "#status-posted"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters