Skip to content

Commit

Permalink
add geoJson mock and types
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 committed Dec 2, 2024
1 parent c78677b commit 9afa203
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions e2e/tests/ui-driven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"packageManager": "[email protected]",
"devDependencies": {
"@playwright/test": "^1.49.0",
"@types/geojson": "^7946.0.14",
"@types/node": "18.16.1",
"eslint-plugin-playwright": "^0.20.0"
}
Expand Down
7 changes: 7 additions & 0 deletions e2e/tests/ui-driven/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions e2e/tests/ui-driven/src/create-flow-with-geospatial.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { getTeamPage } from "./helpers/getPage";
import { createAuthenticatedSession } from "./helpers/globalHelpers";
import { answerFindProperty, clickContinue } from "./helpers/userActions";
import { PlaywrightEditor } from "./pages/Editor";
import { mockMapGeoJson } from "./mocks/geoJsonMock";
import { checkGeoJsonContent } from "./helpers/geospatialChecks";

test.describe("Flow creation, publish and preview", () => {
let context: Context = {
Expand Down Expand Up @@ -117,6 +119,12 @@ test.describe("Flow creation, publish and preview", () => {
await clickContinue({ page });

await expect(page.getByRole('heading', { name: 'About the property' })).toBeVisible()

// Check map component has geoJson content
await checkGeoJsonContent(page, mockMapGeoJson)

// Check property info is being shown
await expect(page.getByText('Test Street, Testville')).toBeVisible()
await clickContinue({ page });

await expect(
Expand Down
12 changes: 12 additions & 0 deletions e2e/tests/ui-driven/src/helpers/geospatialChecks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { expect, Page } from "@playwright/test";
import { Feature } from "geojson";

export const checkGeoJsonContent = async (page: Page, geoJson: Feature) => {
// Wait for the map component to be present using the id
const mapComponent = await page.waitForSelector('my-map#property-information-map');

// Get the geojsonData attribute
const geojsonData = await mapComponent.getAttribute('geojsondata');

expect(JSON.parse(geojsonData!)).toEqual(geoJson)
}
4 changes: 4 additions & 0 deletions e2e/tests/ui-driven/src/mocks/geoJsonMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Feature } from "geojson";


export const mockMapGeoJson: Feature = {"geometry":{"type":"MultiPolygon","coordinates":[[[[-0.633498,51.605485],[-0.633455,51.605606],[-0.633788,51.605643],[-0.634429,51.605799],[-0.634429,51.605767],[-0.633498,51.605485]]]]},"type":"Feature","properties":{"entry-date":"2024-05-06","start-date":"2010-05-12","end-date":"","entity":12000041468,"name":"","dataset":"title-boundary","typology":"geography","reference":"45211072","prefix":"title-boundary","organisation-entity":"13"}}

0 comments on commit 9afa203

Please sign in to comment.