Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production deploy #3609

Merged
merged 40 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
aa6ecf7
[skip pizza] Bump micromatch from 4.0.7 to 4.0.8 in /hasura.planx.uk/…
dependabot[bot] Aug 27, 2024
bad5a37
test: Basic tests describing the "search" feature (#3566)
DafyddLlyr Aug 27, 2024
0d83c4d
test: Setup axios mocks in outstanding frontend tests (#3567)
DafyddLlyr Aug 27, 2024
7bbd1c0
feat: setup MapAndLabel with React Context and schema input fields pe…
jessicamcinchak Aug 27, 2024
effb072
feat: display static map for inactive List "map" fields (#3568)
jessicamcinchak Aug 27, 2024
5c486cc
fix: add submission_email to team_settings seed script (#3571)
RODO94 Aug 27, 2024
f3036b9
fix: submission_email being populated from PROD (#3575)
RODO94 Aug 27, 2024
8ea145a
fix: Pass along missing `variant` prop [skip pizza] (#3574)
DafyddLlyr Aug 27, 2024
68a7ca9
refactor: Move refresh button to browser preview (#3573)
ianjon3s Aug 27, 2024
0b6b010
feat: add new editor - error handling and enhancements (#3543)
jamdelion Aug 28, 2024
f5323c9
feat: Submission Form added to General Settings (#3570)
RODO94 Aug 28, 2024
44656c2
chore: update Metabase to v0.50.22 (#3579)
zz-hh-aa Aug 28, 2024
c4b3bf4
chore: Use vite to build Storybook (#3581)
DafyddLlyr Aug 28, 2024
6e40f0c
refactor: Move editor console to tab (#3578)
ianjon3s Aug 28, 2024
6806573
feat: Setup types for search data facets (#3576)
DafyddLlyr Aug 28, 2024
065d238
feat: setup Satellite basemap selection in MapAndLabel editor (#3572)
jessicamcinchak Aug 28, 2024
75c620c
chore: Bump Storybook dependencies to v8 (#3584)
DafyddLlyr Aug 28, 2024
3110a90
feat: Setup Storybook for `MapAndLabel` (#3585)
DafyddLlyr Aug 28, 2024
3984823
[api] migrate testing framework (Jest > Vitest) (#3555)
freemvmt Aug 29, 2024
8699984
test(api): Add autoUpdate flag to API Vitest config (#3586)
DafyddLlyr Aug 29, 2024
f484485
test(api): Setup eslint-plugin-vite (#3587)
DafyddLlyr Aug 29, 2024
a9eabfd
chore: upgrade to `@opensystemslab/map@next` v1.0.0-alpha.1 (#3590)
jessicamcinchak Aug 29, 2024
4ee2410
chore: add basic UI components for Map & Label "remove" & "copy from"…
jessicamcinchak Aug 29, 2024
c4a80d5
feat: Editor console JSON formatting (#3583)
ianjon3s Aug 29, 2024
4cb61ad
style: Simplify editor sidebar tabs (#3591)
ianjon3s Aug 29, 2024
13326ff
chore: Add `--open` flag to vite in dev mode (#3599)
DafyddLlyr Aug 30, 2024
9056408
fix(map-and-label): Add spacing between schema fields (#3596)
DafyddLlyr Aug 30, 2024
f3948d8
fix: Tidy up `Node.tsx` (#3598)
DafyddLlyr Aug 30, 2024
b27369d
feat: API changes for handling new `submission_email` location (#3582)
RODO94 Aug 30, 2024
ee0f513
fix: Expandable checklists (#3597)
DafyddLlyr Aug 30, 2024
c9ac9c6
feat: Basic validation for `MapAndLabel` (#3589)
DafyddLlyr Aug 30, 2024
38779d2
chore: Update MapAndLabel root error messages (#3600)
DafyddLlyr Aug 30, 2024
35191d4
feat(map-and-label): Better tab error styling (#3602)
DafyddLlyr Aug 30, 2024
b7545a2
feat(map-and-label): Copy feature (#3594)
DafyddLlyr Aug 30, 2024
4c13508
feat: Style 'Plot a feature...' text (#3603)
DafyddLlyr Aug 30, 2024
1c2382a
chore(deps): bump jsdom from 24.1.0 to 25.0.0 in /sharedb.planx.uk (#…
dependabot[bot] Sep 2, 2024
b888daa
tidy: release add Team Editor feature (#3580)
jamdelion Sep 2, 2024
c342bb1
fix: handle no existing team members case when adding a new editor (#…
jamdelion Sep 2, 2024
f242545
Revert "feat: API changes for handling new `submission_email` locatio…
DafyddLlyr Sep 2, 2024
bc75023
refactor: add useToast hook for toast notifications (#3593)
jamdelion Sep 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ jobs:
VITE_APP_API_URL: https://api.${{ env.FULL_DOMAIN }}
VITE_APP_HASURA_URL: https://hasura.${{ env.FULL_DOMAIN }}/v1/graphql
VITE_APP_HASURA_WEBSOCKET: wss://hasura.${{ env.FULL_DOMAIN }}/v1/graphql
VITE_APP_MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
VITE_APP_SHAREDB_URL: wss://sharedb.${{ env.FULL_DOMAIN }}
# needed because there's no API to change google's allowed OAuth URLs
VITE_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev
Expand All @@ -226,6 +227,7 @@ jobs:
VITE_APP_API_URL: https://api.${{ env.FULL_DOMAIN }}
VITE_APP_HASURA_URL: https://hasura.${{ env.FULL_DOMAIN }}/v1/graphql
VITE_APP_HASURA_WEBSOCKET: wss://hasura.${{ env.FULL_DOMAIN }}/v1/graphql
VITE_APP_MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
VITE_APP_SHAREDB_URL: wss://sharedb.${{ env.FULL_DOMAIN }}
VITE_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev
VITE_APP_ENV: pizza
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/push-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ jobs:
- run: pnpm build
working-directory: editor.planx.uk
env:
VITE_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }}
VITE_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }}
VITE_APP_API_URL: https://api.editor.planx.dev
VITE_APP_ENV: staging
VITE_APP_HASURA_URL: https://hasura.editor.planx.dev/v1/graphql
VITE_APP_MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
VITE_APP_HASURA_WEBSOCKET: wss://hasura.editor.planx.dev/v1/graphql
VITE_APP_SHAREDB_URL: wss://sharedb.editor.planx.dev
VITE_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }}
VITE_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }}
VITE_APP_ENV: staging
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/push-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ jobs:
- run: pnpm build
working-directory: editor.planx.uk
env:
VITE_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }}
VITE_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }}
VITE_APP_API_URL: https://api.editor.planx.uk
VITE_APP_ENV: production
VITE_APP_HASURA_URL: https://hasura.editor.planx.uk/v1/graphql
VITE_APP_HASURA_WEBSOCKET: wss://hasura.editor.planx.uk/v1/graphql
VITE_APP_MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
VITE_APP_SHAREDB_URL: wss://sharedb.editor.planx.uk
VITE_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }}
VITE_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }}
VITE_APP_ENV: production
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ editor.planx.uk/.eslintcache
.env.prod
.env.temp
api.planx.uk/.env.test
editor.planx.uk/.env
hasura.planx.uk/.env.test

# IDE
Expand Down
12 changes: 6 additions & 6 deletions api.planx.uk/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "jest"],
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:jest/recommended"
"plugin:@vitest/legacy-recommended"
],
"rules": {
"@typescript-eslint/no-explicit-any": "warn",
Expand All @@ -18,7 +18,8 @@
}
],
"@typescript-eslint/no-non-null-assertion": "off",
"jest/expect-expect": [
"no-nested-ternary": "error",
"@vitest/expect-expect": [
"error",
{
"assertFunctionNames": [
Expand All @@ -29,8 +30,7 @@
"supertest.**.expect"
]
}
],
"no-nested-ternary": "error"
]
},
"globals": {
"require": "readonly",
Expand All @@ -44,7 +44,7 @@
"URLSearchParams": "readonly",
"exports": "readonly",
"fetch": "readonly",
"jest": "readonly",
"vi": "readonly",
"test": "readonly",
"describe": "readonly",
"it": "readonly",
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/client/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test("getClient() throws an error if a store is not set", () => {
});

test("getClient() returns a client if store is set", () => {
const getStoreMock = jest.spyOn(userContext, "getStore");
const getStoreMock = vi.spyOn(userContext, "getStore");
getStoreMock.mockReturnValue({
user: {
sub: "123",
Expand Down
49 changes: 0 additions & 49 deletions api.planx.uk/jest.config.ts

This file was deleted.

11 changes: 0 additions & 11 deletions api.planx.uk/jest.setup.js

This file was deleted.

58 changes: 33 additions & 25 deletions api.planx.uk/lib/hasura/metadata/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
import { createScheduledEvent, RequiredScheduledEventArgs } from "./index.js";
import Axios, { AxiosError } from "axios";
import axios from "axios";
import type { Mocked } from "vitest";

jest.mock("axios", () => ({
...jest.requireActual("axios"),
post: jest.fn(),
}));
const mockAxios = Axios as jest.Mocked<typeof Axios>;
describe("Creation of scheduled event", () => {
vi.mock("axios", async (importOriginal) => {
const actualAxios = await importOriginal<typeof import("axios")>();
return {
default: {
...actualAxios,
post: vi.fn(),
},
};
});
const mockAxios = axios as Mocked<typeof axios>;

const mockScheduledEvent: RequiredScheduledEventArgs = {
webhook: "test url",
schedule_at: new Date(),
comment: "test comment",
payload: {},
};
const mockScheduledEvent: RequiredScheduledEventArgs = {
webhook: "test url",
schedule_at: new Date(),
comment: "test comment",
payload: {},
};

test("createScheduledEvent returns an error if request fails", async () => {
mockAxios.post.mockRejectedValue(new Error());
await expect(createScheduledEvent(mockScheduledEvent)).rejects.toThrow();
});
test("returns an error if request fails", async () => {
mockAxios.post.mockRejectedValue(new Error());
await expect(createScheduledEvent(mockScheduledEvent)).rejects.toThrow();
});

test("createScheduledEvent returns an error if Axios errors", async () => {
mockAxios.post.mockRejectedValue(new AxiosError());
await expect(createScheduledEvent(mockScheduledEvent)).rejects.toThrow();
});
test("returns an error if axios errors", async () => {
mockAxios.post.mockRejectedValue(new axios.AxiosError());
await expect(createScheduledEvent(mockScheduledEvent)).rejects.toThrow();
});

test("createScheduledEvent returns response data on success", async () => {
mockAxios.post.mockResolvedValue({ data: "test data" });
await expect(createScheduledEvent(mockScheduledEvent)).resolves.toBe(
"test data",
);
test("returns response data on success", async () => {
mockAxios.post.mockResolvedValue({ data: "test data" });
await expect(createScheduledEvent(mockScheduledEvent)).resolves.toBe(
"test data",
);
});
});
44 changes: 26 additions & 18 deletions api.planx.uk/lib/hasura/schema/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
import { runSQL } from "./index.js";
import Axios, { AxiosError } from "axios";
import axios from "axios";
import type { Mocked } from "vitest";

jest.mock("axios", () => ({
...jest.requireActual("axios"),
post: jest.fn(),
}));
const mockAxios = Axios as jest.Mocked<typeof Axios>;
describe("runSQL", () => {
vi.mock("axios", async (importOriginal) => {
const actualAxios = await importOriginal<typeof import("axios")>();
return {
default: {
...actualAxios,
post: vi.fn(),
},
};
});
const mockAxios = axios as Mocked<typeof axios>;

const sql = "SELECT * FROM TEST";
const sql = "SELECT * FROM TEST";

test("runSQL returns an error if request fails", async () => {
mockAxios.post.mockRejectedValue(new Error());
await expect(runSQL(sql)).rejects.toThrow();
});
test("returns an error if request fails", async () => {
mockAxios.post.mockRejectedValue(new Error());
await expect(runSQL(sql)).rejects.toThrow();
});

test("runSQL returns an error if Axios errors", async () => {
mockAxios.post.mockRejectedValue(new AxiosError());
await expect(runSQL(sql)).rejects.toThrow();
});
test("returns an error if Axios errors", async () => {
mockAxios.post.mockRejectedValue(new axios.AxiosError());
await expect(runSQL(sql)).rejects.toThrow();
});

test("runSQL returns response data on success", async () => {
mockAxios.post.mockResolvedValue({ data: "test data" });
await expect(runSQL(sql)).resolves.toBe("test data");
test("returns response data on success", async () => {
mockAxios.post.mockResolvedValue({ data: "test data" });
await expect(runSQL(sql)).resolves.toBe("test data");
});
});
2 changes: 1 addition & 1 deletion api.planx.uk/lib/notify/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { sendEmail } from "./index.js";
import { NotifyClient } from "notifications-node-client";
import { NotifyConfig } from "../../types.js";

jest.mock("notifications-node-client");
vi.mock("notifications-node-client");

const TEST_EMAIL = "[email protected]";
const mockConfig: NotifyConfig = {
Expand Down
10 changes: 6 additions & 4 deletions api.planx.uk/modules/admin/session/csv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { authHeader } from "../../../tests/mockJWT.js";
const endpoint = (strings: TemplateStringsArray) =>
`/admin/session/${strings[0]}/csv`;

const mockGenerateCSVData = jest.fn().mockResolvedValue([
const mockGenerateCSVData = vi.fn().mockResolvedValue([
{
question: "Is this a test?",
responses: [{ value: "Yes" }],
metadata: {},
},
]);
jest.mock("@opensystemslab/planx-core", () => {
vi.mock("@opensystemslab/planx-core", () => {
return {
CoreDomainClient: jest.fn().mockImplementation(() => ({
CoreDomainClient: vi.fn().mockImplementation(() => ({
export: {
csvData: () => mockGenerateCSVData(),
},
Expand All @@ -23,7 +23,9 @@ jest.mock("@opensystemslab/planx-core", () => {
});

describe("CSV data admin endpoint", () => {
afterEach(() => jest.clearAllMocks());
afterEach(() => {
vi.clearAllMocks();
});
const auth = authHeader({ role: "platformAdmin" });

it("requires a user to be logged in", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { expectedPlanningPermissionPayload } from "../../../tests/mocks/digitalP
const endpoint = (strings: TemplateStringsArray) =>
`/admin/session/${strings[0]}/digital-planning-application`;

const mockGenerateDigitalPlanningApplicationPayload = jest
const mockGenerateDigitalPlanningApplicationPayload = vi
.fn()
.mockResolvedValue(expectedPlanningPermissionPayload);

jest.mock("@opensystemslab/planx-core", () => {
vi.mock("@opensystemslab/planx-core", () => {
return {
CoreDomainClient: jest.fn().mockImplementation(() => ({
CoreDomainClient: vi.fn().mockImplementation(() => ({
export: {
digitalPlanningDataPayload: () =>
mockGenerateDigitalPlanningApplicationPayload(),
Expand Down
8 changes: 5 additions & 3 deletions api.planx.uk/modules/admin/session/html.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { authHeader } from "../../../tests/mockJWT.js";
const endpoint = (strings: TemplateStringsArray) =>
`/admin/session/${strings[0]}/html`;

const mockGenerateHTMLData = jest.fn().mockResolvedValue({
const mockGenerateHTMLData = vi.fn().mockResolvedValue({
responses: [
{
question: "Is this a test?",
Expand All @@ -15,7 +15,7 @@ const mockGenerateHTMLData = jest.fn().mockResolvedValue({
],
redactedResponses: [],
});
jest.mock("../../../client", () => {
vi.mock("../../../client", () => {
return {
$api: {
export: {
Expand All @@ -26,7 +26,9 @@ jest.mock("../../../client", () => {
});

describe("HTML data admin endpoint", () => {
afterEach(() => jest.clearAllMocks());
afterEach(() => {
vi.clearAllMocks();
});

it("requires a user to be logged in", () => {
return supertest(app)
Expand Down
4 changes: 2 additions & 2 deletions api.planx.uk/modules/admin/session/oneAppXML.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { authHeader } from "../../../tests/mockJWT.js";
const endpoint = (strings: TemplateStringsArray) =>
`/admin/session/${strings[0]}/xml`;

const mockGenerateOneAppXML = jest
const mockGenerateOneAppXML = vi
.fn()
.mockResolvedValue("<dummy:xml></dummy:xml>");

jest.mock("../../../client", () => {
vi.mock("../../../client", () => {
return {
$api: {
export: {
Expand Down
Loading
Loading