Skip to content

Commit 8514b01

Browse files
CCM-9247: Fix e2e tests
1 parent cad8916 commit 8514b01

File tree

9 files changed

+42
-22
lines changed

9 files changed

+42
-22
lines changed

infrastructure/terraform/modules/backend-api/cloudwatch_event_rule_guardduty_quarantine_scan_failed_for_upload.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_cloudwatch_event_rule" "guardduty_quarantine_scan_failed_for_upload" {
2-
name = "${local.csi}-quarantine-scan-failed-uploads"
2+
name = "${local.csi}-quarantine-scan-failed-for-upload"
33
description = "Matches quarantine 'GuardDuty Malware Protection Object Scan Result' events where the scan result is not NO_THREATS_FOUND"
44

55
event_pattern = jsonencode({

infrastructure/terraform/modules/backend-api/iam_role_quarantine_scan_failed_for_upload.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ resource "aws_iam_role" "quarantine_scan_failed_for_upload" {
66

77
resource "aws_iam_role_policy" "quarantine_scan_failed_for_upload" {
88
name = "${local.csi}-quarantine-scan-failed-for-upload"
9-
role = aws_iam_role.quarantine_scan_failed_for_proof.id
9+
role = aws_iam_role.quarantine_scan_failed_for_upload.id
1010
policy = data.aws_iam_policy_document.quarantine_scan_failed_for_upload.json
1111
}
1212

infrastructure/terraform/modules/backend-api/module_lambda_process_proof.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,24 @@ data "aws_iam_policy_document" "process_proof" {
2323

2424
actions = [
2525
"dynamodb:UpdateItem",
26-
"dynamodb:Query",
2726
]
2827

2928
resources = [
3029
aws_dynamodb_table.templates.arn,
3130
]
3231
}
32+
statement {
33+
sid = "AllowDynamoGSIAccess"
34+
effect = "Allow"
35+
36+
actions = [
37+
"dynamodb:Query",
38+
]
39+
40+
resources = [
41+
"${aws_dynamodb_table.templates.arn}/index/QueryById",
42+
]
43+
}
3344

3445
statement {
3546
sid = "AllowKMSAccessDynamoDB"

tests/test-team/config/e2e/e2e.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const buildCommand = [
1313
export default defineConfig({
1414
...baseConfig,
1515

16-
timeout: 30_000, // 30 seconds in the playwright default
16+
timeout: 60_000, // 30 seconds in the playwright default
1717
expect: {
1818
timeout: 10_000, // default is 5 seconds. After creating and previewing sometimes the load is slow on a cold start
1919
},

tests/test-team/helpers/factories/template-factory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const TemplateFactory = {
6363
currentVersion: randomUUID(),
6464
virusScanStatus,
6565
},
66+
proofs: {},
6667
},
6768
});
6869
},

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test.describe('letter file validation', () => {
1818
});
1919

2020
test.afterAll(async () => {
21-
await templateStorageHelper.deleteAdHocTemplates();
21+
//await templateStorageHelper.deleteAdHocTemplates();
2222
});
2323

2424
test('Uploaded pdf template files and test data csv files are virus scanned - if scan passes, files are copied to the internal bucket and validated', async ({
@@ -106,7 +106,7 @@ test.describe('letter file validation', () => {
106106
);
107107
}).toPass({ timeout: 40_000 });
108108

109-
page.reload();
109+
await page.reload();
110110

111111
await expect(page.locator('.nhsuk-error-summary')).toBeHidden();
112112
await expect(page.getByTestId('preview-letter-template-cta')).toBeVisible();
@@ -176,7 +176,7 @@ test.describe('letter file validation', () => {
176176
);
177177
}).toPass({ timeout: 40_000 });
178178

179-
page.reload();
179+
await page.reload();
180180

181181
await expect(page.locator('.nhsuk-error-summary')).toBeHidden();
182182
await expect(page.getByTestId('preview-letter-template-cta')).toBeVisible();
@@ -253,7 +253,7 @@ test.describe('letter file validation', () => {
253253
);
254254
}).toPass({ timeout: 20_000 });
255255

256-
page.reload();
256+
await page.reload();
257257

258258
await expect(page.locator('.nhsuk-error-summary')).toBeVisible();
259259
await expect(page.getByTestId('preview-letter-template-cta')).toBeHidden();
@@ -327,7 +327,7 @@ test.describe('letter file validation', () => {
327327
);
328328
}).toPass({ timeout: 60_000 });
329329

330-
page.reload();
330+
await page.reload();
331331

332332
await expect(page.locator('.nhsuk-error-summary')).toBeVisible();
333333
await expect(page.getByTestId('preview-letter-template-cta')).toBeHidden();
@@ -382,7 +382,7 @@ test.describe('letter file validation', () => {
382382
expect(template.testDataCsvHeaders).toBeUndefined();
383383
}).toPass({ timeout: 40_000 });
384384

385-
page.reload();
385+
await page.reload();
386386

387387
await expect(page.locator('.nhsuk-error-summary')).toBeVisible();
388388
await expect(page.getByTestId('preview-letter-template-cta')).toBeHidden();
@@ -435,7 +435,7 @@ test.describe('letter file validation', () => {
435435
expect(template.testDataCsvHeaders).toBeUndefined();
436436
}).toPass({ timeout: 40_000 });
437437

438-
page.reload();
438+
await page.reload();
439439

440440
await expect(page.locator('.nhsuk-error-summary')).toBeVisible();
441441
await expect(page.getByTestId('preview-letter-template-cta')).toBeHidden();
@@ -483,7 +483,7 @@ test.describe('letter file validation', () => {
483483
expect(template.testDataCsvHeaders).toBeUndefined();
484484
}).toPass({ timeout: 40_000 });
485485

486-
page.reload();
486+
await page.reload();
487487

488488
await expect(page.locator('.nhsuk-error-summary')).toBeVisible();
489489
await expect(page.getByTestId('preview-letter-template-cta')).toBeHidden();
@@ -531,7 +531,7 @@ test.describe('letter file validation', () => {
531531
expect(template.testDataCsvHeaders).toBeUndefined();
532532
}).toPass({ timeout: 40_000 });
533533

534-
page.reload();
534+
await page.reload();
535535

536536
await expect(page.locator('.nhsuk-error-summary')).toBeVisible();
537537
await expect(page.getByTestId('preview-letter-template-cta')).toBeHidden();
@@ -584,7 +584,7 @@ test.describe('letter file validation', () => {
584584
expect(template.testDataCsvHeaders).toBeUndefined();
585585
}).toPass({ timeout: 40_000 });
586586

587-
page.reload();
587+
await page.reload();
588588

589589
await expect(page.locator('.nhsuk-error-summary')).toBeVisible();
590590
await expect(page.getByTestId('preview-letter-template-cta')).toBeHidden();
@@ -639,7 +639,7 @@ test.describe('letter file validation', () => {
639639
expect(template.testDataCsvHeaders).toBeUndefined();
640640
}).toPass({ timeout: 40_000 });
641641

642-
page.reload();
642+
await page.reload();
643643

644644
await expect(page.locator('.nhsuk-error-summary')).toBeVisible();
645645
await expect(page.getByTestId('preview-letter-template-cta')).toBeHidden();

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ test.describe('letter complete e2e journey', () => {
107107
expect(csv?.ChecksumSHA256).toEqual(
108108
pdfUploadFixtures.withPersonalisation.csv.checksumSha256()
109109
);
110+
}).toPass({ timeout: 40_000 });
110111

111-
page.reload();
112+
await expect(async () => {
113+
await page.reload();
112114

113115
const previewTemplatePage = new TemplateMgmtPreviewLetterPage(page);
114116
await expect(previewTemplatePage.continueButton).toBeVisible();

tests/test-team/template-mgmt-e2e-tests/template-mgmt-proofing.e2e.spec.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { readFileSync } from 'node:fs';
22
import { expect, test } from '@playwright/test';
3+
import { randomUUID } from 'node:crypto';
34
import {
45
createAuthHelper,
56
TestUserId,
@@ -22,6 +23,7 @@ test.describe('Letter Proofing', () => {
2223

2324
test.afterAll(async () => {
2425
await sftpHelper.end();
26+
await templateStorageHelper.deleteSeededTemplates();
2527
});
2628

2729
test('proofs are downloaded and linked to the DB entry', async () => {
@@ -60,6 +62,9 @@ test.describe('Letter Proofing', () => {
6062
await lambdaClient.send(
6163
new InvokeCommand({
6264
FunctionName: process.env.SFTP_POLL_LAMBDA_NAME,
65+
Payload: JSON.stringify({
66+
supplier: 'WTMMOCK',
67+
}),
6368
})
6469
);
6570

@@ -92,12 +97,12 @@ test.describe('Letter Proofing', () => {
9297
process.env.TEMPLATES_QUARANTINE_BUCKET_NAME,
9398
'proofs',
9499
templateId,
95-
'proof',
100+
fileName,
96101
'pdf'
97102
);
98103

99104
expect(quarantinePdf?.ChecksumSHA256).toEqual(
100-
pdfUploadFixtures.withPersonalisation.pdf.checksumSha256()
105+
pdfUploadFixtures.noCustomPersonalisation.pdf.checksumSha256()
101106
);
102107

103108
const internalPdf = await templateStorageHelper.getLetterTemplateFile(
@@ -109,10 +114,10 @@ test.describe('Letter Proofing', () => {
109114
);
110115

111116
expect(internalPdf?.ChecksumSHA256).toEqual(
112-
pdfUploadFixtures.withPersonalisation.pdf.checksumSha256()
117+
pdfUploadFixtures.noCustomPersonalisation.pdf.checksumSha256()
113118
);
114119
}
115-
}).toPass({ timeout: 10_000 });
120+
}).toPass({ timeout: 60_000 });
116121
});
117122

118123
test('if the only proof fails the virus scan, the status is not updated to PROOF_AVAILABLE', async () => {
@@ -136,7 +141,7 @@ test.describe('Letter Proofing', () => {
136141

137142
await sftpHelper.put(
138143
pdfContent,
139-
`WTMMOCK/Outgoing/proofs/${templateId}/proof.pdf`
144+
`WTMMOCK/Outgoing/${process.env.SFTP_ENVIRONMENT}/proofs/${templateId}/proof.pdf`
140145
);
141146

142147
// invoke SFTP poll lambda
@@ -174,6 +179,6 @@ test.describe('Letter Proofing', () => {
174179
);
175180

176181
expect(pdf).toBe(null);
177-
}).toPass({ timeout: 10_000 });
182+
}).toPass({ timeout: 60_000 });
178183
});
179184
});

utils/utils/src/s3-repository.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class S3Repository {
2020
Bucket: this.bucket,
2121
Key: key,
2222
Body: fileData,
23+
ChecksumAlgorithm: 'SHA256',
2324
})
2425
);
2526
}

0 commit comments

Comments
 (0)