From cb8408aa39d734929265bbdc6cd3f0c84d534b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Thu, 28 Sep 2023 16:21:53 +0100 Subject: [PATCH 1/5] fix(e2e): Quick fix of failing e2e tests --- e2e/tests/ui-driven/.eslintrc | 5 +---- e2e/tests/ui-driven/src/context.ts | 3 ++- e2e/tests/ui-driven/src/create-flow.spec.ts | 8 ++------ e2e/tests/ui-driven/src/login.spec.ts | 4 ++-- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/e2e/tests/ui-driven/.eslintrc b/e2e/tests/ui-driven/.eslintrc index 06ebaf4f40..ab524aebf3 100644 --- a/e2e/tests/ui-driven/.eslintrc +++ b/e2e/tests/ui-driven/.eslintrc @@ -1,6 +1,3 @@ { - "extends": ["../../.eslintrc", "plugin:playwright/playwright-test"], - "rules": { - "playwright/no-skipped-test": "off" - } + "extends": ["../../.eslintrc", "plugin:playwright/playwright-test"] } diff --git a/e2e/tests/ui-driven/src/context.ts b/e2e/tests/ui-driven/src/context.ts index d188eb4e51..465886cef2 100644 --- a/e2e/tests/ui-driven/src/context.ts +++ b/e2e/tests/ui-driven/src/context.ts @@ -102,11 +102,12 @@ export async function tearDownTestContext(context: Context) { } } -export function generateAuthenticationToken(userId) { +export function generateAuthenticationToken(userId: string) { assert(process.env.JWT_SECRET); return sign( { sub: `${userId}`, + email: "simulate-delivered@notifications.service.gov.uk", "https://hasura.io/jwt/claims": { "x-hasura-allowed-roles": ["platformAdmin", "public"], "x-hasura-default-role": "platformAdmin", diff --git a/e2e/tests/ui-driven/src/create-flow.spec.ts b/e2e/tests/ui-driven/src/create-flow.spec.ts index b6c2d77b6a..71e9905b33 100644 --- a/e2e/tests/ui-driven/src/create-flow.spec.ts +++ b/e2e/tests/ui-driven/src/create-flow.spec.ts @@ -35,7 +35,7 @@ test.describe("Navigation", () => { await tearDownTestContext(context); }); - test.skip("Create a flow", async ({ browser }) => { + test("Create a flow", async ({ browser }) => { const page = await getTeamPage({ browser, userId: context.user!.id!, @@ -91,11 +91,7 @@ test.describe("Navigation", () => { await expect(nodes.getByText(noBranchNoticeText)).toBeVisible(); }); - test.skip("Preview a created flow", async ({ - browser, - }: { - browser: Browser; - }) => { + test("Preview a created flow", async ({ browser }: { browser: Browser }) => { const page = await createAuthenticatedSession({ browser, userId: context.user!.id!, diff --git a/e2e/tests/ui-driven/src/login.spec.ts b/e2e/tests/ui-driven/src/login.spec.ts index 4def1068a9..75920f3fb9 100644 --- a/e2e/tests/ui-driven/src/login.spec.ts +++ b/e2e/tests/ui-driven/src/login.spec.ts @@ -26,7 +26,7 @@ test.describe("Login", () => { await tearDownTestContext(context); }); - test.skip("setting a cookie bypasses login", async ({ browser }) => { + test("setting a cookie bypasses login", async ({ browser }) => { const page = await createAuthenticatedSession({ browser, userId: context.user!.id!, @@ -41,7 +41,7 @@ test.describe("Login", () => { await expect(team).toBeVisible(); }); - test.skip("shows error toast when there is a network error and removes it when a retry is successful", async ({ + test("shows error toast when there is a network error and removes it when a retry is successful", async ({ browser, }) => { const page = await createAuthenticatedSession({ From 6fc65dfcbeb0f6fe19cdedf011e04d5949d0a743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Fri, 29 Sep 2023 11:36:03 +0100 Subject: [PATCH 2/5] fix(e2e): Uncomment skipped e2e tests - Remove redundant email from JWT, rely on ID - Update API tests - Update /me route --- api.planx.uk/modules/misc/controller.ts | 10 +++++----- api.planx.uk/modules/misc/routes.test.ts | 16 +++++++--------- api.planx.uk/package.json | 2 +- api.planx.uk/pnpm-lock.yaml | 8 ++++---- api.planx.uk/server.ts | 1 - e2e/tests/ui-driven/src/context.ts | 1 - editor.planx.uk/.eslintrc | 9 +++++++-- editor.planx.uk/package.json | 2 +- editor.planx.uk/pnpm-lock.yaml | 10 +++++----- 9 files changed, 30 insertions(+), 29 deletions(-) diff --git a/api.planx.uk/modules/misc/controller.ts b/api.planx.uk/modules/misc/controller.ts index 7f283599ab..cc1addd30f 100644 --- a/api.planx.uk/modules/misc/controller.ts +++ b/api.planx.uk/modules/misc/controller.ts @@ -11,17 +11,17 @@ export const getLoggedInUserDetails: RequestHandler = async ( try { const $client = getClient(); - const email = userContext.getStore()?.user.email; - if (!email) + const id = userContext.getStore()?.user.sub; + if (!id) throw new ServerError({ - message: "User email missing from request", + message: "User ID missing from request", status: 400, }); - const user = await $client.user.getByEmail(email); + const user = await $client.user.getById(parseInt(id)); if (!user) throw new ServerError({ - message: `Unable to locate user with email ${email}`, + message: `Unable to locate user with ID ${id}`, status: 400, }); diff --git a/api.planx.uk/modules/misc/routes.test.ts b/api.planx.uk/modules/misc/routes.test.ts index e80e97c015..93413940d9 100644 --- a/api.planx.uk/modules/misc/routes.test.ts +++ b/api.planx.uk/modules/misc/routes.test.ts @@ -5,8 +5,8 @@ import { userContext } from "../auth/middleware"; const getStoreMock = jest.spyOn(userContext, "getStore"); -const mockGetByEmail = jest.fn().mockResolvedValue({ - id: 36, +const mockGetById = jest.fn().mockResolvedValue({ + id: 123, firstName: "Albert", lastName: "Einstein", email: "albert@princeton.edu", @@ -27,7 +27,7 @@ jest.mock("@opensystemslab/planx-core", () => { return { CoreDomainClient: jest.fn().mockImplementation(() => ({ user: { - getByEmail: () => mockGetByEmail(), + getById: () => mockGetById(), }, })), }; @@ -38,7 +38,6 @@ describe("/me endpoint", () => { getStoreMock.mockReturnValue({ user: { sub: "123", - email: "test@opensystemslab.io", jwt: getJWT({ role: "teamEditor" }), }, }); @@ -58,8 +57,7 @@ describe("/me endpoint", () => { it("returns an error for invalid user context", async () => { getStoreMock.mockReturnValue({ user: { - sub: "123", - email: undefined, + sub: undefined, jwt: getJWT({ role: "teamEditor" }), }, }); @@ -70,13 +68,13 @@ describe("/me endpoint", () => { .expect(400) .then((res) => { expect(res.body).toEqual({ - error: "User email missing from request", + error: "User ID missing from request", }); }); }); it("returns an error for an invalid email address", async () => { - mockGetByEmail.mockResolvedValueOnce(null); + mockGetById.mockResolvedValueOnce(null); await supertest(app) .get("/me") @@ -84,7 +82,7 @@ describe("/me endpoint", () => { .expect(400) .then((res) => { expect(res.body).toEqual({ - error: "Unable to locate user with email test@opensystemslab.io", + error: "Unable to locate user with ID 123", }); }); }); diff --git a/api.planx.uk/package.json b/api.planx.uk/package.json index 67bb14eb41..b248856d91 100644 --- a/api.planx.uk/package.json +++ b/api.planx.uk/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "@airbrake/node": "^2.1.8", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#44e9ebe", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#44420b9", "@types/isomorphic-fetch": "^0.0.36", "adm-zip": "^0.5.10", "aws-sdk": "^2.1467.0", diff --git a/api.planx.uk/pnpm-lock.yaml b/api.planx.uk/pnpm-lock.yaml index 1043cbbbaf..583784cc38 100644 --- a/api.planx.uk/pnpm-lock.yaml +++ b/api.planx.uk/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: ^2.1.8 version: 2.1.8 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#44e9ebe - version: git/github.com+theopensystemslab/planx-core/44e9ebe + specifier: git+https://github.com/theopensystemslab/planx-core#44420b9 + version: github.com/theopensystemslab/planx-core/44420b9 '@types/isomorphic-fetch': specifier: ^0.0.36 version: 0.0.36 @@ -8073,8 +8073,8 @@ packages: resolution: {integrity: sha512-wvWkphh5WQsJbVk1tbx1l1Ly4yg+XecD+Mq280uBGt9wa5BKSWf4Mhp6GmrkPixhMxmabYY7RbzlwVP32pbGCg==} dev: false - git/github.com+theopensystemslab/planx-core/44e9ebe: - resolution: {commit: 44e9ebe, repo: git@github.com:theopensystemslab/planx-core.git, type: git} + github.com/theopensystemslab/planx-core/44420b9: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/44420b9} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/api.planx.uk/server.ts b/api.planx.uk/server.ts index 17ff987d3a..6db24eb716 100644 --- a/api.planx.uk/server.ts +++ b/api.planx.uk/server.ts @@ -529,7 +529,6 @@ declare global { interface User { jwt: string; sub?: string; - email?: string; "https://hasura.io/jwt/claims"?: { "x-hasura-allowed-roles": Role[]; }; diff --git a/e2e/tests/ui-driven/src/context.ts b/e2e/tests/ui-driven/src/context.ts index 465886cef2..788230a062 100644 --- a/e2e/tests/ui-driven/src/context.ts +++ b/e2e/tests/ui-driven/src/context.ts @@ -107,7 +107,6 @@ export function generateAuthenticationToken(userId: string) { return sign( { sub: `${userId}`, - email: "simulate-delivered@notifications.service.gov.uk", "https://hasura.io/jwt/claims": { "x-hasura-allowed-roles": ["platformAdmin", "public"], "x-hasura-default-role": "platformAdmin", diff --git a/editor.planx.uk/.eslintrc b/editor.planx.uk/.eslintrc index f22e01a1e4..d0141dc994 100644 --- a/editor.planx.uk/.eslintrc +++ b/editor.planx.uk/.eslintrc @@ -11,7 +11,6 @@ "extends": [ "eslint:recommended", "plugin:jsx-a11y/recommended", - "plugin:testing-library/react", "plugin:@typescript-eslint/recommended", "prettier", "plugin:jest/recommended" @@ -73,5 +72,11 @@ }, "settings": { "jest": { "version": 27 } - } + }, + "overrides": [ + { + "files": ["**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)"], + "extends": ["plugin:testing-library/react"] + } + ] } diff --git a/editor.planx.uk/package.json b/editor.planx.uk/package.json index 4a917666e2..d5195c1e33 100644 --- a/editor.planx.uk/package.json +++ b/editor.planx.uk/package.json @@ -14,7 +14,7 @@ "@mui/styles": "^5.14.5", "@mui/utils": "^5.14.5", "@opensystemslab/map": "^0.7.5", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#44e9ebe", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#44420b9", "@tiptap/core": "^2.0.3", "@tiptap/extension-bold": "^2.0.3", "@tiptap/extension-bubble-menu": "^2.1.6", diff --git a/editor.planx.uk/pnpm-lock.yaml b/editor.planx.uk/pnpm-lock.yaml index 2b8bcaa1b3..ab8619d7d4 100644 --- a/editor.planx.uk/pnpm-lock.yaml +++ b/editor.planx.uk/pnpm-lock.yaml @@ -46,8 +46,8 @@ dependencies: specifier: ^0.7.5 version: 0.7.5 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#44e9ebe - version: git/github.com+theopensystemslab/planx-core/44e9ebe(@types/react@18.2.20) + specifier: git+https://github.com/theopensystemslab/planx-core#44420b9 + version: github.com/theopensystemslab/planx-core/44420b9(@types/react@18.2.20) '@tiptap/core': specifier: ^2.0.3 version: 2.0.3(@tiptap/pm@2.0.3) @@ -20864,9 +20864,9 @@ packages: use-sync-external-store: 1.2.0(react@18.2.0) dev: false - git/github.com+theopensystemslab/planx-core/44e9ebe(@types/react@18.2.20): - resolution: {commit: 44e9ebe, repo: git@github.com:theopensystemslab/planx-core.git, type: git} - id: git@github.com+theopensystemslab/planx-core/44e9ebe + github.com/theopensystemslab/planx-core/44420b9(@types/react@18.2.20): + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/44420b9} + id: github.com/theopensystemslab/planx-core/44420b9 name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true From 72a76d71ba03daf1dc76052a67e4f66160450808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Fri, 29 Sep 2023 11:39:06 +0100 Subject: [PATCH 3/5] fix: Update frontend - Only init user store once - Update Header to use store for username - Avoid zustand namespace clashes in user store --- editor.planx.uk/src/client/index.ts | 6 ++ .../src/components/Header.test.tsx | 11 ++- editor.planx.uk/src/components/Header.tsx | 6 +- .../src/pages/FlowEditor/lib/store/user.ts | 83 +++++-------------- editor.planx.uk/src/routes/authenticated.tsx | 6 +- 5 files changed, 39 insertions(+), 73 deletions(-) diff --git a/editor.planx.uk/src/client/index.ts b/editor.planx.uk/src/client/index.ts index bda7c63919..263f8ca1d3 100644 --- a/editor.planx.uk/src/client/index.ts +++ b/editor.planx.uk/src/client/index.ts @@ -1,4 +1,5 @@ import { CoreDomainClient } from "@opensystemslab/planx-core"; +import { getCookie } from "lib/cookie"; /** * core doesn't expose a graphql interface like the graphql/hasura clients do * instead, it encapsulates query and business logic to only expose declarative interfaces @@ -6,3 +7,8 @@ import { CoreDomainClient } from "@opensystemslab/planx-core"; export const _public = new CoreDomainClient({ targetURL: process.env.REACT_APP_HASURA_URL!, }); + +export const _client = new CoreDomainClient({ + targetURL: process.env.REACT_APP_HASURA_URL!, + auth: { jwt: getCookie("jwt") || "" } +}) diff --git a/editor.planx.uk/src/components/Header.test.tsx b/editor.planx.uk/src/components/Header.test.tsx index 3a0e0c3c3a..6eec0c2991 100644 --- a/editor.planx.uk/src/components/Header.test.tsx +++ b/editor.planx.uk/src/components/Header.test.tsx @@ -40,6 +40,14 @@ describe("Header Component - Editor Route", () => { teamSettings: mockTeam1.settings, teamTheme: mockTeam1.theme, teamSlug: mockTeam1.slug, + user: { + firstName: "Test", + lastName: "User", + isPlatformAdmin: false, + teams: [], + id: 123, + email: "test@example.com" + } }), ); @@ -51,7 +59,6 @@ describe("Header Component - Editor Route", () => { pathname: "/team-name/flow-name", }, data: { - username: "Test User", flow: "test-flow", }, }) as any, @@ -93,7 +100,6 @@ for (const route of ["/preview", "/unpublished", "/pay", "/invite"]) { pathname: "/opensystemslab/test-flow" + route, }, data: { - username: "Test User", flow: "test-flow", }, }) as any, @@ -145,7 +151,6 @@ describe("Section navigation bar", () => { pathname: "/team-name/flow-name/preview", }, data: { - username: "Test User", flow: "test-flow", }, }) as any, diff --git a/editor.planx.uk/src/components/Header.tsx b/editor.planx.uk/src/components/Header.tsx index 81597020ba..2b3f20e44d 100644 --- a/editor.planx.uk/src/components/Header.tsx +++ b/editor.planx.uk/src/components/Header.tsx @@ -423,7 +423,7 @@ const EditorToolbar: React.FC<{ - {route.data.username && ( + {user && ( {route.data.flow && ( )} - {route.data.username[0]} + {user.firstName[0]} + { user && navigate("/logout")}>Log out + } ); }; diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/user.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/user.ts index 6e8a202b30..d239b30930 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/user.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/user.ts @@ -1,20 +1,14 @@ -import { User, UserTeams } from "@opensystemslab/planx-core/types"; -import gql from "graphql-tag"; +import { User } from "@opensystemslab/planx-core/types"; +import { _client } from "client"; import jwtDecode from "jwt-decode"; -import { client } from "lib/graphql"; import { Team } from "types"; import type { StateCreator } from "zustand"; export interface UserStore { - id: number; - firstName: string; - lastName: string; - email: string; - isPlatformAdmin: boolean; - teams: UserTeams[]; + user?: User setUser: (user: User) => void; - getUser: () => User; + getUser: () => User | undefined; canUserEditTeam: (teamSlug: Team["slug"]) => boolean; initUserStore: (jwt: string) => Promise; } @@ -23,70 +17,33 @@ export const userStore: StateCreator = ( set, get, ) => ({ - id: 0, - firstName: "", - lastName: "", - email: "", - isPlatformAdmin: false, - teams: [], - setUser: (user: User) => - set({ - id: user.id, - firstName: user.firstName, - lastName: user.lastName, - email: user.email, - isPlatformAdmin: user.isPlatformAdmin, - teams: user.teams, - }), + setUser: (user: User) => set({ user }), - getUser: () => ({ - id: get().id, - firstName: get().firstName, - lastName: get().lastName, - email: get().email, - isPlatformAdmin: get().isPlatformAdmin, - teams: get().teams, - }), + getUser: () => get().user, - canUserEditTeam: (teamSlug) => { + canUserEditTeam(teamSlug) { + const user = this.getUser(); + if (!user) return false; + return ( - get().isPlatformAdmin || + user.isPlatformAdmin || teamSlug === "templates" || - get().teams.filter( + user.teams.filter( (team) => team.role === "teamEditor" && team.team.slug === teamSlug, ).length > 0 ); }, - initUserStore: async (jwt: string) => { - const email = (jwtDecode(jwt) as any)["email"]; - const users = await client.query({ - query: gql` - query GetUserByEmail($email: String!) { - users: users(where: { email: { _eq: $email } }) { - id - firstName: first_name - lastName: last_name - email - isPlatformAdmin: is_platform_admin - teams { - role - team { - name - slug - id - } - } - } - } - `, - variables: { email }, - }); + async initUserStore(jwt: string) { + const { getUser, setUser } = get(); + + if (getUser()) return; - const user: User = users.data.users[0]; - if (!user) throw new Error(`Failed to get user ${email}`); + const id = (jwtDecode(jwt) as any)["sub"]; + const user = await _client.user.getById(id); + if (!user) throw new Error(`Failed to get user with ID ${id}`); - get().setUser(user); + setUser(user); }, }); diff --git a/editor.planx.uk/src/routes/authenticated.tsx b/editor.planx.uk/src/routes/authenticated.tsx index d4a5806b5e..11b809c624 100644 --- a/editor.planx.uk/src/routes/authenticated.tsx +++ b/editor.planx.uk/src/routes/authenticated.tsx @@ -1,5 +1,5 @@ import gql from "graphql-tag"; -import { compose, lazy, mount, route, withData, withView } from "navi"; +import { compose, lazy, mount, route, withView } from "navi"; import { useStore } from "pages/FlowEditor/lib/store"; import React from "react"; @@ -10,10 +10,6 @@ import { makeTitle } from "./utils"; import { authenticatedView } from "./views/authenticated"; const editorRoutes = compose( - withData(() => ({ - username: useStore.getState().getUser().firstName, - })), - withView(authenticatedView), mount({ From 0cd2c76b98238f7d235f1b97fec1b44b8ed69ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Fri, 29 Sep 2023 11:50:06 +0100 Subject: [PATCH 4/5] fix: Linting --- .../components/DrawBoundary/Public/index.tsx | 22 +-- .../FileUploadAndLabel/Editor.test.tsx | 2 +- .../components/FileUploadAndLabel/Modal.tsx | 6 +- .../classifiedRoadsNegativeResponseMock.ts | 2 +- .../mocks/classifiedRoadsResponseMock.ts | 2 +- .../src/@planx/components/Section/Editor.tsx | 5 +- .../@planx/components/Section/Public.test.tsx | 14 +- .../src/@planx/components/Section/Public.tsx | 45 ++++--- editor.planx.uk/src/client/index.ts | 4 +- .../src/components/Header.test.tsx | 4 +- editor.planx.uk/src/components/Header.tsx | 127 +++++++++--------- .../components/Flow/components/Hanger.tsx | 5 +- .../components/Settings/DesignSettings.tsx | 2 +- .../components/Settings/ServiceFlags.tsx | 2 +- .../src/pages/FlowEditor/lib/store/editor.ts | 4 +- .../src/pages/FlowEditor/lib/store/user.ts | 7 +- editor.planx.uk/src/ui/ImgInput.tsx | 2 +- editor.planx.uk/src/ui/ListManager.tsx | 2 +- 18 files changed, 143 insertions(+), 114 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/DrawBoundary/Public/index.tsx b/editor.planx.uk/src/@planx/components/DrawBoundary/Public/index.tsx index 0d3f450282..7850e0bf32 100644 --- a/editor.planx.uk/src/@planx/components/DrawBoundary/Public/index.tsx +++ b/editor.planx.uk/src/@planx/components/DrawBoundary/Public/index.tsx @@ -12,7 +12,7 @@ import QuestionHeader from "@planx/components/shared/Preview/QuestionHeader"; import { PrivateFileUpload } from "@planx/components/shared/PrivateFileUpload/PrivateFileUpload"; import type { PublicProps } from "@planx/components/ui"; import buffer from "@turf/buffer"; -import { type GeometryObject,point } from "@turf/helpers"; +import { type GeometryObject, point } from "@turf/helpers"; import { Store, useStore } from "pages/FlowEditor/lib/store"; import React, { useEffect, useRef, useState } from "react"; import { FONT_WEIGHT_SEMI_BOLD } from "theme"; @@ -42,10 +42,13 @@ export default function Component(props: Props) { const [boundary, setBoundary] = useState(previousBoundary); const [slots, setSlots] = useState(previousFile ?? []); const [area, setArea] = useState(previousArea); - const addressPoint = passport?.data?._address?.longitude && passport?.data?._address?.latitude && point([ - Number(passport?.data?._address?.longitude), - Number(passport?.data?._address?.latitude), - ]); + const addressPoint = + passport?.data?._address?.longitude && + passport?.data?._address?.latitude && + point([ + Number(passport?.data?._address?.longitude), + Number(passport?.data?._address?.latitude), + ]); const environment = useStore((state) => state.previewEnvironment); useEffect(() => { @@ -120,9 +123,12 @@ export default function Component(props: Props) { drawMode drawPointer="crosshair" drawGeojsonData={JSON.stringify(boundary)} - clipGeojsonData={addressPoint && JSON.stringify( - buffer(addressPoint, BUFFER_IN_METERS, { units: "meters" }), - )} + clipGeojsonData={ + addressPoint && + JSON.stringify( + buffer(addressPoint, BUFFER_IN_METERS, { units: "meters" }), + ) + } zoom={20} maxZoom={23} latitude={Number(passport?.data?._address?.latitude)} diff --git a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Editor.test.tsx b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Editor.test.tsx index c14b559f7c..4b8d71140a 100644 --- a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Editor.test.tsx +++ b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Editor.test.tsx @@ -1,11 +1,11 @@ import { screen } from "@testing-library/react"; +import { vanillaStore } from "pages/FlowEditor/lib/store"; import React from "react"; import { DndProvider } from "react-dnd"; import { HTML5Backend } from "react-dnd-html5-backend"; import { setup } from "testUtils"; import FileUploadAndLabelComponent from "./Editor"; -import { vanillaStore } from "pages/FlowEditor/lib/store"; const { getState } = vanillaStore; diff --git a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Modal.tsx b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Modal.tsx index e6008a3f90..5e6ddedd4b 100644 --- a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Modal.tsx +++ b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Modal.tsx @@ -285,7 +285,11 @@ const SelectMultiple = (props: SelectMultipleProps) => { Select all labels that apply - diff --git a/editor.planx.uk/src/@planx/components/PlanningConstraints/mocks/classifiedRoadsNegativeResponseMock.ts b/editor.planx.uk/src/@planx/components/PlanningConstraints/mocks/classifiedRoadsNegativeResponseMock.ts index 4a51847ec0..6a18b0aac0 100644 --- a/editor.planx.uk/src/@planx/components/PlanningConstraints/mocks/classifiedRoadsNegativeResponseMock.ts +++ b/editor.planx.uk/src/@planx/components/PlanningConstraints/mocks/classifiedRoadsNegativeResponseMock.ts @@ -7,7 +7,7 @@ export default { "road.classified": { name: "Classified road", plural: "Classified roads", - text: "This will effect your project if you are looking to add a dropped kerb. It may also impact some agricultural or forestry projects within 25 metres of a classified road." + text: "This will effect your project if you are looking to add a dropped kerb. It may also impact some agricultural or forestry projects within 25 metres of a classified road.", }, }, constraints: { diff --git a/editor.planx.uk/src/@planx/components/PlanningConstraints/mocks/classifiedRoadsResponseMock.ts b/editor.planx.uk/src/@planx/components/PlanningConstraints/mocks/classifiedRoadsResponseMock.ts index 8296d32838..155d3c782d 100644 --- a/editor.planx.uk/src/@planx/components/PlanningConstraints/mocks/classifiedRoadsResponseMock.ts +++ b/editor.planx.uk/src/@planx/components/PlanningConstraints/mocks/classifiedRoadsResponseMock.ts @@ -7,7 +7,7 @@ export default { "road.classified": { name: "Classified road", plural: "Classified roads", - text: "This will effect your project if you are looking to add a dropped kerb. It may also impact some agricultural or forestry projects within 25 metres of a classified road." + text: "This will effect your project if you are looking to add a dropped kerb. It may also impact some agricultural or forestry projects within 25 metres of a classified road.", }, }, constraints: { diff --git a/editor.planx.uk/src/@planx/components/Section/Editor.tsx b/editor.planx.uk/src/@planx/components/Section/Editor.tsx index da6e3d4ee0..f0f5c13334 100644 --- a/editor.planx.uk/src/@planx/components/Section/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Section/Editor.tsx @@ -28,10 +28,7 @@ function SectionComponent(props: Props) { return (