Skip to content

Commit a5fd7fa

Browse files
committed
CCM-8420: remove confirmation email
1 parent b25ca3e commit a5fd7fa

38 files changed

+25
-1327
lines changed

.github/workflows/stage-4-acceptance.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ jobs:
106106
- name: "Repo setup"
107107
run: |
108108
npm ci
109-
- name: "Generate dependencies"
110-
run: |
111-
npm run generate-dependencies --workspaces --if-present
112109
- name: Configure AWS credentials
113110
uses: aws-actions/configure-aws-credentials@v4
114111
with:
@@ -144,9 +141,6 @@ jobs:
144141
- name: "Repo setup"
145142
run: |
146143
npm ci
147-
- name: "Generate dependencies"
148-
run: |
149-
npm run generate-dependencies --workspaces --if-present
150144
- name: Install Playwright Browsers
151145
run: npx playwright install --with-deps
152146
- name: Configure AWS credentials

README.md

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,40 +37,27 @@
3737

3838
### Running the project locally
3939

40-
1. Convert the email HTML template into a JSON file that can be packaged with the email sending lambda.
41-
42-
```shell
43-
npm run generate-dependencies
44-
```
45-
46-
2. (Optional) If you want to test sending emails then you will need to set the following environment variables locally.
47-
48-
```shell
49-
export ACCOUNT_ID=<aws_account_id>
50-
export NOTIFY_DOMAIN_NAME=<ses_verified_domain>
51-
```
52-
53-
3. To create a Terraform backend sandbox, run:
40+
1. To create a Terraform backend sandbox, run:
5441

5542
```shell
5643
npm run create-backend-sandbox <environment-name>
5744
```
5845

59-
4. Then in a separate terminal, run the app locally:
46+
2. Then in a separate terminal, run the app locally:
6047

6148
```shell
6249
npm run dev
6350
```
6451

65-
5. Open your browser and go to `localhost:3000` to view the app.
52+
3. Open your browser and go to `localhost:3000` to view the app.
6653

67-
6. To destroy a Terraform backend sandbox, run:
54+
4. To destroy a Terraform backend sandbox, run:
6855

6956
```shell
7057
npm run destroy-backend-sandbox <environment-name>
7158
```
7259

73-
7. (Optional) Create a `.env` file at `frontend/.env` and add `INCLUDE_AUTH_PAGES=true` to include the local auth pages when doing a production Next build
60+
5. (Optional) Create a `.env` file at `frontend/.env` and add `INCLUDE_AUTH_PAGES=true` to include the local auth pages when doing a production Next build
7461

7562
### Other commands
7663

amplify.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ applications:
99
- nvm install 20.13.1
1010
- nvm use 20.13.1
1111
- npm ci --cache .npm --prefer-offline
12-
- npm run generate-dependencies --workspaces --if-present
1312
- npm run create-amplify-outputs env
1413
- cd frontend
1514
frontend:

frontend/jest.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const config: Config = {
2828
'.snap',
2929
'resource.ts',
3030
'backend.ts',
31-
'generate-dependencies.ts',
3231
'jest.config.ts',
3332
'.dev.tsx',
3433
],

