diff --git a/api.planx.uk/tests/mockJWT.ts b/api.planx.uk/tests/mockJWT.ts index 6ee27a35e4..817c28313e 100644 --- a/api.planx.uk/tests/mockJWT.ts +++ b/api.planx.uk/tests/mockJWT.ts @@ -1,5 +1,5 @@ import type { Role } from "@opensystemslab/planx-core/types"; -import { sign } from "jsonwebtoken"; +import jwt from "jsonwebtoken"; function getJWT({ role }: { role: Role }) { const data = { @@ -12,7 +12,7 @@ function getJWT({ role }: { role: Role }) { }, }; - return sign(data, process.env.JWT_SECRET!); + return jwt.sign(data, process.env.JWT_SECRET!); } function authHeader({ role }: { role: Role }) { diff --git a/e2e/package.json b/e2e/package.json index 3820bbcddc..d9490c3251 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -10,9 +10,7 @@ "test:debug": "DEBUG_LOG=true pnpm test", "lint": "eslint './tests/**/*.{js,ts}' && prettier -c ./tests", "lint:fix": "eslint --fix './tests/**/*.{js,ts}' && prettier -w ./tests", - "check": "pnpm check:api && pnpm check:ui && pnpm lint", - "check:api": "tsc --project './tests/api-driven/tsconfig.json' && pnpm lint", - "check:ui": "tsc --project './tests/ui-driven/tsconfig.json' && pnpm lint", + "check": "tsc && pnpm lint", "postinstall": "cd tests/ui-driven && pnpm install && cd ../api-driven && pnpm install", "prepare": "cd .. && husky install e2e/.husky" }, @@ -24,6 +22,7 @@ }, "packageManager": "pnpm@8.6.6", "devDependencies": { + "@types/jsonwebtoken": "^9.0.7", "@types/node": "18.16.1", "@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/parser": "^5.62.0", diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index b5bd54c146..b00ad12407 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -5,6 +5,9 @@ settings: excludeLinksFromLockfile: false devDependencies: + '@types/jsonwebtoken': + specifier: ^9.0.7 + version: 9.0.7 '@types/node': specifier: 18.16.1 version: 18.16.1 @@ -116,6 +119,12 @@ packages: resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} dev: true + /@types/jsonwebtoken@9.0.7: + resolution: {integrity: sha512-ugo316mmTYBl2g81zDFnZ7cfxlut3o+/EQdaP7J8QN2kY6lJ22hmQYCK5EHcJHbrW+dkCGSCPgbG8JtYj6qSrg==} + dependencies: + '@types/node': 18.16.1 + dev: true + /@types/node@18.16.1: resolution: {integrity: sha512-DZxSZWXxFfOlx7k7Rv4LAyiMroaxa3Ly/7OOzZO8cBNho0YzAi4qlbrx8W27JGqG57IgR/6J7r+nOJWw6kcvZA==} dev: true diff --git a/e2e/tests/api-driven/tsconfig.json b/e2e/tests/api-driven/tsconfig.json deleted file mode 100644 index 7bdfe43277..0000000000 --- a/e2e/tests/api-driven/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "lib": ["DOM", "ESNext"], - "module": "NodeNext", - "moduleResolution": "nodenext", - "rootDir": "./src" - } -} diff --git a/e2e/tests/ui-driven/package.json b/e2e/tests/ui-driven/package.json index ec73d7c1b8..1ff2594b1d 100644 --- a/e2e/tests/ui-driven/package.json +++ b/e2e/tests/ui-driven/package.json @@ -7,6 +7,7 @@ "ui": "serve ../../../editor.planx.uk/build --single --listen 3000", "postinstall": "./install-dependencies.sh" }, + "type": "module", "dependencies": { "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#a7ec46d", "axios": "^1.7.4", @@ -21,7 +22,7 @@ }, "packageManager": "pnpm@8.6.6", "devDependencies": { - "@playwright/test": "^1.49.0", + "@playwright/test": "^1.49.1", "@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 eca1ba4a33..e647701068 100644 --- a/e2e/tests/ui-driven/pnpm-lock.yaml +++ b/e2e/tests/ui-driven/pnpm-lock.yaml @@ -38,8 +38,8 @@ dependencies: devDependencies: '@playwright/test': - specifier: ^1.49.0 - version: 1.49.0 + specifier: ^1.49.1 + version: 1.49.1 '@types/geojson': specifier: ^7946.0.14 version: 7946.0.14 @@ -639,12 +639,12 @@ packages: '@nodelib/fs.scandir': 2.1.5 fastq: 1.17.1 - /@playwright/test@1.49.0: - resolution: {integrity: sha512-DMulbwQURa8rNIQrf94+jPJQ4FmOVdpE5ZppRNvWVjvhC+6sOeo28r8MgIpQRYouXRtt/FCCXU7zn20jnHR4Qw==} + /@playwright/test@1.49.1: + resolution: {integrity: sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g==} engines: {node: '>=18'} hasBin: true dependencies: - playwright: 1.49.0 + playwright: 1.49.1 dev: true /@popperjs/core@2.11.8: @@ -2060,18 +2060,18 @@ packages: engines: {node: '>=12'} dev: false - /playwright-core@1.49.0: - resolution: {integrity: sha512-R+3KKTQF3npy5GTiKH/T+kdhoJfJojjHESR1YEWhYuEKRVfVaxH3+4+GvXE5xyCngCxhxnykk0Vlah9v8fs3jA==} + /playwright-core@1.49.1: + resolution: {integrity: sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg==} engines: {node: '>=18'} hasBin: true dev: true - /playwright@1.49.0: - resolution: {integrity: sha512-eKpmys0UFDnfNb3vfsf8Vx2LEOtflgRebl0Im2eQQnYMA4Aqd+Zw8bEOB+7ZKvN76901mRnqdsiOGKxzVTbi7A==} + /playwright@1.49.1: + resolution: {integrity: sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA==} engines: {node: '>=18'} hasBin: true dependencies: - playwright-core: 1.49.0 + playwright-core: 1.49.1 optionalDependencies: fsevents: 2.3.2 dev: true 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 16b46b755e..0472dd2352 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 @@ -3,18 +3,18 @@ import { contextDefaults, setUpTestContext, tearDownTestContext, -} from "./helpers/context"; -import { getTeamPage } from "./helpers/getPage"; -import { createAuthenticatedSession } from "./helpers/globalHelpers"; -import { answerQuestion, clickContinue } from "./helpers/userActions"; -import { PlaywrightEditor } from "./pages/Editor"; +} from "./helpers/context.js"; +import { getTeamPage } from "./helpers/getPage.js"; +import { createAuthenticatedSession } from "./helpers/globalHelpers.js"; +import { answerQuestion, clickContinue } from "./helpers/userActions.js"; +import { PlaywrightEditor } from "./pages/Editor.js"; import { navigateToService, publishService, turnServiceOnline, -} from "./helpers/navigateAndPublish"; -import { TestContext } from "./helpers/types"; -import { serviceProps } from "./helpers/serviceData"; +} from "./helpers/navigateAndPublish.js"; +import { TestContext } from "./helpers/types.js"; +import { serviceProps } from "./helpers/serviceData.js"; import { alterDrawGeoJson, checkGeoJsonContent, @@ -22,26 +22,26 @@ import { getMapProperties, resetMapBoundary, waitForMapComponent, -} from "./helpers/geospatialChecks"; +} from "./helpers/geospatialChecks.js"; import { GeoJsonChangeHandler, mockChangedMapGeoJson, mockPropertyTypeOptions, mockTitleBoundaryGeoJson, -} from "./mocks/geospatialMocks"; +} from "./mocks/geospatialMocks.js"; import { setupOSMapsStyles, setupOSMapsVectorTiles, -} from "./mocks/osMapsResponse"; +} from "./mocks/osMapsResponse.js"; import { planningConstraintHeadersMock, setupGISMockResponse, setupRoadsMockResponse, -} from "./mocks/gisResponse"; +} from "./mocks/gisResponse.js"; import { answerFindProperty, userChallengesPlanningConstraint, -} from "./helpers/geoSpatialUserActions"; +} from "./helpers/geoSpatialUserActions.js"; test.describe("Flow creation, publish and preview", () => { let context: TestContext = { diff --git a/e2e/tests/ui-driven/src/create-flow.spec.ts b/e2e/tests/ui-driven/src/create-flow.spec.ts index 921e2a54a9..393b77c468 100644 --- a/e2e/tests/ui-driven/src/create-flow.spec.ts +++ b/e2e/tests/ui-driven/src/create-flow.spec.ts @@ -3,13 +3,13 @@ import { contextDefaults, setUpTestContext, tearDownTestContext, -} from "./helpers/context"; -import { getTeamPage } from "./helpers/getPage"; +} from "./helpers/context.js"; +import { getTeamPage } from "./helpers/getPage.js"; import { createAuthenticatedSession, filterFlags, selectedFlag, -} from "./helpers/globalHelpers"; +} from "./helpers/globalHelpers.js"; import { answerAddressInput, answerChecklist, @@ -20,19 +20,19 @@ import { answerQuestion, answerTextInput, clickContinue, -} from "./helpers/userActions"; -import { PlaywrightEditor } from "./pages/Editor"; -import { createExternalPortal } from "./helpers/addComponent"; +} from "./helpers/userActions.js"; +import { PlaywrightEditor } from "./pages/Editor.js"; +import { createExternalPortal } from "./helpers/addComponent.js"; import { navigateToService, publishService, turnServiceOnline, -} from "./helpers/navigateAndPublish"; -import { TestContext } from "./helpers/types"; +} from "./helpers/navigateAndPublish.js"; +import { TestContext } from "./helpers/types.js"; import { externalPortalFlowData, externalPortalServiceProps, -} from "./helpers/serviceData"; +} from "./helpers/serviceData.js"; test.describe("Flow creation, publish and preview", () => { let context: TestContext = { diff --git a/e2e/tests/ui-driven/src/helpers/addComponent.ts b/e2e/tests/ui-driven/src/helpers/addComponent.ts index 7f9c6f10b3..7ce6000c9d 100644 --- a/e2e/tests/ui-driven/src/helpers/addComponent.ts +++ b/e2e/tests/ui-driven/src/helpers/addComponent.ts @@ -1,9 +1,9 @@ import { ComponentType } from "@opensystemslab/planx-core/types"; import { expect, Locator, Page } from "@playwright/test"; -import { contextDefaults } from "./context"; -import { externalPortalServiceProps } from "./serviceData"; -import { OptionWithDataValues } from "./types"; -import { selectedFlag } from "./globalHelpers"; +import { contextDefaults } from "./context.js"; +import { externalPortalServiceProps } from "./serviceData.js"; +import { OptionWithDataValues } from "./types.js"; +import { selectedFlag } from "./globalHelpers.js"; const createBaseComponent = async ( page: Page, diff --git a/e2e/tests/ui-driven/src/helpers/context.ts b/e2e/tests/ui-driven/src/helpers/context.ts index 393895a384..7e5597119b 100644 --- a/e2e/tests/ui-driven/src/helpers/context.ts +++ b/e2e/tests/ui-driven/src/helpers/context.ts @@ -1,8 +1,8 @@ import { CoreDomainClient } from "@opensystemslab/planx-core"; import { GraphQLClient, gql } from "graphql-request"; -import { sign } from "jsonwebtoken"; +import jwt from "jsonwebtoken"; import assert from "node:assert"; -import { TestContext } from "./types"; +import { TestContext } from "./types.js"; export const contextDefaults: TestContext = { user: { @@ -107,7 +107,7 @@ export async function tearDownTestContext() { export function generateAuthenticationToken(userId: string) { assert(process.env.JWT_SECRET); - return sign( + return jwt.sign( { sub: `${userId}`, "https://hasura.io/jwt/claims": { diff --git a/e2e/tests/ui-driven/src/helpers/geoSpatialUserActions.ts b/e2e/tests/ui-driven/src/helpers/geoSpatialUserActions.ts index aea7a7b2a4..0cba81707d 100644 --- a/e2e/tests/ui-driven/src/helpers/geoSpatialUserActions.ts +++ b/e2e/tests/ui-driven/src/helpers/geoSpatialUserActions.ts @@ -1,5 +1,5 @@ import { expect, Page } from "@playwright/test"; -import { setupOSMockResponse } from "../mocks/osPlacesResponse"; +import { setupOSMockResponse } from "../mocks/osPlacesResponse.js"; export async function answerFindProperty(page: Page) { await setupOSMockResponse(page); diff --git a/e2e/tests/ui-driven/src/helpers/getPage.ts b/e2e/tests/ui-driven/src/helpers/getPage.ts index 8d9880c12e..badee7bf4a 100644 --- a/e2e/tests/ui-driven/src/helpers/getPage.ts +++ b/e2e/tests/ui-driven/src/helpers/getPage.ts @@ -1,5 +1,5 @@ import { Browser, Page } from "@playwright/test"; -import { createAuthenticatedSession } from "./globalHelpers"; +import { createAuthenticatedSession } from "./globalHelpers.js"; export async function getAdminPage({ browser, diff --git a/e2e/tests/ui-driven/src/helpers/globalHelpers.ts b/e2e/tests/ui-driven/src/helpers/globalHelpers.ts index ec39631eae..da1cda6858 100644 --- a/e2e/tests/ui-driven/src/helpers/globalHelpers.ts +++ b/e2e/tests/ui-driven/src/helpers/globalHelpers.ts @@ -1,8 +1,8 @@ import { FlowGraph } from "@opensystemslab/planx-core/types"; import { type Browser, type Page, type Request } from "@playwright/test"; import { gql } from "graphql-request"; -import { generateAuthenticationToken, getGraphQLClient } from "./context"; -import { TestContext } from "./types"; +import { generateAuthenticationToken, getGraphQLClient } from "./context.js"; +import { TestContext } from "./types.js"; import { flatFlags } from "@opensystemslab/planx-core/types"; // Test card numbers to be used in gov.uk sandbox environment diff --git a/e2e/tests/ui-driven/src/helpers/navigateAndPublish.ts b/e2e/tests/ui-driven/src/helpers/navigateAndPublish.ts index d5d66138fa..595c8b284a 100644 --- a/e2e/tests/ui-driven/src/helpers/navigateAndPublish.ts +++ b/e2e/tests/ui-driven/src/helpers/navigateAndPublish.ts @@ -1,5 +1,5 @@ import { expect, Page } from "@playwright/test"; -import { contextDefaults } from "./context"; +import { contextDefaults } from "./context.js"; export const navigateToService = async (page: Page, slug: string) => { await page.goto(`/${contextDefaults.team.slug}/${slug}`); diff --git a/e2e/tests/ui-driven/src/helpers/types.ts b/e2e/tests/ui-driven/src/helpers/types.ts index b76bb5dd9e..1557052c59 100644 --- a/e2e/tests/ui-driven/src/helpers/types.ts +++ b/e2e/tests/ui-driven/src/helpers/types.ts @@ -1,5 +1,5 @@ import { CoreDomainClient } from "@opensystemslab/planx-core"; -import { User } from "@opensystemslab/planx-core/dist/types"; +import { User } from "@opensystemslab/planx-core/types"; type NewTeam = Parameters[0]; diff --git a/e2e/tests/ui-driven/src/helpers/userActions.ts b/e2e/tests/ui-driven/src/helpers/userActions.ts index 6229183c02..fe7306ae06 100644 --- a/e2e/tests/ui-driven/src/helpers/userActions.ts +++ b/e2e/tests/ui-driven/src/helpers/userActions.ts @@ -1,8 +1,8 @@ import type { Locator, Page } from "@playwright/test"; import { expect } from "@playwright/test"; -import { findSessionId, getGraphQLClient } from "./context"; -import { TEST_EMAIL, log, waitForDebugLog } from "./globalHelpers"; -import { TestContext } from "./types"; +import { findSessionId, getGraphQLClient } from "./context.js"; +import { TEST_EMAIL, log, waitForDebugLog } from "./globalHelpers.js"; +import { TestContext } from "./types.js"; export async function saveSession({ page, diff --git a/e2e/tests/ui-driven/src/invite-to-pay/agent.spec.ts b/e2e/tests/ui-driven/src/invite-to-pay/agent.spec.ts index b0c889b288..e7a33ba1d6 100644 --- a/e2e/tests/ui-driven/src/invite-to-pay/agent.spec.ts +++ b/e2e/tests/ui-driven/src/invite-to-pay/agent.spec.ts @@ -4,22 +4,22 @@ import { getGraphQLClient, setUpTestContext, tearDownTestContext, -} from "../helpers/context"; -import { addSessionToContext, modifyFlow } from "../helpers/globalHelpers"; +} from "../helpers/context.js"; +import { addSessionToContext, modifyFlow } from "../helpers/globalHelpers.js"; import { clickContinue, returnToSession, saveSession, -} from "../helpers/userActions"; -import inviteToPayFlow from "../mocks/flows/invite-to-pay-flow"; +} from "../helpers/userActions.js"; +import inviteToPayFlow from "../mocks/flows/invite-to-pay-flow.js"; import { answerInviteToPayForm, getPaymentRequestBySessionId, makePaymentRequest, navigateToPayComponent, -} from "./helpers"; -import { mockPaymentRequest, modifiedInviteToPayFlow } from "./mocks"; -import { TestContext } from "../helpers/types"; +} from "./helpers.js"; +import { mockPaymentRequest, modifiedInviteToPayFlow } from "./mocks.js"; +import { TestContext } from "../helpers/types.js"; let context: TestContext = { ...contextDefaults, diff --git a/e2e/tests/ui-driven/src/invite-to-pay/helpers.ts b/e2e/tests/ui-driven/src/invite-to-pay/helpers.ts index 0d29aac6a9..dd6004325a 100644 --- a/e2e/tests/ui-driven/src/invite-to-pay/helpers.ts +++ b/e2e/tests/ui-driven/src/invite-to-pay/helpers.ts @@ -1,14 +1,18 @@ -import { PaymentRequest } from "@opensystemslab/planx-core/dist/types"; +import { PaymentRequest } from "@opensystemslab/planx-core/types"; import { expect, type Page } from "@playwright/test"; import { GraphQLClient, gql } from "graphql-request"; -import { TEST_EMAIL, addSessionToContext, log } from "../helpers/globalHelpers"; +import { + TEST_EMAIL, + addSessionToContext, + log, +} from "../helpers/globalHelpers.js"; import { answerChecklist, answerContactInput, fillInEmail, -} from "../helpers/userActions"; -import { TestContext } from "../helpers/types"; -import { answerFindProperty } from "../helpers/geoSpatialUserActions"; +} from "../helpers/userActions.js"; +import { TestContext } from "../helpers/types.js"; +import { answerFindProperty } from "../helpers/geoSpatialUserActions.js"; /** * Navigates to pay component whilst completing the minimum requirements for an Invite to Pay flow diff --git a/e2e/tests/ui-driven/src/invite-to-pay/mocks.ts b/e2e/tests/ui-driven/src/invite-to-pay/mocks.ts index 4cbc0a5beb..2c35ea86a9 100644 --- a/e2e/tests/ui-driven/src/invite-to-pay/mocks.ts +++ b/e2e/tests/ui-driven/src/invite-to-pay/mocks.ts @@ -4,8 +4,8 @@ import { PaymentRequest, SessionData, } from "@opensystemslab/planx-core/types"; -import { TEST_EMAIL } from "../helpers/globalHelpers"; -import inviteToPayFlow from "../mocks/flows/invite-to-pay-flow"; +import { TEST_EMAIL } from "../helpers/globalHelpers.js"; +import inviteToPayFlow from "../mocks/flows/invite-to-pay-flow.js"; export const mockPaymentRequest: Partial = { payeeEmail: TEST_EMAIL, diff --git a/e2e/tests/ui-driven/src/invite-to-pay/nominee.spec.ts b/e2e/tests/ui-driven/src/invite-to-pay/nominee.spec.ts index 387c288aec..6e6259b783 100644 --- a/e2e/tests/ui-driven/src/invite-to-pay/nominee.spec.ts +++ b/e2e/tests/ui-driven/src/invite-to-pay/nominee.spec.ts @@ -7,13 +7,13 @@ import { getGraphQLClient, setUpTestContext, tearDownTestContext, -} from "../helpers/context"; -import { cards, setFeatureFlag } from "../helpers/globalHelpers"; -import { fillGovUkCardDetails } from "../helpers/userActions"; -import inviteToPayFlow from "../mocks/flows/invite-to-pay-flow"; -import { getPaymentRequestBySessionId } from "./helpers"; -import { mockPaymentRequestDetails, mockSessionData } from "./mocks"; -import { TestContext } from "../helpers/types"; +} from "../helpers/context.js"; +import { cards, setFeatureFlag } from "../helpers/globalHelpers.js"; +import { fillGovUkCardDetails } from "../helpers/userActions.js"; +import inviteToPayFlow from "../mocks/flows/invite-to-pay-flow.js"; +import { getPaymentRequestBySessionId } from "./helpers.js"; +import { mockPaymentRequestDetails, mockSessionData } from "./mocks.js"; +import { TestContext } from "../helpers/types.js"; let context: TestContext = { ...contextDefaults, diff --git a/e2e/tests/ui-driven/src/login.spec.ts b/e2e/tests/ui-driven/src/login.spec.ts index 083c1897de..72a4851045 100644 --- a/e2e/tests/ui-driven/src/login.spec.ts +++ b/e2e/tests/ui-driven/src/login.spec.ts @@ -3,9 +3,9 @@ import { contextDefaults, setUpTestContext, tearDownTestContext, -} from "./helpers/context"; -import { createAuthenticatedSession } from "./helpers/globalHelpers"; -import { TestContext } from "./helpers/types"; +} from "./helpers/context.js"; +import { createAuthenticatedSession } from "./helpers/globalHelpers.js"; +import { TestContext } from "./helpers/types.js"; test.describe("Login", () => { let context: TestContext = { diff --git a/e2e/tests/ui-driven/src/mocks/geospatialMocks.ts b/e2e/tests/ui-driven/src/mocks/geospatialMocks.ts index 5354e94101..80b3d629e2 100644 --- a/e2e/tests/ui-driven/src/mocks/geospatialMocks.ts +++ b/e2e/tests/ui-driven/src/mocks/geospatialMocks.ts @@ -1,4 +1,4 @@ -import { OptionWithDataValues } from "../helpers/types"; +import { OptionWithDataValues } from "../helpers/types.js"; import { Feature, Polygon } from "geojson"; type ChangeHandlerProperties = { diff --git a/e2e/tests/ui-driven/src/mocks/gisResponse.ts b/e2e/tests/ui-driven/src/mocks/gisResponse.ts index 2fe8215041..a777094ef8 100644 --- a/e2e/tests/ui-driven/src/mocks/gisResponse.ts +++ b/e2e/tests/ui-driven/src/mocks/gisResponse.ts @@ -1,6 +1,6 @@ import { expect, Page } from "@playwright/test"; -import { mockRoadData } from "./geospatialMocks"; -import propertyConstraintsResponse from "./propertyConstraintResponse.json"; +import { mockRoadData } from "./geospatialMocks.js"; +import propertyConstraintsResponse from "./propertyConstraintResponse.json" with { type: "json" }; export async function setupGISMockResponse(page: Page) { const gisDigitalLandEndpoint = "**/gis/E2E?geom*"; diff --git a/e2e/tests/ui-driven/src/mocks/osMapsResponse.ts b/e2e/tests/ui-driven/src/mocks/osMapsResponse.ts index ccd6f6de6f..bb096bba59 100644 --- a/e2e/tests/ui-driven/src/mocks/osMapsResponse.ts +++ b/e2e/tests/ui-driven/src/mocks/osMapsResponse.ts @@ -1,5 +1,5 @@ import { Page } from "@playwright/test"; -import { osMapsStylesResponse } from "./osMapsMockData"; +import { osMapsStylesResponse } from "./osMapsMockData.js"; export async function setupOSMapsStyles(page: Page) { const ordnanceSurveyMapsStyles = new RegExp( diff --git a/e2e/tests/ui-driven/src/pages/Editor.ts b/e2e/tests/ui-driven/src/pages/Editor.ts index 779304e23d..774665b31f 100644 --- a/e2e/tests/ui-driven/src/pages/Editor.ts +++ b/e2e/tests/ui-driven/src/pages/Editor.ts @@ -28,9 +28,9 @@ import { createTaskList, createTextInput, createUploadAndLabel, -} from "../helpers/addComponent"; -import { OptionWithDataValues } from "../helpers/types"; -import { selectedFlag } from "../helpers/globalHelpers"; +} from "../helpers/addComponent.js"; +import { OptionWithDataValues } from "../helpers/types.js"; +import { selectedFlag } from "../helpers/globalHelpers.js"; export class PlaywrightEditor { readonly page: Page; diff --git a/e2e/tests/ui-driven/src/pay.spec.ts b/e2e/tests/ui-driven/src/pay.spec.ts index e33509d03d..7a2c2f09d7 100644 --- a/e2e/tests/ui-driven/src/pay.spec.ts +++ b/e2e/tests/ui-driven/src/pay.spec.ts @@ -7,16 +7,19 @@ import { getGraphQLClient, setUpTestContext, tearDownTestContext, -} from "./helpers/context"; +} from "./helpers/context.js"; import { cards, getSessionId, log, waitForPaymentResponse, -} from "./helpers/globalHelpers"; -import { fillGovUkCardDetails, submitCardDetails } from "./helpers/userActions"; -import payFlow from "./mocks/flows/pay-flow.json"; -import { TestContext } from "./helpers/types"; +} from "./helpers/globalHelpers.js"; +import { + fillGovUkCardDetails, + submitCardDetails, +} from "./helpers/userActions.js"; +import payFlow from "./mocks/flows/pay-flow.json" with { type: "json" }; +import { TestContext } from "./helpers/types.js"; let context: TestContext = { ...contextDefaults, diff --git a/e2e/tests/ui-driven/src/refresh-page.spec.ts b/e2e/tests/ui-driven/src/refresh-page.spec.ts index 744696fe77..92c87fa5c1 100644 --- a/e2e/tests/ui-driven/src/refresh-page.spec.ts +++ b/e2e/tests/ui-driven/src/refresh-page.spec.ts @@ -3,12 +3,12 @@ import { contextDefaults, setUpTestContext, tearDownTestContext, -} from "./helpers/context"; +} from "./helpers/context.js"; import { createAuthenticatedSession, isGetUserRequest, -} from "./helpers/globalHelpers"; -import { TestContext } from "./helpers/types"; +} from "./helpers/globalHelpers.js"; +import { TestContext } from "./helpers/types.js"; test.describe("Refresh page", () => { let context: TestContext = { diff --git a/e2e/tests/ui-driven/src/save-and-return.spec.ts b/e2e/tests/ui-driven/src/save-and-return.spec.ts index d84cdda237..4d2f8ee609 100644 --- a/e2e/tests/ui-driven/src/save-and-return.spec.ts +++ b/e2e/tests/ui-driven/src/save-and-return.spec.ts @@ -3,8 +3,8 @@ import { contextDefaults, setUpTestContext, tearDownTestContext, -} from "./helpers/context"; -import { modifyFlow } from "./helpers/globalHelpers"; +} from "./helpers/context.js"; +import { modifyFlow } from "./helpers/globalHelpers.js"; import { answerQuestion, clickContinue, @@ -12,12 +12,12 @@ import { findQuestion, returnToSession, saveSession, -} from "./helpers/userActions"; +} from "./helpers/userActions.js"; import { modifiedSimpleSendFlow, simpleSendFlow, -} from "./mocks/flows/save-and-return-flows"; -import { TestContext } from "./helpers/types"; +} from "./mocks/flows/save-and-return-flows.js"; +import { TestContext } from "./helpers/types.js"; test.describe("Save and return", () => { let context: TestContext = { diff --git a/e2e/tests/ui-driven/src/sections.spec.ts b/e2e/tests/ui-driven/src/sections.spec.ts index b321506214..da0509ee22 100644 --- a/e2e/tests/ui-driven/src/sections.spec.ts +++ b/e2e/tests/ui-driven/src/sections.spec.ts @@ -6,7 +6,7 @@ import { getGraphQLClient, setUpTestContext, tearDownTestContext, -} from "./helpers/context"; +} from "./helpers/context.js"; import { answerChecklist, answerQuestion, @@ -18,9 +18,9 @@ import { fillInEmail, returnToSession, saveSession, -} from "./helpers/userActions"; -import { flow, updatedQuestionAnswers } from "./mocks/flows/sections-flow"; -import { TestContext } from "./helpers/types"; +} from "./helpers/userActions.js"; +import { flow, updatedQuestionAnswers } from "./mocks/flows/sections-flow.js"; +import { TestContext } from "./helpers/types.js"; // TODO: move this type to planx-core // also defined in editor.planx.uk/src/types.ts diff --git a/e2e/tests/ui-driven/src/utils.ts b/e2e/tests/ui-driven/src/utils.ts index 6e6036fc51..eae0550c37 100644 --- a/e2e/tests/ui-driven/src/utils.ts +++ b/e2e/tests/ui-driven/src/utils.ts @@ -1,4 +1,4 @@ -import { sign } from "jsonwebtoken"; +import jwt from "jsonwebtoken"; import Axios from "axios"; export const gqlAdmin = async (query, variables = {}) => { @@ -35,7 +35,7 @@ export const getJWT = (userId) => { }, }; - return sign(data, process.env.JWT_SECRET); + return jwt.sign(data, process.env.JWT_SECRET!); }; export const insertTeam = async (teamName) => { diff --git a/e2e/tests/ui-driven/tsconfig.json b/e2e/tests/ui-driven/tsconfig.json deleted file mode 100644 index bccc94946c..0000000000 --- a/e2e/tests/ui-driven/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "rootDir": "." - } -} diff --git a/e2e/tsconfig.json b/e2e/tsconfig.json index 5f38a96607..62e62a58fd 100644 --- a/e2e/tsconfig.json +++ b/e2e/tsconfig.json @@ -3,16 +3,19 @@ "allowJs": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, - "lib": ["ES2021", "DOM"], - "module": "commonjs", - "moduleResolution": "node", "resolveJsonModule": true, "rootDir": "tests", "skipLibCheck": true, "strict": true, "noImplicitAny": false, "target": "es2021", - "noEmit": true + "noEmit": true, + "lib": [ + "DOM", + "ESNext" + ], + "module": "NodeNext", + "moduleResolution": "nodenext", }, "exclude": ["node_modules"] }