@@ -151,6 +151,7 @@ function setupDefaultMocks() {
151151 ( supplierConfig . getVariantDetails as jest . Mock ) . mockResolvedValue ( {
152152 id : "v1" ,
153153 volumeGroupId : "g1" ,
154+ priority : 1 ,
154155 } ) ;
155156 ( supplierConfig . getVolumeGroupDetails as jest . Mock ) . mockResolvedValue ( {
156157 id : "g1" ,
@@ -161,19 +162,18 @@ function setupDefaultMocks() {
161162 suppliers : [ { id : "s1" , name : "Supplier 1" , status : "PROD" } ] ,
162163 } ) ;
163164 ( allocationConfig . preferredSupplierPack as jest . Mock ) . mockResolvedValue ( {
164- id : "pack-spec-1 " ,
165+ id : "spec1 " ,
165166 type : "A4" ,
166167 colour : false ,
167168 duplex : false ,
169+ billingId : "billing1" ,
168170 } ) ;
169171 ( allocationConfig . filterSuppliersWithCapacity as jest . Mock ) . mockResolvedValue (
170172 [ { id : "s1" , name : "Supplier 1" , status : "PROD" } ] ,
171173 ) ;
172- ( allocationConfig . selectSupplierByFactor as jest . Mock ) . mockResolvedValue ( {
173- id : "s1" ,
174- name : "Supplier 1" ,
175- status : "PROD" ,
176- } ) ;
174+ ( allocationConfig . selectSupplierByFactor as jest . Mock ) . mockResolvedValue (
175+ "supplier1" ,
176+ ) ;
177177 ( allocationConfig . suppliersWithValidPack as jest . Mock ) . mockResolvedValue ( [
178178 { id : "s1" , name : "Supplier 1" , status : "PROD" } ,
179179 ] ) ;
@@ -334,24 +334,6 @@ describe("createSupplierAllocatorHandler", () => {
334334 expect ( messageBody . letterEvent . data . domainId ) . toBe ( "letter-test" ) ;
335335 } ) ;
336336
337- test ( "resolves correct supplier spec from variant map" , async ( ) => {
338- const preparedEvent = createPreparedV2Event ( ) ;
339-
340- const evt : SQSEvent = createSQSEvent ( [
341- createSqsRecord ( "msg1" , JSON . stringify ( preparedEvent ) ) ,
342- ] ) ;
343-
344- process . env . UPSERT_LETTERS_QUEUE_URL = "https://sqs.test.queue" ;
345-
346- const handler = createSupplierAllocatorHandler ( mockedDeps ) ;
347- await handler ( evt , { } as any , { } as any ) ;
348-
349- const sendCall = ( mockSqsClient . send as jest . Mock ) . mock . calls [ 0 ] [ 0 ] ;
350- const messageBody = JSON . parse ( sendCall . input . MessageBody ) ;
351- expect ( messageBody . supplierSpec . supplierId ) . toBe ( "supplier1" ) ;
352- expect ( messageBody . supplierSpec . specId ) . toBe ( "spec1" ) ;
353- } ) ;
354-
355337 test ( "processes multiple messages in batch" , async ( ) => {
356338 const evt : SQSEvent = createSQSEvent ( [
357339 createSqsRecord (
@@ -574,8 +556,8 @@ describe("createSupplierAllocatorHandler", () => {
574556 const handler = createSupplierAllocatorHandler ( mockedDeps ) ;
575557 const result = await handler ( evt , { } as any , { } as any ) ;
576558 if ( ! result ) throw new Error ( "expected BatchResponse, got void" ) ;
577- expect ( result . batchItemFailures ) . toHaveLength ( 0 ) ;
578- expect ( ( mockedDeps . logger . error as jest . Mock ) . mock . calls ) . toHaveLength ( 1 ) ;
559+ expect ( result . batchItemFailures ) . toHaveLength ( 1 ) ;
560+ expect ( ( mockedDeps . logger . error as jest . Mock ) . mock . calls ) . toHaveLength ( 2 ) ;
579561 expect ( ( mockedDeps . logger . error as jest . Mock ) . mock . calls [ 0 ] [ 0 ] ) . toEqual (
580562 expect . objectContaining ( {
581563 description : "Error fetching supplier from config" ,
@@ -654,8 +636,8 @@ describe("createSupplierAllocatorHandler", () => {
654636 const result = await handler ( evt , { } as any , { } as any ) ;
655637 if ( ! result ) throw new Error ( "expected BatchResponse, got void" ) ;
656638
657- expect ( result . batchItemFailures ) . toHaveLength ( 0 ) ;
658- expect ( ( mockedDeps . logger . error as jest . Mock ) . mock . calls ) . toHaveLength ( 1 ) ;
639+ expect ( result . batchItemFailures ) . toHaveLength ( 1 ) ;
640+ expect ( ( mockedDeps . logger . error as jest . Mock ) . mock . calls ) . toHaveLength ( 2 ) ;
659641 expect ( ( mockedDeps . logger . error as jest . Mock ) . mock . calls [ 0 ] [ 0 ] ) . toEqual (
660642 expect . objectContaining ( {
661643 description : "Error fetching supplier from config" ,
0 commit comments