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 #3641

Merged
merged 10 commits into from
Sep 9, 2024
4 changes: 2 additions & 2 deletions api.planx.uk/modules/send/downloadApplicationFiles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export async function downloadApplicationFiles(

try {
// Confirm that the provided email matches the stored team settings for the provided localAuthority
const { notifyPersonalisation } = await getTeamEmailSettings(
const { teamSettings } = await getTeamEmailSettings(
req.query.localAuthority as string,
);
if (notifyPersonalisation.sendToEmail !== req.query.email) {
if (teamSettings.submissionEmail !== req.query.email) {
return next({
status: 403,
message:
Expand Down
12 changes: 6 additions & 6 deletions api.planx.uk/modules/send/email/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ describe(`sending an application by email to a planning office`, () => {
data: {
teams: [
{
notifyPersonalisation: {
teamSettings: {
emailReplyToId: "abc123",
sendToEmail: "[email protected]",
submissionEmail: "[email protected]",
},
},
],
Expand Down Expand Up @@ -154,9 +154,9 @@ describe(`sending an application by email to a planning office`, () => {
data: {
teams: [
{
notifyPersonalisation: {
teamSettings: {
emailReplyToId: "abc123",
sendToEmail: null,
submissionEmail: null,
},
},
],
Expand Down Expand Up @@ -206,8 +206,8 @@ describe(`downloading application data received by email`, () => {
data: {
teams: [
{
notifyPersonalisation: {
sendToEmail: "[email protected]",
teamSettings: {
submissionEmail: "[email protected]",
},
},
],
Expand Down
15 changes: 7 additions & 8 deletions api.planx.uk/modules/send/email/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ export async function sendToEmail(

try {
// Confirm this local authority (aka team) has an email configured in teams.submission_email
const { notifyPersonalisation } =
await getTeamEmailSettings(localAuthority);
if (!notifyPersonalisation.sendToEmail) {
const { teamSettings } = await getTeamEmailSettings(localAuthority);
if (!teamSettings.submissionEmail) {
return next({
status: 400,
message: `Send to email is not enabled for this local authority (${localAuthority})`,
Expand All @@ -47,15 +46,15 @@ export async function sendToEmail(
serviceName: flowName,
sessionId: payload.sessionId,
applicantEmail: email,
downloadLink: `${process.env.API_URL_EXT}/download-application-files/${payload.sessionId}?email=${notifyPersonalisation.sendToEmail}&localAuthority=${localAuthority}`,
...notifyPersonalisation,
downloadLink: `${process.env.API_URL_EXT}/download-application-files/${payload.sessionId}?email=${teamSettings.submissionEmail}&localAuthority=${localAuthority}`,
...teamSettings,
},
};

// Send the email
const response = await sendEmail(
"submit",
notifyPersonalisation.sendToEmail,
teamSettings.submissionEmail,
config,
);

Expand All @@ -66,14 +65,14 @@ export async function sendToEmail(
insertAuditEntry(
payload.sessionId,
localAuthority,
notifyPersonalisation.sendToEmail,
teamSettings.submissionEmail,
config,
response,
);

return res.status(200).send({
message: `Successfully sent to email`,
inbox: notifyPersonalisation.sendToEmail,
inbox: teamSettings.submissionEmail,
govuk_notify_template: "Submit",
});
} catch (error) {
Expand Down
11 changes: 4 additions & 7 deletions api.planx.uk/modules/send/email/service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { gql } from "graphql-request";
import { $api } from "../../../client/index.js";
import {
NotifyPersonalisation,
Session,
} from "@opensystemslab/planx-core/types";
import { Session, TeamContactSettings } from "@opensystemslab/planx-core/types";
import { EmailSubmissionNotifyConfig } from "../../../types.js";

interface GetTeamEmailSettings {
teams: {
notifyPersonalisation: NotifyPersonalisation & { sendToEmail: string };
teamSettings: TeamContactSettings;
}[];
}

Expand All @@ -17,12 +14,12 @@ export async function getTeamEmailSettings(localAuthority: string) {
gql`
query GetTeamEmailSettings($slug: String) {
teams(where: { slug: { _eq: $slug } }) {
notifyPersonalisation: team_settings {
teamSettings: team_settings {
helpEmail: help_email
helpPhone: help_phone
emailReplyToId: email_reply_to_id
helpOpeningHours: help_opening_hours
sendToEmail: submission_email
submissionEmail: submission_email
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@airbrake/node": "^2.1.8",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#931d4db",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#ec52620",
"@types/isomorphic-fetch": "^0.0.36",
"adm-zip": "^0.5.10",
"aws-sdk": "^2.1467.0",
Expand Down
14 changes: 7 additions & 7 deletions api.planx.uk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ More info about e2e tests is available in our [testing approach documentation](h

We use [Playwright](https://playwright.dev/docs/api/class-test) to run UI driven tests where user interactions are simulated via a web browser.

### Running UI-driven tests

1. Navigate to `/tests/ui-driven`
2. Run `pnpm install` to install the Playwright package.
3. Run `pnpm exec playwright install` to install the Playwright test browsers.
4. Run the tests with `pnpm test`



## API driven tests

Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/api-driven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"packageManager": "[email protected]",
"dependencies": {
"@cucumber/cucumber": "^9.3.0",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#931d4db",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#ec52620",
"axios": "^1.7.4",
"dotenv": "^16.3.1",
"dotenv-expand": "^10.0.0",
Expand Down
14 changes: 7 additions & 7 deletions e2e/tests/api-driven/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/tests/api-driven/src/globalHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TEST_EMAIL } from "../../ui-driven/src/globalHelpers";
import { TEST_EMAIL } from "../../ui-driven/src/helpers/globalHelpers";
import { $admin } from "./client";

export function createTeam(
Expand Down
16 changes: 8 additions & 8 deletions e2e/tests/api-driven/src/invite-to-pay/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { CustomWorld } from "./steps";
import axios from "axios";
import { readFileSync } from "node:fs";
import type {
FlowGraph,
PaymentRequest,
} from "@opensystemslab/planx-core/types";
import axios from "axios";
import gql from "graphql-tag";
import { readFileSync } from "node:fs";
import { TEST_EMAIL } from "../../../ui-driven/src/helpers/globalHelpers";
import { $admin } from "../client";
import { createTeam, createUser } from "../globalHelpers";
import {
inviteToPayFlowGraph,
sendNodeWithDestination,
mockBreadcrumbs,
mockPassport,
sendNodeWithDestination,
} from "./mocks";
import { $admin } from "../client";
import { TEST_EMAIL } from "../../../ui-driven/src/globalHelpers";
import { createTeam, createUser } from "../globalHelpers";
import gql from "graphql-tag";
import { CustomWorld } from "./steps";

export async function setUpMocks() {
const serverMockFile = readFileSync(`${__dirname}/mocks/server-mocks.yaml`);
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/ui-driven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"postinstall": "./install-dependencies.sh"
},
"dependencies": {
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#931d4db",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#ec52620",
"axios": "^1.7.4",
"dotenv": "^16.3.1",
"eslint": "^8.56.0",
Expand Down
14 changes: 7 additions & 7 deletions e2e/tests/ui-driven/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading