Skip to content

Commit 8306e5a

Browse files
CCM-10283: Fix linting
1 parent 22f34c8 commit 8306e5a

File tree

5 files changed

+40
-28
lines changed

5 files changed

+40
-28
lines changed

lambdas/backend-api/src/templates/infra/email-client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export class EmailClient {
1919
supplier: string,
2020
proofFilenames: string[]
2121
) {
22-
const emailTemplateContent = readFileSync('./email-template.html').toString();
22+
const emailTemplateContent = readFileSync(
23+
'./email-template.html'
24+
).toString();
2325
const htmlTemplate = Handlebars.compile(emailTemplateContent);
2426

2527
return htmlTemplate({

tests/test-team/helpers/email-helper.ts

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
import { S3Client, ListObjectsV2Command, GetObjectCommand } from '@aws-sdk/client-s3';
2-
import { Readable } from 'stream';
1+
import {
2+
S3Client,
3+
ListObjectsV2Command,
4+
GetObjectCommand,
5+
} from '@aws-sdk/client-s3';
6+
import { Readable } from 'node:stream';
37

48
async function streamToString(stream: Readable): Promise<string> {
59
return await new Promise((resolve, reject) => {
610
const chunks: Buffer[] = [];
7-
stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
8-
stream.on("error", (err) => reject(err));
9-
stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf-8")));
11+
stream.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
12+
stream.on('error', (err) => reject(err));
13+
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
1014
});
1115
}
1216

@@ -22,38 +26,40 @@ export class EmailHelper {
2226
// This will stop working if one environment ever ends up with 1,000 email on it.
2327
// This seems very unlikely but if it happens we can revisit this and add pagination.
2428
async getEmailForTemplateId(templateId: string, dateCutoff: Date) {
25-
2629
const command = new ListObjectsV2Command({
27-
Bucket: this.testEmailBucketName,
28-
Prefix: this.testEmailPrefix,
30+
Bucket: this.testEmailBucketName,
31+
Prefix: this.testEmailPrefix,
2932
});
3033

3134
const { Contents = [] } = await this.s3Client.send(command);
3235

33-
const sortedKeys = Contents
34-
.filter(({ LastModified }) => (LastModified ?? 0) > dateCutoff)
35-
.sort((a, b) => ((b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0)));
36+
const sortedKeys = Contents.filter(
37+
({ LastModified }) => (LastModified ?? 0) > dateCutoff
38+
).sort(
39+
(a, b) =>
40+
(b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0)
41+
);
3642

3743
// SES does not tell us what the S3 keys are going to be for received emails,
3844
// so we have to search all recent ones to ensure we get the right one and
3945
// not one that was generated by a different test
4046
for (const { Key } of sortedKeys) {
41-
const getCommand = new GetObjectCommand({
42-
Bucket: this.testEmailBucketName,
47+
const getCommand = new GetObjectCommand({
48+
Bucket: this.testEmailBucketName,
4349
Key,
44-
});
50+
});
4551

46-
const { Body } = await this.s3Client.send(getCommand);
52+
const { Body } = await this.s3Client.send(getCommand);
4753

48-
if (!Body || !(Body instanceof Readable)) {
49-
throw new Error('Unexpected response body type');
50-
}
54+
if (!Body || !(Body instanceof Readable)) {
55+
throw new Error('Unexpected response body type');
56+
}
5157

52-
const content = await streamToString(Body);
58+
const content = await streamToString(Body);
5359

54-
if (content.includes(templateId)) {
55-
return content;
56-
}
60+
if (content.includes(templateId)) {
61+
return content;
62+
}
5763
}
5864

5965
throw new Error('Email not found');

tests/test-team/helpers/use-cases/simulate-passed-validation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export class SimulatePassedValidation implements IUseCase<Template> {
4343
fileName: 'proof.pdf',
4444
supplier: 'WTMMOCK',
4545
virusScanStatus: 'PASSED',
46-
}
47-
}
46+
},
47+
},
4848
},
4949
ReturnValues: 'ALL_NEW',
5050
})

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@ test.describe('POST /v1/template/:templateId/submit', () => {
198198
const emailHelper = new EmailHelper();
199199

200200
await expect(async () => {
201-
const emailContents = await emailHelper.getEmailForTemplateId(templateId, start);
201+
const emailContents = await emailHelper.getEmailForTemplateId(
202+
templateId,
203+
start
204+
);
202205

203206
expect(emailContents).toContain(templateId);
204207
expect(emailContents).toContain(templateName);

utils/backend-config/src/backend-config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ export const BackendConfigHelper = {
7979
userPoolClientId:
8080
outputsFileContent.cognito_user_pool_client_id?.value ?? '',
8181
sftpPollLambdaName: outputsFileContent.sftp_poll_lambda_name?.value ?? '',
82-
testEmailBucketName: outputsFileContent.test_email_bucket_name.value ?? '',
83-
testEmailPrefix: outputsFileContent.test_email_prefix?.value ?? ''
82+
testEmailBucketName:
83+
outputsFileContent.test_email_bucket_name.value ?? '',
84+
testEmailPrefix: outputsFileContent.test_email_prefix?.value ?? '',
8485
};
8586
},
8687

0 commit comments

Comments
 (0)