Skip to content

Commit

Permalink
test: Add mock to share location
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Nov 13, 2023
1 parent a984c15 commit 02b987b
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 225 deletions.
112 changes: 1 addition & 111 deletions api.planx.uk/modules/flows/publish/publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import supertest from "supertest";
import { queryMock } from "../../../tests/graphqlQueryMock";
import { authHeader, getJWT } from "../../../tests/mockJWT";
import app from "../../../server";
import { FlowGraph } from "@opensystemslab/planx-core/types";
import { userContext } from "../../auth/middleware";
import { mockFlowData } from "../../../tests/mocks/validateAndPublishMocks";

beforeAll(() => {
const getStoreMock = jest.spyOn(userContext, "getStore");
Expand Down Expand Up @@ -154,113 +154,3 @@ describe("publish", () => {
});
});
});

const mockFlowData: FlowGraph = {
_root: {
edges: [
"SectionOne",
"QuestionOne",
"InternalPortalNode",
"FindPropertyNode",
"PayNode",
"SendNode",
"ResultNode",
"ConfirmationNode",
],
},
SectionOne: {
type: 360,
data: {
title: "Section 1",
},
},
FindPropertyNode: {
type: 9,
},
ResultNode: {
data: {
flagSet: "Planning permission",
overrides: {
NO_APP_REQUIRED: {
heading: "Congratulations!",
},
},
},
type: 3,
},
AnswerOne: {
data: {
text: "?",
},
type: 200,
},
QuestionInPortal: {
data: {
text: "internal question",
},
type: 100,
edges: ["AnswerInPortalOne", "AnswerInPortalTwo"],
},
AnswerTwo: {
data: {
text: "!!",
},
type: 200,
},
InternalPortalNode: {
data: {
text: "portal",
},
type: 300,
edges: ["QuestionInPortal"],
},
QuestionOne: {
data: {
text: "Question",
},
type: 100,
edges: ["AnswerOne", "AnswerTwo"],
},
PayNode: {
data: {
fn: "application.fee.payable",
url: "http://localhost:7002/pay",
color: "#EFEFEF",
title: "Pay for your application",
description:
'<p>The planning fee covers the cost of processing your application. Find out more about how planning fees are calculated <a href="https://www.gov.uk/guidance/fees-for-planning-applications" target="_self">here</a>.</p>',
},
type: 400,
},
AnswerInPortalOne: {
data: {
text: "?",
},
type: 200,
},
AnswerInPortalTwo: {
data: {
text: "*",
},
type: 200,
},
ConfirmationNode: {
data: {
heading: "Application sent",
moreInfo:
"<h2>You will be contacted</h2>\n<ul>\n<li>if there is anything missing from the information you have provided so far</li>\n<li>if any additional information is required</li>\n<li>to arrange a site visit, if required</li>\n<li>to inform you whether a certificate has been granted or not</li>\n</ul>\n",
contactInfo:
'<p>You can contact us at <a href="mailto:[email protected]" target="_self"><strong>[email protected]</strong></a></p>\n',
description:
"A payment receipt has been emailed to you. You will also receive an email to confirm when your application has been received.",
feedbackCTA: "What did you think of this service? (takes 30 seconds)",
},
type: 725,
},
SendNode: {
data: {
url: "http://localhost:7002/bops/southwark",
},
type: 650,
},
};
113 changes: 2 additions & 111 deletions api.planx.uk/modules/flows/validate/validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { queryMock } from "../../../tests/graphqlQueryMock";
import { authHeader, getJWT } from "../../../tests/mockJWT";
import app from "../../../server";
import { flowWithInviteToPay } from "../../../tests/mocks/inviteToPayData";
import { FlowGraph } from "@opensystemslab/planx-core/types";
import { userContext } from "../../auth/middleware";
import { FlowGraph } from "@opensystemslab/planx-core/types";
import { mockFlowData } from "../../../tests/mocks/validateAndPublishMocks";

beforeAll(() => {
const getStoreMock = jest.spyOn(userContext, "getStore");
Expand Down Expand Up @@ -294,113 +295,3 @@ describe("invite to pay validation on diff", () => {
});
});
});

