Skip to content

Commit 5278f3f

Browse files
CM-11976: Fix tests
1 parent c103649 commit 5278f3f

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { z } from 'zod';
22
import { SelectObjectContentEventStream } from '@aws-sdk/client-s3';
33
import {
4+
$RoutingConfigCompletedEventV1,
5+
$RoutingConfigDeletedEventV1,
6+
$RoutingConfigDraftedEventV1,
47
$TemplateCompletedEventV1,
58
$TemplateDeletedEventV1,
69
$TemplateDraftedEventV1,
@@ -13,21 +16,21 @@ import {
1316
} from 'date-fns';
1417
import { S3Helper } from '../s3-helper';
1518

16-
const $NHSNotifyTemplateEvent = z.discriminatedUnion('type', [
19+
const $NHSNotifyEvent = z.discriminatedUnion('type', [
1720
$TemplateCompletedEventV1,
1821
$TemplateDraftedEventV1,
1922
$TemplateDeletedEventV1,
23+
$RoutingConfigCompletedEventV1,
24+
$RoutingConfigDraftedEventV1,
25+
$RoutingConfigDeletedEventV1,
2026
]);
2127

22-
type NHSNotifyTemplateEvent = z.infer<typeof $NHSNotifyTemplateEvent>;
28+
type NHSNotifyEvent = z.infer<typeof $NHSNotifyEvent>;
2329

2430
export class EventCacheHelper {
2531
private readonly bucketName = process.env.EVENT_CACHE_BUCKET_NAME;
2632

27-
async findEvents(
28-
from: Date,
29-
ids: string[]
30-
): Promise<NHSNotifyTemplateEvent[]> {
33+
async findEvents(from: Date, ids: string[]): Promise<NHSNotifyEvent[]> {
3134
if (ids.length === 0) {
3235
return [];
3336
}
@@ -52,7 +55,7 @@ export class EventCacheHelper {
5255
private async queryFileForEvents(
5356
fileName: string,
5457
ids: string[]
55-
): Promise<NHSNotifyTemplateEvent[]> {
58+
): Promise<NHSNotifyEvent[]> {
5659
const formattedIds = ids.map((r) => `'${r}'`);
5760

5861
const response = await S3Helper.queryJSONLFile(
@@ -71,8 +74,8 @@ export class EventCacheHelper {
7174
private async parse(
7275
fileName: string,
7376
payload: AsyncIterable<SelectObjectContentEventStream>
74-
): Promise<NHSNotifyTemplateEvent[]> {
75-
const events: NHSNotifyTemplateEvent[] = [];
77+
): Promise<NHSNotifyEvent[]> {
78+
const events: NHSNotifyEvent[] = [];
7679

7780
for await (const event of payload) {
7881
if (!event.Records?.Payload) continue;
@@ -83,7 +86,7 @@ export class EventCacheHelper {
8386
.split('\n')
8487
.filter((line) => line.trim())
8588
.map((line) => {
86-
const { data, success, error } = $NHSNotifyTemplateEvent.safeParse(
89+
const { data, success, error } = $NHSNotifyEvent.safeParse(
8790
JSON.parse(line)
8891
);
8992

0 commit comments

Comments
 (0)