@@ -12,6 +12,7 @@ import { readFileSync } from 'node:fs';
1212import { SftpHelper } from '../helpers/sftp/sftp-helper' ;
1313import { InvokeCommand , LambdaClient } from '@aws-sdk/client-lambda' ;
1414import { setTimeout } from 'node:timers/promises' ;
15+ import { Template } from 'helpers/types' ;
1516
1617test . describe ( 'Event publishing - Letters' , ( ) => {
1718 const authHelper = createAuthHelper ( ) ;
@@ -117,18 +118,18 @@ test.describe('Event publishing - Letters', () => {
117118 } ) => {
118119 const templateId = randomUUID ( ) ;
119120
120- await templateStorageHelper . seedTemplateData ( [
121- {
122- ... TemplateFactory . uploadLetterTemplate (
123- templateId ,
124- userProofingEnabled ,
125- 'userProofingEnabledTemplate' ,
126- 'PENDING_PROOF_REQUEST'
127- ) ,
128- // the values in this array do not matter at this point
129- personalisationParameters : [ 'nhsNumber' ] ,
130- } ,
131- ] ) ;
121+ const template = {
122+ ... TemplateFactory . uploadLetterTemplate (
123+ templateId ,
124+ userProofingEnabled ,
125+ 'userProofingEnabledTemplate' ,
126+ 'PENDING_PROOF_REQUEST'
127+ ) ,
128+ // the values in this array do not matter at this point
129+ personalisationParameters : [ 'nhsNumber' ] ,
130+ } ;
131+
132+ await templateStorageHelper . seedTemplateData ( [ template ] ) ;
132133
133134 const start = new Date ( ) ;
134135
@@ -162,6 +163,7 @@ test.describe('Event publishing - Letters', () => {
162163 {
163164 headers : {
164165 Authorization : await userProofingEnabled . getAccessToken ( ) ,
166+ 'X-Lock-Number' : String ( template . lockNumber ) ,
165167 } ,
166168 }
167169 ) ;
@@ -177,20 +179,23 @@ test.describe('Event publishing - Letters', () => {
177179 } )
178180 ) ;
179181
182+ let latest : Template = template ;
183+
180184 await expect ( async ( ) => {
181- const template = await templateStorageHelper . getTemplate ( {
185+ latest = await templateStorageHelper . getTemplate ( {
182186 templateId,
183187 clientId : userProofingEnabled . clientId ,
184188 } ) ;
185189
186- expect ( template . templateStatus ) . toBe ( 'PROOF_AVAILABLE' ) ;
190+ expect ( latest . templateStatus ) . toBe ( 'PROOF_AVAILABLE' ) ;
187191 } ) . toPass ( { timeout : 15_000 , intervals : [ 1000 , 3000 , 5000 ] } ) ;
188192
189193 const submitResponse = await request . patch (
190194 `${ process . env . API_BASE_URL } /v1/template/${ templateId } /submit` ,
191195 {
192196 headers : {
193197 Authorization : await userProofingEnabled . getAccessToken ( ) ,
198+ 'X-Lock-Number' : String ( latest . lockNumber ) ,
194199 } ,
195200 }
196201 ) ;
0 commit comments