Skip to content

Commit

Permalink
chore(test): UI tests to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Jan 3, 2025
1 parent 8bb3a9e commit f8cc51f
Show file tree
Hide file tree
Showing 41 changed files with 170 additions and 166 deletions.
2 changes: 1 addition & 1 deletion api.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@airbrake/node": "^2.1.8",
"@aws-sdk/client-s3": "^3.696.0",
"@aws-sdk/s3-request-presigner": "^3.701.0",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#a7ec46d",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#d004278",
"@types/isomorphic-fetch": "^0.0.36",
"adm-zip": "^0.5.10",
"axios": "^1.7.4",
Expand Down
14 changes: 7 additions & 7 deletions api.planx.uk/pnpm-lock.yaml

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

4 changes: 2 additions & 2 deletions api.planx.uk/tests/mockJWT.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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 }) {
Expand Down
5 changes: 2 additions & 3 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -24,6 +22,7 @@
},
"packageManager": "[email protected]",
"devDependencies": {
"@types/jsonwebtoken": "^9.0.7",
"@types/node": "22.10.5",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
Expand Down
9 changes: 9 additions & 0 deletions e2e/pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion e2e/tests/api-driven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"packageManager": "[email protected]",
"dependencies": {
"@cucumber/cucumber": "^11.1.1",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#a7ec46d",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#d004278",
"axios": "^1.7.4",
"dotenv": "^16.3.1",
"dotenv-expand": "^10.0.0",
Expand Down
14 changes: 7 additions & 7 deletions e2e/tests/api-driven/pnpm-lock.yaml

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

4 changes: 2 additions & 2 deletions e2e/tests/api-driven/src/invite-to-pay/mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type {
Node,
} from "@opensystemslab/planx-core/types";
import { ComponentType } from "@opensystemslab/planx-core/types";
import flow from "./flow.json" assert { type: "json" };
import session from "./session.json" assert { type: "json" };
import flow from "./flow.json" with { type: "json" };
import session from "./session.json" with { type: "json" };

export const mockBreadcrumbs = session.data?.breadcrumbs as Breadcrumbs;

Expand Down
9 changes: 0 additions & 9 deletions e2e/tests/api-driven/tsconfig.json

This file was deleted.

5 changes: 3 additions & 2 deletions e2e/tests/ui-driven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
"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",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#d004278",
"axios": "^1.7.4",
"dotenv": "^16.3.1",
"eslint": "^8.56.0",
Expand All @@ -21,7 +22,7 @@
},
"packageManager": "[email protected]",
"devDependencies": {
"@playwright/test": "^1.49.0",
"@playwright/test": "^1.49.1",
"@types/geojson": "^7946.0.14",
"@types/node": "22.10.5",
"eslint-plugin-playwright": "^0.20.0"
Expand Down
34 changes: 17 additions & 17 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.

26 changes: 13 additions & 13 deletions e2e/tests/ui-driven/src/create-flow-with-geospatial.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@ 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,
checkUploadFileAltRoute,
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 = {
Expand Down
18 changes: 9 additions & 9 deletions e2e/tests/ui-driven/src/create-flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 = {
Expand Down
8 changes: 4 additions & 4 deletions e2e/tests/ui-driven/src/helpers/addComponent.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Loading

0 comments on commit f8cc51f

Please sign in to comment.