diff --git a/e2e/tests/ui-driven/package.json b/e2e/tests/ui-driven/package.json index 91c2c8e9db..b5aaa364e3 100644 --- a/e2e/tests/ui-driven/package.json +++ b/e2e/tests/ui-driven/package.json @@ -22,6 +22,7 @@ "packageManager": "pnpm@8.6.6", "devDependencies": { "@playwright/test": "^1.49.0", + "@types/geojson": "^7946.0.14", "@types/node": "18.16.1", "eslint-plugin-playwright": "^0.20.0" } diff --git a/e2e/tests/ui-driven/pnpm-lock.yaml b/e2e/tests/ui-driven/pnpm-lock.yaml index 4e3fc3e0fe..75407766b7 100644 --- a/e2e/tests/ui-driven/pnpm-lock.yaml +++ b/e2e/tests/ui-driven/pnpm-lock.yaml @@ -40,6 +40,9 @@ devDependencies: '@playwright/test': specifier: ^1.49.0 version: 1.49.0 + '@types/geojson': + specifier: ^7946.0.14 + version: 7946.0.14 '@types/node': specifier: 18.16.1 version: 18.16.1 @@ -647,6 +650,10 @@ packages: resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==} dev: false + /@types/geojson@7946.0.14: + resolution: {integrity: sha512-WCfD5Ht3ZesJUsONdhvm84dmzWOiOzOAqOncN0++w0lBw1o8OuDNJF2McvvCef/yBqb/HYRahp1BYtODFQ8bRg==} + dev: true + /@types/json-schema@7.0.15: resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} dev: false diff --git a/e2e/tests/ui-driven/src/create-flow-with-geospatial.spec.ts b/e2e/tests/ui-driven/src/create-flow-with-geospatial.spec.ts index 28779bd31e..f0b9306d72 100644 --- a/e2e/tests/ui-driven/src/create-flow-with-geospatial.spec.ts +++ b/e2e/tests/ui-driven/src/create-flow-with-geospatial.spec.ts @@ -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 = { @@ -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( diff --git a/e2e/tests/ui-driven/src/helpers/geospatialChecks.ts b/e2e/tests/ui-driven/src/helpers/geospatialChecks.ts new file mode 100644 index 0000000000..68fd1c4507 --- /dev/null +++ b/e2e/tests/ui-driven/src/helpers/geospatialChecks.ts @@ -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) +} \ No newline at end of file diff --git a/e2e/tests/ui-driven/src/mocks/geoJsonMock.ts b/e2e/tests/ui-driven/src/mocks/geoJsonMock.ts new file mode 100644 index 0000000000..72ae2382db --- /dev/null +++ b/e2e/tests/ui-driven/src/mocks/geoJsonMock.ts @@ -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"}} \ No newline at end of file