Skip to content

Commit

Permalink
test: Fix tests after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Dec 19, 2023
1 parent ed92e86 commit e45655d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
34 changes: 34 additions & 0 deletions api.planx.uk/modules/send/bops/bops.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ describe(`sending an application to BOPS`, () => {
});

describe(`sending an application to BOPS v2`, () => {
const submissionURL = "https://test.bops-test.com";

beforeEach(() => {
queryMock.mockQuery({
name: "FindApplication",
Expand All @@ -183,6 +185,38 @@ describe(`sending an application to BOPS v2`, () => {
insertBopsApplication: { id: 22 },
},
});

queryMock.mockQuery({
name: "GetStagingBopsSubmissionURL",
data: {
teams: [
{
integrations: {
bopsSubmissionURL: submissionURL,
},
},
],
},
variables: {
slug: "southwark",
},
});

queryMock.mockQuery({
name: "GetStagingBopsSubmissionURL",
data: {
teams: [
{
integrations: {
bopsSubmissionURL: null,
},
},
],
},
variables: {
slug: "unsupported-team",
},
});
});

it("successfully proxies request and returns hasura id", async () => {
Expand Down
16 changes: 14 additions & 2 deletions api.planx.uk/modules/send/bops/bops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,21 @@ const sendToBOPSV2 = async (
// a local or staging API instance should send to the BOPS staging endpoint
// production should send to the BOPS production endpoint
const localAuthority = req.params.localAuthority;
const bopsSubmissionURLEnvName = `BOPS_SUBMISSION_URL_${localAuthority.toUpperCase()}`;
const bopsSubmissionURL = process.env[bopsSubmissionURLEnvName];
const env = process.env.NODE_ENV === "production" ? "production" : "staging";
const bopsSubmissionURL = await $api.team.getBopsSubmissionURL(
localAuthority,
env,
);
const isSupported = Boolean(bopsSubmissionURL);
if (!isSupported) {
return next(
new ServerError({
status: 400,
message: `Back-office Planning System (BOPS) is not enabled for this local authority (${localAuthority})`,
}),
);
}

if (!isSupported) {
return next(
new ServerError({
Expand Down

0 comments on commit e45655d

Please sign in to comment.