@@ -69,7 +69,7 @@ function createPreparedV1Event(
6969 requestItemId : "requestItem1" ,
7070 requestItemPlanId : "requestItemPlan1" ,
7171 clientId : "client1" ,
72- campaignId : "campaign1" ,
72+ campaignId : overrides . campaignId ?? "campaign1" ,
7373 templateId : "template1" ,
7474 url : overrides . url ?? "s3://letterDataBucket/letter1.pdf" ,
7575 sha256Hash :
@@ -230,6 +230,37 @@ describe("createSupplierAllocatorHandler", () => {
230230 } ) ;
231231 } ) ;
232232
233+ test ( "parses SNS notification and sends message to SQS queue for v2 event without a campaignId" , async ( ) => {
234+ const preparedEvent = createPreparedV2Event ( { campaignId : "" } ) ;
235+ const evt : SQSEvent = createSQSEvent ( [
236+ createSqsRecord ( "msg1" , JSON . stringify ( preparedEvent ) ) ,
237+ ] ) ;
238+
239+ setupDefaultMocks ( ) ;
240+ process . env . UPSERT_LETTERS_QUEUE_URL = "https://sqs.test.queue" ;
241+
242+ const handler = createSupplierAllocatorHandler ( mockedDeps ) ;
243+ const result = await handler ( evt , { } as any , { } as any ) ;
244+
245+ expect ( result ) . toBeDefined ( ) ;
246+ if ( ! result ) throw new Error ( "expected BatchResponse, got void" ) ;
247+
248+ expect ( result . batchItemFailures ) . toHaveLength ( 0 ) ;
249+
250+ expect ( mockSqsClient . send ) . toHaveBeenCalledTimes ( 1 ) ;
251+ const sendCall = ( mockSqsClient . send as jest . Mock ) . mock . calls [ 0 ] [ 0 ] ;
252+ expect ( sendCall ) . toBeInstanceOf ( SendMessageCommand ) ;
253+
254+ const messageBody = JSON . parse ( sendCall . input . MessageBody ) ;
255+ expect ( messageBody . letterEvent ) . toEqual ( preparedEvent ) ;
256+ expect ( messageBody . supplierSpec ) . toEqual ( {
257+ supplierId : "supplier1" ,
258+ specId : "spec1" ,
259+ priority : 1 ,
260+ billingId : "billing1" ,
261+ } ) ;
262+ } ) ;
263+
233264 test ( "parses SNS notification and sends message to SQS queue for v1 event" , async ( ) => {
234265 const preparedEvent = createPreparedV1Event ( ) ;
235266
0 commit comments