11import { expect , test } from '../../fixtures/test-fixtures' ;
2- import { extractSubscriptionID , getRecordsFromNemsSubscription , getRecordsFromParticipantDemographicService , getRecordsFromParticipantManagementService , receiveParticipantViaServiceNow } from "../../../api/distributionService/bsSelectService" ;
2+ import { extractSubscriptionID , getRecordsFromNemsSubscription , getRecordsFromParticipantDemographicService , getRecordsFromParticipantManagementService , receiveParticipantViaServiceNow , retry } from "../../../api/distributionService/bsSelectService" ;
33import { composeValidators , expectStatus } from "../../../api/responseValidators" ;
44import { ParticipantRecord } from '../../../interface/InputData' ;
55import { loadParticipantPayloads } from '../../fixtures/jsonDataReader' ;
@@ -8,10 +8,10 @@ test.describe('@DTOSS-3881-01 @e2e @epic4c- Cohort Manger subscribed the Added r
88
99 let participantData : Record < string , ParticipantRecord > ;
1010
11- test . beforeAll ( ( ) => {
11+ test . beforeAll ( async ( ) => {
1212 const folderName = '@DTOSS-3881-01' ;
1313 const fileName = 'ADD-participantPayload.json' ;
14- participantData = loadParticipantPayloads ( folderName , fileName ) ;
14+ participantData = await loadParticipantPayloads ( folderName , fileName ) ;
1515 } ) ;
1616
1717 test ( '@DTOSS-3881-01 DTOSS-10011 @not-runner-based - Verify subscription IDs on Nems table for ADD' , {
@@ -22,7 +22,7 @@ test.describe('@DTOSS-3881-01 @e2e @epic4c- Cohort Manger subscribed the Added r
2222 } , async ( { request } , testInfo ) => {
2323
2424 await test . step ( 'Given Cohort manager receives data from ServiceNow and subscribed to PDS' , async ( ) => {
25- const payload = participantData [ 'inputParticipantRecord_test ' ] ;
25+ const payload = participantData [ 'inputParticipantRecord ' ] ;
2626 const response = await receiveParticipantViaServiceNow ( request , payload ) ;
2727 const validators = composeValidators (
2828 expectStatus ( 202 )
@@ -31,55 +31,44 @@ test.describe('@DTOSS-3881-01 @e2e @epic4c- Cohort Manger subscribed the Added r
3131 } ) ;
3232
3333 await test . step ( 'Then NHSNumber, GivenName, FamilyName is written to Participant Demographic table' , async ( ) => {
34- const response = await getRecordsFromParticipantDemographicService ( request ) ;
35-
34+ const response = await retry (
35+ ( ) => getRecordsFromParticipantDemographicService ( request ) ,
36+ ( res ) =>
37+ res ?. data ?. [ 0 ] ?. NhsNumber === 9997160908 &&
38+ res ?. data ?. [ 0 ] ?. GivenName === "Jane" &&
39+ res ?. data ?. [ 0 ] ?. FamilyName === "Doe" ,
40+ { retries : 5 , delayMs : 2000 }
41+ ) ;
3642 expect ( response ?. data ?. [ 0 ] ?. NhsNumber ) . toBe ( 9997160908 ) ;
3743 expect ( response ?. data ?. [ 0 ] ?. GivenName ) . toBe ( "Jane" ) ;
3844 expect ( response ?. data ?. [ 0 ] ?. FamilyName ) . toBe ( "Doe" ) ;
3945 } ) ;
4046
4147 await test . step ( 'And NHSNumber, ScreeningId, ReferralFlag is written to Participant Management table' , async ( ) => {
42- const response = await getRecordsFromParticipantManagementService ( request ) ;
48+ const response = await retry (
49+ ( ) => getRecordsFromParticipantManagementService ( request ) ,
50+ ( res ) =>
51+ res ?. data ?. [ 0 ] ?. NHSNumber === 9997160908 &&
52+ res ?. data ?. [ 0 ] ?. ScreeningId === 1 &&
53+ res ?. data ?. [ 0 ] ?. ReferralFlag === 1 ,
54+ { retries : 5 , delayMs : 2000 }
55+ ) ;
4356 expect ( response ?. data ?. [ 0 ] ?. NHSNumber ) . toBe ( 9997160908 ) ;
4457 expect ( response ?. data ?. [ 0 ] ?. ScreeningId ) . toBe ( 1 ) ;
4558 expect ( response ?. data ?. [ 0 ] ?. ReferralFlag ) . toBe ( 1 ) ;
4659 } ) ;
4760
48- await test . step ( 'Assert that NemsSubscription service is available ' , async ( ) => {
49- const nhsNumber = participantData [ 'inputParticipantRecord_test ' ] . u_case_variable_data . nhs_number ;
61+ await test . step ( 'DTOSS-10012 ADD verify NemsSubscription in NEMS_SUBSCRIPTION table ' , async ( ) => {
62+ const nhsNumber = participantData [ 'inputParticipantRecord ' ] . u_case_variable_data . nhs_number ;
5063 const response = await getRecordsFromNemsSubscription ( request , nhsNumber ) ;
5164 const validators = composeValidators (
5265 expectStatus ( 200 )
5366 ) ;
5467 await validators ( response ) ;
55- } ) ;
56-
57- await test . step ( `DTOSS-10012 ADD verify NemsSubscription in NEMS_SUBSCRIPTION table` , async ( ) => {
58- const nhsNumber = participantData [ 'inputParticipantRecord_test' ] . u_case_variable_data . nhs_number ;
59-
60- const response = await getRecordsFromNemsSubscription ( request , nhsNumber ) ;
6168 const subscriptionID = extractSubscriptionID ( response ) ;
62- expect ( response . status ) . toBe ( 200 ) ;
6369 expect ( subscriptionID ) . not . toBeNull ( ) ;
6470
6571 console . log ( `Extracted Subscription ID: ${ subscriptionID } for NHS number: ${ nhsNumber } ` ) ;
6672 } ) ;
6773 } ) ;
68-
69- test ( '@DTOSS-3881-02 DTOSS-10013 @not-runner-based AMEND verify NemsSubscription_id in NEMS_SUBSCRIPTION table' , {
70- annotation : [ {
71- type : 'Requirement - https://nhsd-jira.digital.nhs.uk/browse/DTOSS-3881' ,
72- description : 'Tests - https://nhsd-jira.digital.nhs.uk/browse/DTOSS-10013' ,
73- } ]
74- } , async ( { request } , testInfo ) => {
75-
76- const nhsNumber = '9996534472' ;
77-
78- const response = await getRecordsFromNemsSubscription ( request , nhsNumber ) ;
79- const subscriptionID = extractSubscriptionID ( response ) ;
80- expect ( response . status ) . toBe ( 200 ) ;
81- expect ( subscriptionID ) . not . toBeNull ( ) ;
82-
83- console . log ( `Extracted Subscription ID: ${ subscriptionID } for NHS number: ${ nhsNumber } ` ) ;
84- } ) ;
8574} ) ;
0 commit comments