const mockFlowData: FlowGraph = {
_root: {
edges: [
"SectionOne",
"QuestionOne",
"InternalPortalNode",
"FindPropertyNode",
"PayNode",
"SendNode",
"ResultNode",
"ConfirmationNode",
],
},
SectionOne: {
type: 360,
data: {
title: "Section 1",
},
},
FindPropertyNode: {
type: 9,
},
ResultNode: {
data: {
flagSet: "Planning permission",
overrides: {
NO_APP_REQUIRED: {
heading: "Congratulations!",
},
},
},
type: 3,
},
AnswerOne: {
data: {
text: "?",
},
type: 200,
},
QuestionInPortal: {
data: {
text: "internal question",
},
type: 100,
edges: ["AnswerInPortalOne", "AnswerInPortalTwo"],
},
AnswerTwo: {
data: {
text: "!!",
},
type: 200,
},
InternalPortalNode: {
data: {
text: "portal",
},
type: 300,
edges: ["QuestionInPortal"],
},
QuestionOne: {
data: {
text: "Question",
},
type: 100,
edges: ["AnswerOne", "AnswerTwo"],
},
PayNode: {
data: {
fn: "application.fee.payable",
url: "http://localhost:7002/pay",
color: "#EFEFEF",
title: "Pay for your application",
description:
'<p>The planning fee covers the cost of processing your application. Find out more about how planning fees are calculated <a href="https://www.gov.uk/guidance/fees-for-planning-applications" target="_self">here</a>.</p>',
},
type: 400,
},
AnswerInPortalOne: {
data: {
text: "?",
},
type: 200,
},
AnswerInPortalTwo: {
data: {
text: "*",
},
type: 200,
},
ConfirmationNode: {
data: {
heading: "Application sent",
moreInfo:
"<h2>You will be contacted</h2>\n<ul>\n<li>if there is anything missing from the information you have provided so far</li>\n<li>if any additional information is required</li>\n<li>to arrange a site visit, if required</li>\n<li>to inform you whether a certificate has been granted or not</li>\n</ul>\n",
contactInfo:
'<p>You can contact us at <a href="mailto:[email protected]" target="_self"><strong>[email protected]</strong></a></p>\n',
description:
"A payment receipt has been emailed to you. You will also receive an email to confirm when your application has been received.",
feedbackCTA: "What did you think of this service? (takes 30 seconds)",
},
type: 725,
},
SendNode: {
data: {
url: "http://localhost:7002/bops/southwark",
},
type: 650,
},
};
3 changes: 0 additions & 3 deletions api.planx.uk/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
useFilePermission,
useHasuraAuth,
useSendEmailAuth,
usePlatformAdminAuth,
} from "./modules/auth/middleware";

import airbrake from "./airbrake";
Expand All @@ -48,7 +47,6 @@ import { createSendEvents } from "./send/createSendEvents";
import { downloadApplicationFiles, sendToEmail } from "./send/email";
import { sendToUniform } from "./send/uniform";
import { useOrdnanceSurveyProxy } from "./proxy/ordnanceSurvey";
import { gql } from "graphql-request";
import { classifiedRoadsSearch } from "./gis/classifiedRoads";
import { googleStrategy } from "./modules/auth/strategy/google";
import authRoutes from "./modules/auth/routes";
Expand All @@ -61,7 +59,6 @@ import adminRoutes from "./modules/admin/routes";
import flowRoutes from "./modules/flows/routes";
import { useSwaggerDocs } from "./docs";
import { Role } from "@opensystemslab/planx-core/types";
import { $public } from "./client";

const router = express.Router();

Expand Down
111 changes: 111 additions & 0 deletions api.planx.uk/tests/mocks/validateAndPublishMocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { FlowGraph } from "@opensystemslab/planx-core/types";

export const mockFlowData: FlowGraph = {
_root: {
edges: [
"SectionOne",
"QuestionOne",
"InternalPortalNode",
"FindPropertyNode",
"PayNode",
"SendNode",
"ResultNode",
"ConfirmationNode",
],
},
SectionOne: {
type: 360,
data: {
title: "Section 1",
},
},
FindPropertyNode: {
type: 9,
},
ResultNode: {
data: {
flagSet: "Planning permission",
overrides: {
NO_APP_REQUIRED: {
heading: "Congratulations!",
},
},
},
type: 3,
},
AnswerOne: {
data: {
text: "?",
},
type: 200,
},
QuestionInPortal: {
data: {
text: "internal question",
},
type: 100,
edges: ["AnswerInPortalOne", "AnswerInPortalTwo"],
},
AnswerTwo: {
data: {
text: "!!",
},
type: 200,
},
InternalPortalNode: {
data: {
text: "portal",
},
type: 300,
edges: ["QuestionInPortal"],
},
QuestionOne: {
data: {
text: "Question",
},
type: 100,
edges: ["AnswerOne", "AnswerTwo"],
},
PayNode: {
data: {
fn: "application.fee.payable",
url: "http://localhost:7002/pay",
color: "#EFEFEF",
title: "Pay for your application",
description:
'<p>The planning fee covers the cost of processing your application. Find out more about how planning fees are calculated <a href="https://www.gov.uk/guidance/fees-for-planning-applications" target="_self">here</a>.</p>',
},
type: 400,
},
AnswerInPortalOne: {
data: {
text: "?",
},
type: 200,
},
AnswerInPortalTwo: {
data: {
text: "*",
},
type: 200,
},
ConfirmationNode: {
data: {
heading: "Application sent",
moreInfo:
"<h2>You will be contacted</h2>\n<ul>\n<li>if there is anything missing from the information you have provided so far</li>\n<li>if any additional information is required</li>\n<li>to arrange a site visit, if required</li>\n<li>to inform you whether a certificate has been granted or not</li>\n</ul>\n",
contactInfo:
'<p>You can contact us at <a href="mailto:[email protected]" target="_self"><strong>[email protected]</strong></a></p>\n',
description:
"A payment receipt has been emailed to you. You will also receive an email to confirm when your application has been received.",
feedbackCTA: "What did you think of this service? (takes 30 seconds)",
},
type: 725,
},
SendNode: {
data: {
url: "http://localhost:7002/bops/southwark",
},
type: 650,
},
};

0 comments on commit 02b987b

Please sign in to comment.