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/modules/team/service.test.ts b/api.planx.uk/modules/team/service.test.ts index 34d0b4cca3..2fba0d633e 100644 --- a/api.planx.uk/modules/team/service.test.ts +++ b/api.planx.uk/modules/team/service.test.ts @@ -40,7 +40,6 @@ describe("TeamService", () => { getStoreMock.mockReturnValue({ user: { sub: "123", - email: "test@opensystemslab.io", jwt: getJWT({ role: "teamEditor" }), }, }); diff --git a/api.planx.uk/package.json b/api.planx.uk/package.json index c4738f22f4..f1824aeee8 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 09d135ecd8..0999a3f57e 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 @@ -8116,8 +8116,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/.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..788230a062 100644 --- a/e2e/tests/ui-driven/src/context.ts +++ b/e2e/tests/ui-driven/src/context.ts @@ -102,7 +102,7 @@ export async function tearDownTestContext(context: Context) { } } -export function generateAuthenticationToken(userId) { +export function generateAuthenticationToken(userId: string) { assert(process.env.JWT_SECRET); return sign( { 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({ 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 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 (