updated link on awaiting submission view allin welsh Related work items: #24389
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
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);
|
||
});
|