Skip to content

Commit 0a20ae9

Browse files
CM-11976: Add event tests
1 parent 24e3863 commit 0a20ae9

File tree

5 files changed

+417
-20
lines changed

5 files changed

+417
-20
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"data": {
3+
"campaignId": "campaign-id",
4+
"cascade": [
5+
{
6+
"cascadeGroups": [
7+
"standard"
8+
],
9+
"channel": "NHS_APP",
10+
"channelType": "primary",
11+
"defaultTemplateId": "nhs-app-template-id"
12+
},
13+
{
14+
"cascadeGroups": [
15+
"standard"
16+
],
17+
"channel": "EMAIL",
18+
"channelType": "primary",
19+
"defaultTemplateId": "email-template-id"
20+
},
21+
{
22+
"cascadeGroups": [
23+
"standard"
24+
],
25+
"channel": "SMS",
26+
"channelType": "primary",
27+
"defaultTemplateId": "sms-template-id"
28+
},
29+
{
30+
"cascadeGroups": [
31+
"standard"
32+
],
33+
"channel": "LETTER",
34+
"channelType": "primary",
35+
"defaultTemplateId": "letter-template-id"
36+
},
37+
{
38+
"cascadeGroups": [
39+
"other-language"
40+
],
41+
"channel": "LETTER",
42+
"channelType": "primary",
43+
"conditionalTemplates": [
44+
{
45+
"language": "fr",
46+
"templateId": "fr-template-id"
47+
},
48+
{
49+
"language": "ar",
50+
"templateId": "ar-template-id"
51+
}
52+
]
53+
},
54+
{
55+
"cascadeGroups": [
56+
"other-format"
57+
],
58+
"channe": "LETTER",
59+
"channelType": "primary",
60+
"conditionalTemplates": [
61+
{
62+
"accessibleFormat": "x1",
63+
"templateId": "x1-template-id"
64+
}
65+
]
66+
}
67+
],
68+
"cascadeGroupOverrides": [
69+
{
70+
"language": [
71+
"fr",
72+
"ar"
73+
],
74+
"name": "other-language"
75+
},
76+
{
77+
"accessibleFormat": [
78+
"x1"
79+
],
80+
"name": "other-format"
81+
}
82+
],
83+
"clientId": "client-id",
84+
"createdAt": "2025-07-29T08:45:00.000Z",
85+
"defaultCascadeGroup": "standard",
86+
"id": "12f1f09c-a555-4d9b-8405-0b33490bc929",
87+
"name": "routing-config-name",
88+
"status": "COMPLETED"
89+
},
90+
"datacontenttype": "application/json",
91+
"dataschema": "https://notify.nhs.uk/events/schemas/RoutingConfigCompleted/v1.json",
92+
"dataschemaversion": "1.0.0",
93+
"id": "12f1f09c-a555-4d9b-8405-0b33490bc929",
94+
"plane": "control",
95+
"source": "//notify.nhs.uk/app/nhs-notify-template-management-prod/main",
96+
"specversion": "1.0",
97+
"subject": "871b0f4e-0b32-474e-a49a-23fc554bc5a6",
98+
"time": "2025-07-29T08:45:00.000Z",
99+
"type": "uk.nhs.notify.template-management.RoutingConfigCompleted.v1"
100+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"data": {
3+
"campaignId": "campaign-id",
4+
"cascade": [
5+
{
6+
"cascadeGroups": [
7+
"standard"
8+
],
9+
"channel": "NHS_APP",
10+
"channelType": "primary",
11+
"defaultTemplateId": "nhs-app-template-id"
12+
},
13+
{
14+
"cascadeGroups": [
15+
"standard"
16+
],
17+
"channel": "EMAIL",
18+
"channelType": "primary",
19+
"defaultTemplateId": "email-template-id"
20+
},
21+
{
22+
"cascadeGroups": [
23+
"standard"
24+
],
25+
"channel": "SMS",
26+
"channelType": "primary",
27+
"defaultTemplateId": "sms-template-id"
28+
},
29+
{
30+
"cascadeGroups": [
31+
"standard"
32+
],
33+
"channel": "LETTER",
34+
"channelType": "primary",
35+
"defaultTemplateId": "letter-template-id"
36+
},
37+
{
38+
"cascadeGroups": [
39+
"other-language"
40+
],
41+
"channel": "LETTER",
42+
"channelType": "primary",
43+
"conditionalTemplates": [
44+
{
45+
"language": "fr",
46+
"templateId": "fr-template-id"
47+
},
48+
{
49+
"language": "ar",
50+
"templateId": "ar-template-id"
51+
}
52+
]
53+
},
54+
{
55+
"cascadeGroups": [
56+
"other-format"
57+
],
58+
"channe": "LETTER",
59+
"channelType": "primary",
60+
"conditionalTemplates": [
61+
{
62+
"accessibleFormat": "x1",
63+
"templateId": "x1-template-id"
64+
}
65+
]
66+
}
67+
],
68+
"cascadeGroupOverrides": [
69+
{
70+
"language": [
71+
"fr",
72+
"ar"
73+
],
74+
"name": "other-language"
75+
},
76+
{
77+
"accessibleFormat": [
78+
"x1"
79+
],
80+
"name": "other-format"
81+
}
82+
],
83+
"clientId": "client-id",
84+
"createdAt": "2025-07-29T08:45:00.000Z",
85+
"defaultCascadeGroup": "standard",
86+
"id": "12f1f09c-a555-4d9b-8405-0b33490bc929",
87+
"name": "routing-config-name",
88+
"status": "DELETED"
89+
},
90+
"datacontenttype": "application/json",
91+
"dataschema": "https://notify.nhs.uk/events/schemas/RoutingConfigDeleted/v1.json",
92+
"dataschemaversion": "1.0.0",
93+
"id": "12f1f09c-a555-4d9b-8405-0b33490bc929",
94+
"plane": "control",
95+
"source": "//notify.nhs.uk/app/nhs-notify-template-management-prod/main",
96+
"specversion": "1.0",
97+
"subject": "871b0f4e-0b32-474e-a49a-23fc554bc5a6",
98+
"time": "2025-07-29T08:45:00.000Z",
99+
"type": "uk.nhs.notify.template-management.RoutingConfigDeleted.v1"
100+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"data": {
3+
"campaignId": "campaign-id",
4+
"cascade": [
5+
{
6+
"cascadeGroups": [
7+
"standard"
8+
],
9+
"channel": "NHS_APP",
10+
"channelType": "primary",
11+
"defaultTemplateId": "nhs-app-template-id"
12+
},
13+
{
14+
"cascadeGroups": [
15+
"standard"
16+
],
17+
"channel": "EMAIL",
18+
"channelType": "primary",
19+
"defaultTemplateId": "email-template-id"
20+
},
21+
{
22+
"cascadeGroups": [
23+
"standard"
24+
],
25+
"channel": "SMS",
26+
"channelType": "primary",
27+
"defaultTemplateId": "sms-template-id"
28+
},
29+
{
30+
"cascadeGroups": [
31+
"standard"
32+
],
33+
"channel": "LETTER",
34+
"channelType": "primary",
35+
"defaultTemplateId": "letter-template-id"
36+
},
37+
{
38+
"cascadeGroups": [
39+
"other-language"
40+
],
41+
"channel": "LETTER",
42+
"channelType": "primary",
43+
"conditionalTemplates": [
44+
{
45+
"language": "fr",
46+
"templateId": "fr-template-id"
47+
},
48+
{
49+
"language": "ar",
50+
"templateId": "ar-template-id"
51+
}
52+
]
53+
},
54+
{
55+
"cascadeGroups": [
56+
"other-format"
57+
],
58+
"channe": "LETTER",
59+
"channelType": "primary",
60+
"conditionalTemplates": [
61+
{
62+
"accessibleFormat": "x1",
63+
"templateId": "x1-template-id"
64+
}
65+
]
66+
}
67+
],
68+
"cascadeGroupOverrides": [
69+
{
70+
"language": [
71+
"fr",
72+
"ar"
73+
],
74+
"name": "other-language"
75+
},
76+
{
77+
"accessibleFormat": [
78+
"x1"
79+
],
80+
"name": "other-format"
81+
}
82+
],
83+
"clientId": "client-id",
84+
"createdAt": "2025-07-29T08:45:00.000Z",
85+
"defaultCascadeGroup": "standard",
86+
"id": "12f1f09c-a555-4d9b-8405-0b33490bc929",
87+
"name": "routing-config-name",
88+
"status": "DRAFT"
89+
},
90+
"datacontenttype": "application/json",
91+
"dataschema": "https://notify.nhs.uk/events/schemas/RoutingConfigDrafted/v1.json",
92+
"dataschemaversion": "1.0.0",
93+
"id": "12f1f09c-a555-4d9b-8405-0b33490bc929",
94+
"plane": "control",
95+
"source": "//notify.nhs.uk/app/nhs-notify-template-management-prod/main",
96+
"specversion": "1.0",
97+
"subject": "871b0f4e-0b32-474e-a49a-23fc554bc5a6",
98+
"time": "2025-07-29T08:45:00.000Z",
99+
"type": "uk.nhs.notify.template-management.RoutingConfigDrafted.v1"
100+
}