frontend/src/__tests__/components/forms/SubmitTemplate/server-action.test.ts

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { submitTemplate } from '@forms/SubmitTemplate/server-action';
55
import { getMockFormData } from '@testhelpers';
66
import { redirect } from 'next/navigation';
7-
import { getTemplate, saveTemplate, sendEmail } from '@utils/form-actions';
7+
import { getTemplate, saveTemplate } from '@utils/form-actions';
88
import {
99
TemplateType,
1010
TemplateStatus,
@@ -18,7 +18,6 @@ jest.mock('@utils/amplify-utils');
1818
const redirectMock = jest.mocked(redirect);
1919
const getTemplateMock = jest.mocked(getTemplate);
2020
const saveTemplateMock = jest.mocked(saveTemplate);
21-
const sendEmailMock = jest.mocked(sendEmail);
2221

2322
const mockNhsAppTemplate = {
2423
templateType: TemplateType.NHS_APP,
@@ -65,25 +64,23 @@ describe('submitTemplate', () => {
6564
expect(redirectMock).toHaveBeenCalledWith('/invalid-template', 'replace');
6665
});
6766

68-
it('should handle error when failing to send email', async () => {
67+
it('should handle error when failing to save template', async () => {
6968
getTemplateMock.mockResolvedValueOnce(mockNhsAppTemplate);
7069

71-
saveTemplateMock.mockResolvedValueOnce(mockNhsAppTemplate);
72-
73-
sendEmailMock.mockImplementationOnce(() => {
74-
throw new Error('failed to send email');
70+
saveTemplateMock.mockImplementationOnce(() => {
71+
throw new Error('failed to save template');
7572
});
7673

7774
const formData = getMockFormData({
7875
templateId: '1',
7976
});
8077

8178
await expect(submitTemplate('submit-route', formData)).rejects.toThrow(
82-
'failed to send email'
79+
'failed to save template'
8380
);
8481
});
8582

86-
it('should redirect when successfully sent email', async () => {
83+
it('should redirect when successfully submitted', async () => {
8784
getTemplateMock.mockResolvedValueOnce(mockNhsAppTemplate);
8885

8986
const formData = getMockFormData({
@@ -92,31 +89,17 @@ describe('submitTemplate', () => {
9289

9390
await submitTemplate('submit-route', formData);
9491

95-
expect(sendEmailMock).toHaveBeenCalledWith(mockNhsAppTemplate.id);
96-
92+
expect(saveTemplateMock).toHaveBeenCalledWith(
93+
expect.objectContaining({
94+
createdAt: '2025-01-13T10:19:25.579Z',
95+
id: '1',
96+
message: 'body',
97+
name: 'name',
98+
templateStatus: 'SUBMITTED',
99+
templateType: 'NHS_APP',
100+
updatedAt: '2025-01-13T10:19:25.579Z',
101+
})
102+
);
97103
expect(redirectMock).toHaveBeenCalledWith('/submit-route/1', 'push');
98104
});
99-
100-
it('should send an email with the subject line when template type is EMAIL', async () => {
101-
const mockEmailTemplate = {
102-
id: 'template-id',
103-
templateType: TemplateType.EMAIL,
104-
templateStatus: TemplateStatus.NOT_YET_SUBMITTED,
105-
name: 'name',
106-
subject: 'subjectLine',
107-
message: 'body',
108-
createdAt: '2025-01-13T10:19:25.579Z',
109-
updatedAt: '2025-01-13T10:19:25.579Z',
110-
};
111-
112-
getTemplateMock.mockResolvedValueOnce(mockEmailTemplate);
113-
114-
const formData = getMockFormData({
115-
templateId: 'template-id',
116-
});
117-
118-
await submitTemplate('submit-route', formData);
119-
120-
expect(sendEmailMock).toHaveBeenCalledWith(mockEmailTemplate.id);
121-
});
122105
});

frontend/src/__tests__/utils/form-actions.test.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
createTemplate,
1212
saveTemplate,
1313
getTemplate,
14-
sendEmail,
1514
getTemplates,
1615
} from '@utils/form-actions';
1716
import { getAccessTokenServer } from '@utils/amplify-utils';
@@ -274,42 +273,6 @@ describe('form-actions', () => {
274273
await expect(getTemplates()).rejects.toThrow('Failed to get access token');
275274
});
276275

277-
test('sendEmail', async () => {
278-
mockedBackendClient.functions.sendEmail.mockResolvedValueOnce({
279-
data: undefined,
280-
error: undefined,
281-
});
282-
283-
const response = await sendEmail('id');
284-
285-
expect(mockedBackendClient.functions.sendEmail).toHaveBeenCalledWith('id');
286-
287-
expect(response).toEqual(undefined);
288-
});
289-
290-
test('sendEmail - should thrown error when no token', async () => {
291-
authIdTokenServerMock.mockReset();
292-
authIdTokenServerMock.mockResolvedValueOnce(undefined);
293-
294-
await expect(sendEmail('id')).rejects.toThrow('Failed to get access token');
295-
});
296-
297-
test('getTemplates - should return nothing when an error occurs', async () => {
298-
mockedBackendClient.functions.sendEmail.mockResolvedValueOnce({
299-
data: undefined,
300-
error: {
301-
code: 404,
302-
message: 'Not found',
303-
},
304-
});
305-
306-
const response = await sendEmail('id');
307-
308-
expect(mockedBackendClient.functions.sendEmail).toHaveBeenCalledWith('id');
309-
310-
expect(response).toEqual(undefined);
311-
});
312-
313276
test('getTemplates - order by createdAt and then id', async () => {
314277
const baseTemplate = {
315278
templateType: TemplateType.SMS,

frontend/src/components/forms/SubmitTemplate/server-action.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use server';
22

33
import { redirect, RedirectType } from 'next/navigation';
4-
import { getTemplate, saveTemplate, sendEmail } from '@utils/form-actions';
4+
import { getTemplate, saveTemplate } from '@utils/form-actions';
55
import { z } from 'zod';
66
import { validateChannelTemplate } from '@utils/validate-template';
77
import { TemplateStatus } from 'nhs-notify-web-template-management-utils';
@@ -31,8 +31,6 @@ export async function submitTemplate(route: string, formData: FormData) {
3131
...validatedTemplate,
3232
templateStatus: TemplateStatus.SUBMITTED,
3333
});
34-
35-
await sendEmail(templateId);
3634
} catch (error) {
3735
logger.error('Failed to submit template', {
3836
error,

frontend/src/utils/form-actions.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,6 @@ export async function getTemplate(
7171
return data;
7272
}
7373

74-
export async function sendEmail(templateId: string) {
75-
const token = await getAccessTokenServer();
76-
77-
if (!token) {
78-
throw new Error('Failed to get access token');
79-
}
80-
81-
const { error } = await BackendClient(token).functions.sendEmail(templateId);
82-
83-
if (error) {
84-
logger.error({
85-
description: 'Error sending email',
86-
error,
87-
});
88-
}
89-
}
90-
9174
export async function getTemplates(): Promise<TemplateDTO[]> {
9275
const token = await getAccessTokenServer();
9376

infrastructure/terraform/components/app/module_backend_api.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module "backend_api" {
88
group = var.group
99
csi = local.csi
1010
log_retention_in_days = var.log_retention_in_days
11-
email_domain_name = local.root_domain_name
1211

1312
cognito_config = jsondecode(data.aws_ssm_parameter.cognito_config.value)
1413
}

infrastructure/terraform/components/sandbox/module_backend_api.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module "backend_api" {
88
group = var.group
99
csi = local.csi
1010
log_retention_in_days = var.log_retention_in_days
11-
email_domain_name = "no-domain"
1211

1312
cognito_config = {
1413
USER_POOL_ID = aws_cognito_user_pool.sandbox.id

0 commit comments

Comments
 (0)