@@ -182,6 +182,77 @@ test.describe('@regression @e2e @epic4b-block-tests @smoke Tests', async () => {
182182 } ) ;
183183 } ) ;
184184
185+ test ( '@DTOSS-7617-01 AC1 - Verify no exception is raised to NBO when attempting to amend a blocked participant' , async ( { request } : { request : APIRequestContext } , testInfo : TestInfo ) => {
186+ // Arrange: Get test data for ADD
187+ const [ addValidations , addInputParticipantRecord , addNhsNumbers , addTestFilesPath ] = await getApiTestData ( testInfo . title , 'ADD' ) ;
188+ const nhsNumber = addNhsNumbers [ 0 ] ;
189+ await cleanupDatabaseFromAPI ( request , [ nhsNumber ] ) ;
190+
191+ // Add the participant
192+ const addParquetFile = await createParquetFromJson ( addNhsNumbers , addInputParticipantRecord , addTestFilesPath ) ;
193+ await processFileViaStorage ( addParquetFile ) ;
194+
195+ // Wait for participant to appear in DB before blocking
196+ let participantExists = false ;
197+ for ( let i = 0 ; i < 12 ; i ++ ) {
198+ const resp = await getRecordsFromParticipantManagementService ( request ) ;
199+ if ( resp ?. data && Array . isArray ( resp . data ) && resp . data . length > 0 && String ( resp . data [ 0 ] . NHSNumber ) === nhsNumber ) {
200+ participantExists = true ;
201+ break ;
202+ }
203+ console . log ( `Waiting for participant to appear in DB... (attempt ${ i + 1 } /12)` ) ;
204+ await new Promise ( res => setTimeout ( res , 2500 ) ) ;
205+ }
206+ expect ( participantExists ) . toBe ( true ) ;
207+
208+ // Block the participant
209+ const blockPayload = {
210+ NhsNumber : nhsNumber ,
211+ FamilyName : addInputParticipantRecord [ 0 ] . family_name ,
212+ DateOfBirth : addInputParticipantRecord [ 0 ] . date_of_birth
213+ } ;
214+ await BlockParticipant ( request , blockPayload ) ;
215+
216+ // Wait until the participant is actually blocked
217+ let blocked = false ;
218+ for ( let i = 0 ; i < 6 ; i ++ ) {
219+ const resp = await getRecordsFromParticipantManagementService ( request ) ;
220+ if ( resp ?. data ?. [ 0 ] ?. BlockedFlag === 1 ) {
221+ blocked = true ;
222+ break ;
223+ }
224+ console . log ( `Waiting for participant to be blocked... (attempt ${ i + 1 } /6)` ) ;
225+ await new Promise ( res => setTimeout ( res , 2000 ) ) ;
226+ }
227+ expect ( blocked ) . toBe ( true ) ;
228+
229+ // Act: Try to AMEND the blocked participant
230+ const [ amendValidations , amendInputParticipantRecord , amendNhsNumbers , amendTestFilesPath ] = await getApiTestData ( testInfo . title , 'AMEND_BLOCKED' ) ;
231+ const amendParquetFile = await createParquetFromJson ( amendNhsNumbers , amendInputParticipantRecord , amendTestFilesPath ) ;
232+ await processFileViaStorage ( amendParquetFile ) ;
233+
234+ // Assert: No exception raised to NBO
235+ await test . step ( 'No exception should be raised to NBO' , async ( ) => {
236+ const response = await getValidationExceptions ( request , 3 , nhsNumber ) ;
237+ expect ( response . data === null || ( Array . isArray ( response . data ) && response . data . length === 0 ) ) . toBe ( true ) ;
238+ } ) ;
239+
240+ // Assert: Participant remains blocked
241+ await test . step ( 'Participant should remain blocked' , async ( ) => {
242+ const resp = await getRecordsFromParticipantManagementService ( request ) ;
243+ expect ( resp ?. data ?. [ 0 ] ?. BlockedFlag ) . toBe ( 1 ) ;
244+ } ) ;
245+
246+ // Assert: Participant data should NOT be updated in the DB
247+ await test . step ( 'Participant data should not be updated' , async ( ) => {
248+ const resp = await getRecordsFromParticipantManagementService ( request ) ;
249+ // Verify that the participant is still in the DB with original record type
250+ expect ( resp ?. data ?. [ 0 ] ?. NHSNumber ) . toBe ( Number ( nhsNumber ) ) ;
251+ expect ( resp ?. data ?. [ 0 ] ?. RecordType ) . toBe ( "ADD" ) ;
252+ expect ( resp ?. data ?. [ 0 ] ?. BlockedFlag ) . toBe ( 1 ) ;
253+ } ) ;
254+ } ) ;
255+
185256 test ( '@DTOSS-7660-01 AC2 - Blocked participant AMEND action does not raise exception to NBO' , async ( { request } : { request : APIRequestContext } , testInfo : TestInfo ) => {
186257 // Arrange: Get test data
187258 const [ addValidations , addInputParticipantRecord , addNhsNumbers , addTestFilesPath ] = await getApiTestData ( testInfo . title , 'ADD_BLOCKED' ) ;
0 commit comments