Skip to content

Commit 2946d32

Browse files
authored
CCM-8420: remove confirmation email (#274)
1 parent 23a1077 commit 2946d32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+71
-1436
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__/components/molecules/__snapshots__/TemplateSubmitted.test.tsx.snap

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ exports[`TemplateSubmitted component should render 1`] = `
4343
>
4444
What you need to do next
4545
</h2>
46-
<p>
47-
You'll receive a confirmation email, which contains the template name and ID.
48-
</p>
4946
<h3>
5047
If you're currently onboarding
5148
</h3>

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

Lines changed: 20 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@ import {
1111
createTemplate,
1212
saveTemplate,
1313
getTemplate,
14-
sendEmail,
1514
getTemplates,
1615
} from '@utils/form-actions';
1716
import { getAccessTokenServer } from '@utils/amplify-utils';
1817
import { mockDeep } from 'jest-mock-extended';
19-
import { IBackendClient } from 'nhs-notify-backend-client/src/types/backend-client';
18+
import { ITemplateClient } from 'nhs-notify-backend-client';
2019

21-
const mockedBackendClient = mockDeep<IBackendClient>();
20+
const mockedTemplateClient = mockDeep<ITemplateClient>();
2221
const authIdTokenServerMock = jest.mocked(getAccessTokenServer);
2322

2423
jest.mock('@utils/amplify-utils');
25-
jest.mock('nhs-notify-backend-client/src/backend-api-client', () => ({
26-
BackendClient: () => mockedBackendClient,
24+
jest.mock('nhs-notify-backend-client/src/template-api-client', () => ({
25+
TemplateClient: () => mockedTemplateClient,
2726
}));
2827

2928
describe('form-actions', () => {
@@ -44,7 +43,7 @@ describe('form-actions', () => {
4443
updatedAt: '2025-01-13T10:19:25.579Z',
4544
};
4645

47-
mockedBackendClient.templates.createTemplate.mockResolvedValueOnce({
46+
mockedTemplateClient.createTemplate.mockResolvedValueOnce({
4847
data: responseData,
4948
});
5049

@@ -57,15 +56,15 @@ describe('form-actions', () => {
5756

5857
const response = await createTemplate(createTemplateInput);
5958

60-
expect(mockedBackendClient.templates.createTemplate).toHaveBeenCalledWith(
59+
expect(mockedTemplateClient.createTemplate).toHaveBeenCalledWith(
6160
createTemplateInput
6261
);
6362

6463
expect(response).toEqual(responseData);
6564
});
6665

6766
test('createTemplate - should thrown error when saving unexpectedly fails', async () => {
68-
mockedBackendClient.templates.createTemplate.mockResolvedValueOnce({
67+
mockedTemplateClient.createTemplate.mockResolvedValueOnce({
6968
error: {
7069
code: 400,
7170
message: 'Bad request',
@@ -83,7 +82,7 @@ describe('form-actions', () => {
8382
'Failed to create new template'
8483
);
8584

86-
expect(mockedBackendClient.templates.createTemplate).toHaveBeenCalledWith(
85+
expect(mockedTemplateClient.createTemplate).toHaveBeenCalledWith(
8786
createTemplateInput
8887
);
8988
});
@@ -115,7 +114,7 @@ describe('form-actions', () => {
115114
updatedAt: '2025-01-13T10:19:25.579Z',
116115
};
117116

118-
mockedBackendClient.templates.updateTemplate.mockResolvedValueOnce({
117+
mockedTemplateClient.updateTemplate.mockResolvedValueOnce({
119118
data: responseData,
120119
});
121120

@@ -129,7 +128,7 @@ describe('form-actions', () => {
129128

130129
const response = await saveTemplate(updateTemplateInput);
131130

132-
expect(mockedBackendClient.templates.updateTemplate).toHaveBeenCalledWith(
131+
expect(mockedTemplateClient.updateTemplate).toHaveBeenCalledWith(
133132
updateTemplateInput.id,
134133
updateTemplateInput
135134
);
@@ -138,7 +137,7 @@ describe('form-actions', () => {
138137
});
139138

140139
test('saveTemplate - should thrown error when saving unexpectedly fails', async () => {
141-
mockedBackendClient.templates.updateTemplate.mockResolvedValueOnce({
140+
mockedTemplateClient.updateTemplate.mockResolvedValueOnce({
142141
error: {
143142
code: 400,
144143
message: 'Bad request',
@@ -157,7 +156,7 @@ describe('form-actions', () => {
157156
'Failed to save template data'
158157
);
159158

160-
expect(mockedBackendClient.templates.updateTemplate).toHaveBeenCalledWith(
159+
expect(mockedTemplateClient.updateTemplate).toHaveBeenCalledWith(
161160
updateTemplateInput.id,
162161
updateTemplateInput
163162
);
@@ -191,21 +190,19 @@ describe('form-actions', () => {
191190
updatedAt: '2025-01-13T10:19:25.579Z',
192191
};
193192

194-
mockedBackendClient.templates.getTemplate.mockResolvedValueOnce({
193+
mockedTemplateClient.getTemplate.mockResolvedValueOnce({
195194
data: responseData,
196195
});
197196

198197
const response = await getTemplate('id');
199198

200-
expect(mockedBackendClient.templates.getTemplate).toHaveBeenCalledWith(
201-
'id'
202-
);
199+
expect(mockedTemplateClient.getTemplate).toHaveBeenCalledWith('id');
203200

204201
expect(response).toEqual(responseData);
205202
});
206203

207204
test('getTemplate - should return undefined when no data', async () => {
208-
mockedBackendClient.templates.getTemplate.mockResolvedValueOnce({
205+
mockedTemplateClient.getTemplate.mockResolvedValueOnce({
209206
data: undefined,
210207
error: {
211208
code: 404,
@@ -215,9 +212,7 @@ describe('form-actions', () => {
215212

216213
const response = await getTemplate('id');
217214

218-
expect(mockedBackendClient.templates.getTemplate).toHaveBeenCalledWith(
219-
'id'
220-
);
215+
expect(mockedTemplateClient.getTemplate).toHaveBeenCalledWith('id');
221216

222217
expect(response).toEqual(undefined);
223218
});
@@ -242,19 +237,19 @@ describe('form-actions', () => {
242237
updatedAt: '2025-01-13T10:19:25.579Z',
243238
};
244239

245-
mockedBackendClient.templates.listTemplates.mockResolvedValueOnce({
240+
mockedTemplateClient.listTemplates.mockResolvedValueOnce({
246241
data: [responseData],
247242
});
248243

249244
const response = await getTemplates();
250245

251-
expect(mockedBackendClient.templates.listTemplates).toHaveBeenCalledWith();
246+
expect(mockedTemplateClient.listTemplates).toHaveBeenCalledWith();
252247

253248
expect(response).toEqual([responseData]);
254249
});
255250

256251
test('getTemplates - should return empty array when fetching unexpectedly fails', async () => {
257-
mockedBackendClient.templates.listTemplates.mockResolvedValueOnce({
252+
mockedTemplateClient.listTemplates.mockResolvedValueOnce({
258253
data: undefined,
259254
error: {
260255
code: 500,
@@ -274,42 +269,6 @@ describe('form-actions', () => {
274269
await expect(getTemplates()).rejects.toThrow('Failed to get access token');
275270
});
276271

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-
313272
test('getTemplates - order by createdAt and then id', async () => {
314273
const baseTemplate = {
315274
templateType: TemplateType.SMS,
@@ -348,7 +307,7 @@ describe('form-actions', () => {
348307
'10',
349308
];
350309

351-
mockedBackendClient.templates.listTemplates.mockResolvedValueOnce({
310+
mockedTemplateClient.listTemplates.mockResolvedValueOnce({
352311
data: templates,
353312
});
354313

0 commit comments

Comments
 (0)