Skip to content

Commit 7ddf2a6

Browse files
CCM-15256: Initial commit
1 parent bfa5fe0 commit 7ddf2a6

5 files changed

Lines changed: 53 additions & 1 deletion

File tree

infrastructure/terraform/components/dl/scripts/sql/reports/daily_report.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ WITH vars AS (
1212
OR e.type LIKE '%.pdm.resource.retries.exceeded.%'
1313
OR e.type LIKE '%.messages.request.rejected.%' THEN 'Digital'
1414
WHEN e.type LIKE '%.print.letter.transitioned.%'
15-
OR e.type LIKE '%.print.file.quarantined.%' THEN 'Print' ELSE NULL
15+
OR e.type LIKE '%.print.file.quarantined.%'
16+
OR e.type LIKE '%.print.invalid.attachment.received.%' THEN 'Print' ELSE NULL
1617
END as communicationtype,
1718
CASE
1819
WHEN e.type LIKE '%.item.dequeued.%' THEN 'Unread'
@@ -21,6 +22,7 @@ WITH vars AS (
2122
WHEN e.type LIKE '%.pdm.resource.retries.exceeded.%' THEN 'Failed'
2223
WHEN e.type LIKE '%.messages.request.rejected.%' THEN 'Failed'
2324
WHEN e.type LIKE '%.print.file.quarantined.%' THEN 'Failed'
25+
WHEN e.type LIKE '%.print.invalid.attachment.received.%' THEN 'Failed'
2426
WHEN e.letterstatus = 'RETURNED' THEN 'Returned'
2527
WHEN e.letterstatus = 'FAILED' THEN 'Failed'
2628
WHEN e.letterstatus = 'DISPATCHED' THEN 'Dispatched'

tests/playwright/digital-letters-component-tests/report-generator.component.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ const scenarios = [
124124
'DL_CLIV_003',
125125
'Attachment contains a virus',
126126
),
127+
// Scenario for new Print failure event: InvalidAttachmentReceived
128+
new ReportScenario(
129+
'component-test-invalid-attachment-received',
130+
CommunicationType.Print,
131+
[EventStatus.PrintInvalidAttachmentReceived],
132+
'Failed',
133+
senderId,
134+
'DL_CLIV_002',
135+
'Invalid attachment received',
136+
),
127137
// multiple events for the same message reference, should take the one with highest priority status (returned > failed > dispatched > rejected)
128138
new ReportScenario(
129139
'component-test-rejected-pending',

tests/playwright/helpers/event-builders.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
DigitalLetterRead,
33
FileQuarantined,
4+
InvalidAttachmentReceived,
45
ItemDequeued,
56
MessageRequestRejected,
67
PDMResourceRetriesExceeded,
@@ -184,3 +185,24 @@ export function buildFileQuarantinedEvent(
184185
},
185186
} as FileQuarantined;
186187
}
188+
189+
export function buildInvalidAttachmentReceivedEvent(
190+
eventId: string,
191+
time: string,
192+
messageReference: string,
193+
senderId: string,
194+
): InvalidAttachmentReceived {
195+
const baseEvent = buildBaseEvent('print', time);
196+
return {
197+
...baseEvent,
198+
id: eventId,
199+
type: 'uk.nhs.notify.digital.letters.print.invalid.attachment.received.v1',
200+
dataschema:
201+
'https://notify.nhs.uk/cloudevents/schemas/digital-letters/2025-10-draft/data/digital-letters-print-invalid-attachment-received-data.schema.json',
202+
data: {
203+
messageReference,
204+
senderId,
205+
failureCode: 'DL_CLIV_002',
206+
},
207+
} as InvalidAttachmentReceived;
208+
}

tests/playwright/helpers/report-helpers.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
DigitalLetterRead,
1414
FileQuarantined,
1515
GenerateReport,
16+
InvalidAttachmentReceived,
1617
ItemDequeued,
1718
MessageRequestRejected,
1819
MessageRequestSkipped,
@@ -22,6 +23,7 @@ import {
2223
validateDigitalLetterRead,
2324
validateFileQuarantined,
2425
validateGenerateReport,
26+
validateInvalidAttachmentReceived,
2527
validateItemDequeued,
2628
validateMessageRequestRejected,
2729
validateMessageRequestSkipped,
@@ -40,6 +42,7 @@ import expectToPassEventually from 'helpers/expectations';
4042
import {
4143
buildDigitalLetterReadEvent,
4244
buildFileQuarantinedEvent,
45+
buildInvalidAttachmentReceivedEvent,
4346
buildItemDequeuedEvent,
4447
buildMessageRequestRejectedEvent,
4548
buildPDMResourceRetriesExceededEvent,
@@ -67,6 +70,7 @@ export enum EventStatus {
6770
DigitalPDMResourceRetriesExceeded = 'PDMResourceRetriesExceeded',
6871
DigitalMessageRequestRejected = 'MessageRequestRejected',
6972
PrintFileQuarantined = 'FileQuarantined',
73+
PrintInvalidAttachmentReceived = 'InvalidAttachmentReceived',
7074
}
7175
/**
7276
* Utility class to proof the SQL logic to determine which status should be reported for a given message reference,
@@ -219,6 +223,18 @@ export function publishEventForScenario(scenario: ReportScenario) {
219223
],
220224
validateFileQuarantined,
221225
);
226+
} else if (EventStatus.PrintInvalidAttachmentReceived === status) {
227+
eventPublisher.sendEvents<InvalidAttachmentReceived>(
228+
[
229+
buildInvalidAttachmentReceivedEvent(
230+
uuidv4(),
231+
scenario.time,
232+
scenario.messageReference,
233+
scenario.senderId,
234+
),
235+
],
236+
validateInvalidAttachmentReceived,
237+
);
222238
} else {
223239
eventPublisher.sendEvents<PrintLetterTransitioned>(
224240
[

utils/py-utils/dl_utils/failure_codes.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
code,description
2+
DL_CLIV_001,Local ID not provided
3+
DL_CLIV_002,Invalid attachment received
24
DL_PDMV_001,Letter rejected by PDM
35
DL_PDMV_002,Timeout waiting for letter storage
46
DL_CLIV_003,Attachment contains a virus

0 commit comments

Comments
 (0)