tests/test-team/helpers/events/event-cache-helper.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export class EventCacheHelper {
2626

2727
async findEvents(
2828
from: Date,
29-
templateIds: string[]
29+
ids: string[]
3030
): Promise<NHSNotifyTemplateEvent[]> {
31-
if (templateIds.length === 0) {
31+
if (ids.length === 0) {
3232
return [];
3333
}
3434

@@ -41,7 +41,7 @@ export class EventCacheHelper {
4141
const filteredFiles = S3Helper.filterAndSort(files.flat(), from);
4242

4343
const eventPromises = filteredFiles.map((file) =>
44-
this.queryFileForEvents(file.Key!, templateIds)
44+
this.queryFileForEvents(file.Key!, ids)
4545
);
4646

4747
const results = await Promise.all(eventPromises);
@@ -51,9 +51,9 @@ export class EventCacheHelper {
5151

5252
private async queryFileForEvents(
5353
fileName: string,
54-
templateIds: string[]
54+
ids: string[]
5555
): Promise<NHSNotifyTemplateEvent[]> {
56-
const formattedIds = templateIds.map((r) => `'${r}'`);
56+
const formattedIds = ids.map((r) => `'${r}'`);
5757

5858
const response = await S3Helper.queryJSONLFile(
5959
this.bucketName,

0 commit comments

Comments
 (0)