Skip to content

Commit a274b7c

Browse files
CCM-12090: Test fixes and code cleanup
1 parent eee8473 commit a274b7c

File tree

8 files changed

+19
-8
lines changed

8 files changed

+19
-8
lines changed

frontend/src/__tests__/app/upload-letter-template/page.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe('UploadLetterTemplatePage', () => {
120120
);
121121
});
122122

123-
it('should redirect to error page when neither campaignIds is present and empty', async () => {
123+
it('should redirect to error page when campaignIds is present and empty', async () => {
124124
const mockRedirect = jest.mocked(redirect);
125125

126126
mockGetSessionServer.mockResolvedValueOnce({

lambdas/backend-api/src/templates/api/upload-letter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { APIGatewayProxyHandler } from 'aws-lambda';
2-
import { UploadLetterTemplate } from 'nhs-notify-web-template-management-utils';
32
import { apiFailure, apiSuccess } from './responses';
43
import { getLetterUploadParts } from '../app/get-letter-upload-parts';
54
import { TemplateClient } from '../app/template-client';
@@ -32,7 +31,7 @@ export function createHandler({
3231

3332
const { data: created, error: createTemplateError } =
3433
await templateClient.uploadLetterTemplate(
35-
template as UploadLetterTemplate,
34+
template,
3635
{ userId, clientId },
3736
pdf,
3837
csv

tests/test-team/template-mgmt-api-tests/create-template.api.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ test.describe('POST /v1/template', () => {
108108
});
109109

110110
test.describe('NHS_APP templates', () => {
111-
test('returns 201 if template is valid', async ({ request }) => {
111+
test.only('returns 201 if template is valid', async ({ request }) => {
112112
const template = TemplateAPIPayloadFactory.getCreateTemplatePayload({
113113
templateType: 'NHS_APP',
114114
});

tests/test-team/template-mgmt-api-tests/submit-template.api.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ test.describe('POST /v1/template/:templateId/submit', () => {
11011101
expect(updated).toEqual({
11021102
statusCode: 200,
11031103
template: {
1104-
campaignId: testClients[userProofingDisabled.clientKey]?.campaignId,
1104+
campaignId: 'campaign-id',
11051105
clientId: userProofingDisabled.clientId,
11061106
createdAt: expect.stringMatching(isoDateRegExp),
11071107
id: expect.stringMatching(uuidRegExp),

tests/test-team/template-mgmt-api-tests/upload-letter-template.api.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ test.describe('POST /v1/letter-template', () => {
414414
{
415415
templateType: 'LETTER',
416416
name: undefined,
417+
campaignId: 'Campaign1',
417418
},
418419
[
419420
{
@@ -462,6 +463,7 @@ test.describe('POST /v1/letter-template', () => {
462463
TemplateAPIPayloadFactory.getUploadLetterTemplatePayload(
463464
{
464465
templateType: 'LETTER',
466+
campaignId: 'Campaign1',
465467
},
466468
[
467469
{
@@ -514,6 +516,7 @@ test.describe('POST /v1/letter-template', () => {
514516
TemplateAPIPayloadFactory.getUploadLetterTemplatePayload(
515517
{
516518
templateType: 'LETTER',
519+
campaignId: 'Campaign1',
517520
},
518521
[
519522
{
@@ -557,6 +560,7 @@ test.describe('POST /v1/letter-template', () => {
557560
TemplateAPIPayloadFactory.getUploadLetterTemplatePayload(
558561
{
559562
templateType: 'LETTER',
563+
campaignId: 'Campaign1',
560564
},
561565
[
562566
{

tests/test-team/template-mgmt-component-tests/letter/template-mgmt-preview-letter-page.component.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,12 @@ test.describe('Preview Letter template Page', () => {
132132
templates.notYetSubmitted.name
133133
);
134134

135+
if (!templates.notYetSubmitted.campaignId) {
136+
throw new Error('Test data misconfiguration');
137+
}
138+
135139
await expect(previewLetterTemplatePage.campaignId).toContainText(
136-
templates.notYetSubmitted.campaignId!
140+
templates.notYetSubmitted.campaignId
137141
);
138142

139143
await previewLetterTemplatePage.clickContinueButton();

tests/test-team/template-mgmt-component-tests/letter/template-mgmt-preview-submitted-letter-page.component.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ test.describe('Preview submitted Letter message template Page', () => {
8585
templates.valid.name
8686
);
8787

88+
if (!templates.valid.campaignId) {
89+
throw new Error('Test data misconfiguration');
90+
}
91+
8892
await expect(previewSubmittedLetterTemplatePage.campaignId).toContainText(
89-
templates.valid.campaignId!
93+
templates.valid.campaignId
9094
);
9195
});
9296

tests/test-team/template-mgmt-e2e-tests/template-mgmt-letter-full.e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function create(
3737

3838
if (campaignId) {
3939
await page.selectOption('#letterTemplateCampaignId', {
40-
value: 'other-campaign-id',
40+
value: campaignId,
4141
});
4242
}
4343

0 commit comments

Comments
 (0)