Skip to content

Commit

Permalink
feat: stub out editor & API endpoint and send events for Idox Nexus (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak authored Jun 28, 2024
1 parent 764a9dc commit fba15e7
Show file tree
Hide file tree
Showing 11 changed files with 571 additions and 95 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,8 @@ UNIFORM_CLIENT_AYLESBURY_VALE=👻
UNIFORM_CLIENT_CHILTERN=👻
UNIFORM_CLIENT_WYCOMBE=👻

## Forthcoming Idox Nexus integration
IDOX_NEXUS_CLIENT=👻

## End-to-end test team (borrows Lambeth's details)
GOV_UK_PAY_SECRET_E2E=👻
1 change: 1 addition & 0 deletions api.planx.uk/lib/hasura/metadata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface ScheduledEvent {
export interface CombinedResponse {
bops?: ScheduledEventResponse;
uniform?: ScheduledEventResponse;
idox?: ScheduledEventResponse;
email?: ScheduledEventResponse;
s3?: ScheduledEventResponse;
}
Expand Down
12 changes: 11 additions & 1 deletion api.planx.uk/modules/send/createSendEvents/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const createSendEvents: CreateSendEventsController = async (
res,
next,
) => {
const { email, uniform, bops, s3 } = res.locals.parsedReq.body;
const { email, uniform, bops, s3, idox } = res.locals.parsedReq.body;
const { sessionId } = res.locals.parsedReq.params;

try {
Expand Down Expand Up @@ -47,6 +47,16 @@ const createSendEvents: CreateSendEventsController = async (
combinedResponse["uniform"] = uniformEvent;
}

if (idox) {
const idoxEvent = await createScheduledEvent({
webhook: `{{HASURA_PLANX_API_URL}}/idox/${idox.localAuthority}`,
schedule_at: new Date(now.getTime() + 60 * 1000),
payload: idox.body,
comment: `idox_nexus_submission_${sessionId}`,
});
combinedResponse["idox"] = idoxEvent;
}

if (s3) {
const s3Event = await createScheduledEvent({
webhook: `{{HASURA_PLANX_API_URL}}/upload-submission/${s3.localAuthority}`,
Expand Down
1 change: 1 addition & 0 deletions api.planx.uk/modules/send/createSendEvents/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const combinedEventsPayloadSchema = z.object({
bops: eventSchema.optional(),
uniform: eventSchema.optional(),
s3: eventSchema.optional(),
idox: eventSchema.optional(),
}),
params: z.object({
sessionId: z.string().uuid(),
Expand Down
24 changes: 24 additions & 0 deletions api.planx.uk/modules/send/idox/nexus.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import supertest from "supertest";
import app from "../../../server";

describe(`sending an application to Idox Nexus`, () => {
it("fails without authorization header", async () => {
await supertest(app)
.post("/idox/southwark")
.send({ payload: { sessionId: "123" } })
.expect(401);
});

it("errors if the payload body does not include a sessionId", async () => {
await supertest(app)
.post("/idox/southwark")
.set({ Authorization: process.env.HASURA_PLANX_API_KEY! })
.send({ payload: { somethingElse: "123" } })
.expect(400)
.then((res) => {
expect(res.body).toEqual({
error: "Missing application data to send to Idox Nexus",
});
});
});
});
Loading

0 comments on commit fba15e7

Please sign in to comment.