Skip to content

Commit

Permalink
Move mocks around
Browse files Browse the repository at this point in the history
  • Loading branch information
jamdelion committed Sep 17, 2024
1 parent 6a992f9 commit 7da5771
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
16 changes: 2 additions & 14 deletions e2e/tests/ui-driven/src/helpers/userActions.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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,
{
Expand Down
13 changes: 13 additions & 0 deletions e2e/tests/ui-driven/src/mocks/osPlacesResponse.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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),
});
});
}

0 comments on commit 7da5771

Please sign in to comment.