Files
pedwfrontend/pwe2e/tests/loggedout/homepageLinks.spec.js
Robert Bond 478fa91004 Merged PR 2558: updated link on awaiting submission view allin welsh
updated link on awaiting submission view allin welsh

Related work items: #24389
2026-08-12 13:58:07 +00:00

36 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { test, expect } from "@playwright/test";
import { handleSearchResults } from "../../helpers/index";
test("Check for DNS applications", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "Accept cookies" }).click();
await page.getByRole("link", { name: "View all DNS applications" }).click();
async function handleSearchResults(page) {
const results = page.locator("dd a.govuk-link--no-underline");
await Promise.race([
results.first().waitFor({ state: "visible", timeout: 15000 }),
]);
if ((await results.count()) > 0) {
await results.first().click({ timeout: 15000 });
await expect(page.locator("#main-content")).toContainText("Reference:", {
timeout: 15000,
});
return "clicked";
} else if ((await noResultsMessage.count()) > 0) {
console.log("️ No results found. Test passes.");
return "no-results";
} else {
throw new Error(
"⚠️ Unexpected search page state: neither results nor zero-results message found."
);
}
}
// Handle search results safely
const outcome = await handleSearchResults(page);
console.log(`Search outcome for DNS":`, outcome);
});