diff --git a/e2e/tests/ui-driven/src/helpers/userActions.ts b/e2e/tests/ui-driven/src/helpers/userActions.ts index bfa801e474..51c7cbe7ca 100644 --- a/e2e/tests/ui-driven/src/helpers/userActions.ts +++ b/e2e/tests/ui-driven/src/helpers/userActions.ts @@ -1,6 +1,6 @@ import type { Locator, Page } from "@playwright/test"; import { expect } from "@playwright/test"; -import { mockOSPlacesResponse } from "../mocks/osPlacesResponse"; +import { setupOSMockResponse } from "../mocks/osPlacesResponse"; import type { Context } from "./context"; import { findSessionId, getGraphQLClient } from "./context"; import { TEST_EMAIL, log, waitForDebugLog } from "./globalHelpers"; @@ -121,7 +121,7 @@ export async function answerChecklist({ title: string; answers: string[]; }) { - const checklist = await page.getByRole("heading").filter({ + const checklist = page.getByRole("heading").filter({ hasText: title, }); await expect(checklist).toBeVisible(); @@ -204,18 +204,6 @@ export async function answerFindProperty(page: Page) { await page.getByRole("option").first().click(); } -async function setupOSMockResponse(page: Page) { - const ordnanceSurveryPlacesEndpoint = new RegExp( - /proxy\/ordnance-survey\/search\/places\/v1\/postcode\/*/, - ); - await page.route(ordnanceSurveryPlacesEndpoint, async (route) => { - await route.fulfill({ - status: 200, - body: JSON.stringify(mockOSPlacesResponse), - }); - }); -} - export async function answerContactInput( page: Page, { diff --git a/e2e/tests/ui-driven/src/mocks/osPlacesResponse.ts b/e2e/tests/ui-driven/src/mocks/osPlacesResponse.ts index 6b6baf7d4b..5f4547be28 100644 --- a/e2e/tests/ui-driven/src/mocks/osPlacesResponse.ts +++ b/e2e/tests/ui-driven/src/mocks/osPlacesResponse.ts @@ -1,3 +1,5 @@ +import { Page } from "@playwright/test"; + export const mockOSPlacesResponse = { header: { uri: "https://api.os.uk/search/places/v1/postcode?postcode=SW1%201AA&dataset=LPI&maxResults=100&output_srs=EPSG%3A4326&lr=EN&offset=0", @@ -58,3 +60,14 @@ export const mockOSPlacesResponse = { }, ], }; +export async function setupOSMockResponse(page: Page) { + const ordnanceSurveryPlacesEndpoint = new RegExp( + /proxy\/ordnance-survey\/search\/places\/v1\/postcode\/*/, + ); + await page.route(ordnanceSurveryPlacesEndpoint, async (route) => { + await route.fulfill({ + status: 200, + body: JSON.stringify(mockOSPlacesResponse), + }); + }); +}