Skip to content

Commit 6b3a0e1

Browse files
CCM-10442: Test fixes
1 parent f0c99fe commit 6b3a0e1

File tree

11 files changed

+36
-72
lines changed

11 files changed

+36
-72
lines changed

infrastructure/terraform/components/sandbox/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@
4747
| <a name="output_sftp_poll_lambda_name"></a> [sftp\_poll\_lambda\_name](#output\_sftp\_poll\_lambda\_name) | n/a |
4848
| <a name="output_templates_table_name"></a> [templates\_table\_name](#output\_templates\_table\_name) | n/a |
4949
| <a name="output_test_email_bucket_name"></a> [test\_email\_bucket\_name](#output\_test\_email\_bucket\_name) | n/a |
50-
| <a name="output_test_proof_requested_email_prefix"></a> [test\_proof\_requested\_email\_prefix](#output\_test\_proof\_requested\_email\_prefix) | n/a |
51-
| <a name="output_test_template_submitted_email_prefix"></a> [test\_template\_submitted\_email\_prefix](#output\_test\_template\_submitted\_email\_prefix) | n/a |
50+
| <a name="output_test_email_bucket_prefix"></a> [test\_email\_bucket\_prefix](#output\_test\_email\_bucket\_prefix) | n/a |
5251
<!-- vale on -->
5352
<!-- markdownlint-enable -->
5453
<!-- END_TF_DOCS -->
Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
locals {
2-
mock_letter_supplier_name = "WTMMOCK"
3-
4-
use_sftp_letter_supplier_mock = lookup(var.letter_suppliers, local.mock_letter_supplier_name, null) != null
5-
62
email_domain = "sandbox.${local.acct.dns_zone["name"]}"
73
sandbox_letter_supplier_mock_proof_requested_sender = "proof-requested-sender-${var.environment}@${local.email_domain}"
84
sandbox_letter_supplier_mock_template_submitted_sender = "template-submitted-sender-${var.environment}@${local.email_domain}"
95
sandbox_letter_supplier_mock_recipient = "supplier-recipient-${var.environment}@${local.email_domain}"
10-
11-
# var.letter_suppliers is defined at a point where we don't know what the environment is, so
12-
# we need to add the environment-dependent test recipient separately here
13-
letter_suppliers = local.use_sftp_letter_supplier_mock ? merge(
14-
var.letter_suppliers,
15-
{ WTMMOCK = {
16-
email_addresses = concat(var.letter_suppliers.WTMMOCK.email_addresses, [local.sandbox_letter_supplier_mock_recipient])
17-
enable_polling = true
18-
default_supplier = true
19-
} }
20-
) : var.letter_suppliers
216
}

infrastructure/terraform/components/sandbox/module_backend_api.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ module "backend_api" {
1818
}
1919

2020
enable_proofing = true
21-
letter_suppliers = local.letter_suppliers
21+
letter_suppliers = {
22+
WTMMOCK = {
23+
email_addresses = concat(var.letter_suppliers.WTMMOCK.email_addresses, [local.sandbox_letter_supplier_mock_recipient])
24+
enable_polling = true
25+
default_supplier = true
26+
}
27+
}
2228

2329
kms_key_arn = data.aws_kms_key.sandbox.arn
2430

infrastructure/terraform/components/sandbox/outputs.tf

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ output "test_email_bucket_name" {
6262
value = local.acct["ses_testing_config"].bucket_name
6363
}
6464

65-
output "test_proof_requested_email_prefix" {
66-
value = "proof-requested-emails-${var.environment}"
67-
}
68-
69-
70-
output "test_template_submitted_email_prefix" {
71-
value = "template-submitted-emails-${var.environment}"
65+
output "test_email_bucket_prefix" {
66+
value = "emails-${var.environment}"
7267
}

infrastructure/terraform/components/sandbox/ses_receipt_rule_proof_requested.tf renamed to infrastructure/terraform/components/sandbox/ses_receipt_rule.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ resource "aws_ses_receipt_rule" "proof_requested" {
33
rule_set_name = local.acct["ses_testing_config"].rule_set_name
44

55
# Despite being called "recipients", AWS appears to apply this check to the sender email
6-
recipients = [local.sandbox_letter_supplier_mock_proof_requested_sender]
6+
recipients = [local.sandbox_letter_supplier_mock_recipient]
77
enabled = true
88
scan_enabled = true
99
tls_policy = "Optional"
1010

1111
s3_action {
1212
position = 1
1313
bucket_name = local.acct["ses_testing_config"].bucket_name
14-
object_key_prefix = "proof-requested-emails-${var.environment}/"
14+
object_key_prefix = "emails-${var.environment}/"
1515
iam_role_arn = local.acct["ses_testing_config"].iam_role_arn
1616
}
1717
}

infrastructure/terraform/components/sandbox/ses_receipt_rule_template_submitted.tf

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/test-team/global.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ declare global {
1414
TEMPLATES_INTERNAL_BUCKET_NAME: string;
1515
TEMPLATES_QUARANTINE_BUCKET_NAME: string;
1616
TEMPLATES_DOWNLOAD_BUCKET_NAME: string;
17-
TEST_TEMPLATE_SUBMITTED_EMAIL_PREFIX: string;
18-
TEST_PROOF_REQUESTED_EMAIL_PREFIX: string;
17+
TEST_EMAIL_BUCKET_PREFIX: string;
1918
}
2019
}
2120

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ export class EmailHelper {
5454
async getEmailForTemplateId(
5555
prefix: string,
5656
templateId: string,
57-
dateCutoff: Date
57+
dateCutoff: Date,
58+
extraTextToSearch: string,
5859
) {
5960
const s3Items = await this.getAllS3Items(prefix);
6061

@@ -82,7 +83,7 @@ export class EmailHelper {
8283

8384
const content = await streamToString(Body);
8485

85-
if (content.includes(templateId)) {
86+
if (content.includes(templateId) && content.includes(extraTextToSearch)) {
8687
return content;
8788
}
8889
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,10 @@ test.describe('POST /v1/template/:templateId/submit', () => {
200200

201201
await expect(async () => {
202202
const emailContents = await emailHelper.getEmailForTemplateId(
203-
process.env.TEST_TEMPLATE_SUBMITTED_EMAIL_PREFIX,
203+
process.env.TEST_EMAIL_BUCKET_PREFIX,
204204
templateId,
205-
start
205+
start,
206+
'template-submitted-sender'
206207
);
207208

208209
expect(emailContents).toContain(templateId);

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,20 +260,22 @@ function submit(
260260
function checkEmail(
261261
expandedTemplateId: string,
262262
testStart: Date,
263-
prefix: string,
264-
emailTitle: string
263+
emailTitle: string,
264+
extraTextToSearch: string,
265265
) {
266266
return test.step('check email', async () => {
267267
await expect(async () => {
268268
const emailContents = await emailHelper.getEmailForTemplateId(
269-
prefix,
269+
process.env.TEST_EMAIL_BUCKET_PREFIX,
270270
expandedTemplateId,
271-
testStart
271+
testStart,
272+
extraTextToSearch,
272273
);
273274

274275
expect(emailContents).toContain(expandedTemplateId);
275276
expect(emailContents).toContain('Valid Letter Template'); // template name
276277
expect(emailContents).toContain(emailTitle);
278+
expect(emailContents).toContain(extraTextToSearch);
277279
}).toPass({ timeout: 60_000 });
278280
});
279281
}
@@ -322,17 +324,17 @@ test.describe('letter complete e2e journey', () => {
322324
await checkEmail(
323325
expandedTemplateId,
324326
testStart,
325-
process.env.TEST_PROOF_REQUESTED_EMAIL_PREFIX,
326-
'Proof Requested'
327+
'Proof Requested',
328+
'proof-requested-sender',
327329
);
328330

329331
await submit(page, templateStorageHelper, templateKey);
330332

331333
await checkEmail(
332334
expandedTemplateId,
333335
testStart,
334-
process.env.TEST_TEMPLATE_SUBMITTED_EMAIL_PREFIX,
335-
'Template Submitted'
336+
'Template Submitted',
337+
'template-submitted-sender',
336338
);
337339
});
338340

0 commit comments

Comments
 (0)