From 76783eca41d08556c3e8148da7fe1b27eebca82f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Mon, 9 Oct 2023 13:43:27 +0100 Subject: [PATCH 1/2] chore: Drop redundant endpoints --- api.planx.uk/server.test.js | 17 ----------------- api.planx.uk/server.ts | 29 ----------------------------- 2 files changed, 46 deletions(-) diff --git a/api.planx.uk/server.test.js b/api.planx.uk/server.test.js index 7428f7baef..8a05da05c8 100644 --- a/api.planx.uk/server.test.js +++ b/api.planx.uk/server.test.js @@ -1,24 +1,7 @@ import supertest from "supertest"; -import { queryMock } from "./tests/graphqlQueryMock"; import app from "./server"; -it("mocks hasura", async () => { - queryMock.mockQuery({ - name: "GetTeams", - data: { - teams: [{ id: 1 }], - }, - }); - - await supertest(app) - .get("/hasura") - .expect(200) - .then((res) => { - expect(res.body).toEqual({ teams: [{ id: 1 }] }); - }); -}); - describe("authentication", () => { test("Failed login endpoint", async () => { await supertest(app) diff --git a/api.planx.uk/server.ts b/api.planx.uk/server.ts index bb8e293c08..eea4a135ac 100644 --- a/api.planx.uk/server.ts +++ b/api.planx.uk/server.ts @@ -190,21 +190,6 @@ app.use("/webhooks", webhookRoutes); app.use("/gis", router); -app.get("/hasura", async function (_req, res, next) { - try { - const data = await adminClient.request(gql` - query GetTeams { - teams { - id - } - } - `); - res.json(data); - } catch (err) { - next(err); - } -}); - app.get("/gis", (_req, _res, next) => { next({ status: 400, @@ -227,12 +212,6 @@ app.get("/admin/session/:sessionId/html-redacted", getRedactedHTMLExport); app.get("/admin/session/:sessionId/zip", generateZip); app.get("/admin/session/:sessionId/summary", getSessionSummary); -// XXX: leaving this in temporarily as a testing endpoint to ensure it -// works correctly in staging and production -app.get("/throw-error", () => { - throw new Error("custom error"); -}); - app.post("/flows/:flowId/copy", useTeamEditorAuth, copyFlow); app.post("/flows/:flowId/diff", useTeamEditorAuth, validateAndDiffFlow); @@ -448,14 +427,6 @@ app.post("/invite-to-pay/:sessionId", inviteToPay); app.use("/proxy/ordnance-survey", useOrdnanceSurveyProxy); -app.get("/error", async (res, req, next) => { - try { - throw Error("This is a test error"); - } catch (error) { - next(error); - } -}); - const errorHandler: ErrorRequestHandler = (errorObject, _req, res, _next) => { const { status = 500, message = "Something went wrong" } = (() => { if ( From d00704fbe60142c74496eddb606f21eb75e6aef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Mon, 9 Oct 2023 13:55:26 +0100 Subject: [PATCH 2/2] test: Drop redundant tests --- api.planx.uk/tests/serverErrorHandler.test.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/api.planx.uk/tests/serverErrorHandler.test.js b/api.planx.uk/tests/serverErrorHandler.test.js index b4ca189238..cb14574208 100644 --- a/api.planx.uk/tests/serverErrorHandler.test.js +++ b/api.planx.uk/tests/serverErrorHandler.test.js @@ -30,20 +30,6 @@ describe("bad requests", () => { await get("/pay/wrong/1").expect(400); }); - test(`app.get("/hasura")`, async () => { - await get("/hasura").expect(500); - }); - - test(`app.get("/me")`, async () => { - await get("/me") - .expect(401) - .then((response) => { - expect(response.body).toEqual({ - error: "No authorization token was found", - }); - }); - }); - test(`app.get("/gis")`, async () => { await get("/gis").expect(400); }); @@ -58,10 +44,6 @@ describe("bad requests", () => { }); }); - test(`app.get("/throw-error")`, async () => { - await get("/throw-error").expect(500); - }); - test(`app.post("/flows/:flowId/publish")`, async () => { await post("/flows/WRONG/publish").expect(401); });